diff options
author | Oleksandr Koval <oleksandr.koval.dev@gmail.com> | 2021-01-05 12:32:36 (GMT) |
---|---|---|
committer | Oleksandr Koval <oleksandr.koval.dev@gmail.com> | 2021-01-05 12:32:36 (GMT) |
commit | 209daa20b2bd2ee2a76e70af58e895647f7e284f (patch) | |
tree | 081f3192927b19325f40c0da459a11e5b5a5784b /Source/CPack/cmCPackDebGenerator.cxx | |
parent | 764ce15ffbe232347a41e40509a2e485bae226f6 (diff) | |
download | CMake-209daa20b2bd2ee2a76e70af58e895647f7e284f.zip CMake-209daa20b2bd2ee2a76e70af58e895647f7e284f.tar.gz CMake-209daa20b2bd2ee2a76e70af58e895647f7e284f.tar.bz2 |
Code style: add missed explicit 'this->'
CMake uses explicit 'this->' style. Using custom clang-tidy check we can
detect and fix places where 'this->' was missed.
Diffstat (limited to 'Source/CPack/cmCPackDebGenerator.cxx')
-rw-r--r-- | Source/CPack/cmCPackDebGenerator.cxx | 183 |
1 files changed, 95 insertions, 88 deletions
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 6f21d87..43dbdb5 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -96,20 +96,20 @@ DebGenerator::DebGenerator( } if (!strcmp(debianCompressionType, "lzma")) { - CompressionSuffix = ".lzma"; - TarCompressionType = cmArchiveWrite::CompressLZMA; + this->CompressionSuffix = ".lzma"; + this->TarCompressionType = cmArchiveWrite::CompressLZMA; } else if (!strcmp(debianCompressionType, "xz")) { - CompressionSuffix = ".xz"; - TarCompressionType = cmArchiveWrite::CompressXZ; + this->CompressionSuffix = ".xz"; + this->TarCompressionType = cmArchiveWrite::CompressXZ; } else if (!strcmp(debianCompressionType, "bzip2")) { - CompressionSuffix = ".bz2"; - TarCompressionType = cmArchiveWrite::CompressBZip2; + this->CompressionSuffix = ".bz2"; + this->TarCompressionType = cmArchiveWrite::CompressBZip2; } else if (!strcmp(debianCompressionType, "gzip")) { - CompressionSuffix = ".gz"; - TarCompressionType = cmArchiveWrite::CompressGZip; + this->CompressionSuffix = ".gz"; + this->TarCompressionType = cmArchiveWrite::CompressGZip; } else if (!strcmp(debianCompressionType, "none")) { - CompressionSuffix.clear(); - TarCompressionType = cmArchiveWrite::CompressNone; + this->CompressionSuffix.clear(); + this->TarCompressionType = cmArchiveWrite::CompressNone; } else { cmCPackLogger(cmCPackLog::LOG_ERROR, "Error unrecognized compression type: " @@ -119,22 +119,22 @@ DebGenerator::DebGenerator( bool DebGenerator::generate() const { - generateDebianBinaryFile(); - generateControlFile(); - if (!generateDataTar()) { + this->generateDebianBinaryFile(); + this->generateControlFile(); + if (!this->generateDataTar()) { return false; } - std::string md5Filename = generateMD5File(); - if (!generateControlTar(md5Filename)) { + std::string md5Filename = this->generateMD5File(); + if (!this->generateControlTar(md5Filename)) { return false; } - return generateDeb(); + return this->generateDeb(); } void DebGenerator::generateDebianBinaryFile() const { // debian-binary file - const std::string dbfilename = WorkDir + "/debian-binary"; + const std::string dbfilename = this->WorkDir + "/debian-binary"; cmGeneratedFileStream out; out.Open(dbfilename, false, true); out << "2.0\n"; // required for valid debian package @@ -142,18 +142,18 @@ void DebGenerator::generateDebianBinaryFile() const void DebGenerator::generateControlFile() const { - std::string ctlfilename = WorkDir + "/control"; + std::string ctlfilename = this->WorkDir + "/control"; cmGeneratedFileStream out; out.Open(ctlfilename, false, true); - for (auto const& kv : ControlValues) { + for (auto const& kv : this->ControlValues) { out << kv.first << ": " << kv.second << "\n"; } unsigned long totalSize = 0; { - std::string dirName = cmStrCat(TemporaryDir, '/'); - for (std::string const& file : PackageFiles) { + std::string dirName = cmStrCat(this->TemporaryDir, '/'); + for (std::string const& file : this->PackageFiles) { totalSize += cmSystemTools::FileLength(file); } } @@ -162,7 +162,8 @@ void DebGenerator::generateControlFile() const bool DebGenerator::generateDataTar() const { - std::string filename_data_tar = WorkDir + "/data.tar" + CompressionSuffix; + std::string filename_data_tar = + this->WorkDir + "/data.tar" + this->CompressionSuffix; cmGeneratedFileStream fileStream_data_tar; fileStream_data_tar.Open(filename_data_tar, false, true); if (!fileStream_data_tar) { @@ -171,8 +172,8 @@ bool DebGenerator::generateDataTar() const << filename_data_tar << "\" for writing" << std::endl); return false; } - cmArchiveWrite data_tar(fileStream_data_tar, TarCompressionType, - DebianArchiveType); + cmArchiveWrite data_tar(fileStream_data_tar, this->TarCompressionType, + this->DebianArchiveType); data_tar.Open(); // uid/gid should be the one of the root user, and this root user has @@ -184,16 +185,16 @@ bool DebGenerator::generateDataTar() const // collect all top level install dirs for that // e.g. /opt/bin/foo, /usr/bin/bar and /usr/bin/baz would // give /usr and /opt - size_t topLevelLength = WorkDir.length(); + size_t topLevelLength = this->WorkDir.length(); cmCPackLogger(cmCPackLog::LOG_DEBUG, - "WDIR: \"" << WorkDir << "\", length = " << topLevelLength - << std::endl); + "WDIR: \"" << this->WorkDir + << "\", length = " << topLevelLength << std::endl); std::set<std::string> orderedFiles; // we have to reconstruct the parent folders as well - for (std::string currentPath : PackageFiles) { - while (currentPath != WorkDir) { + for (std::string currentPath : this->PackageFiles) { + while (currentPath != this->WorkDir) { // the last one IS WorkDir, but we do not want this one: // XXX/application/usr/bin/myprogram with GEN_WDIR=XXX/application // should not add XXX/application @@ -235,7 +236,7 @@ bool DebGenerator::generateDataTar() const cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem adding file to tar:" << std::endl - << "#top level directory: " << WorkDir << std::endl + << "#top level directory: " << this->WorkDir << std::endl << "#file: " << file << std::endl << "#error:" << data_tar.GetError() << std::endl); return false; @@ -246,13 +247,13 @@ bool DebGenerator::generateDataTar() const std::string DebGenerator::generateMD5File() const { - std::string md5filename = WorkDir + "/md5sums"; + std::string md5filename = this->WorkDir + "/md5sums"; cmGeneratedFileStream out; out.Open(md5filename, false, true); - std::string topLevelWithTrailingSlash = cmStrCat(TemporaryDir, '/'); - for (std::string const& file : PackageFiles) { + std::string topLevelWithTrailingSlash = cmStrCat(this->TemporaryDir, '/'); + for (std::string const& file : this->PackageFiles) { // hash only regular files if (cmSystemTools::FileIsDirectory(file) || cmSystemTools::FileIsSymlink(file)) { @@ -281,7 +282,7 @@ std::string DebGenerator::generateMD5File() const bool DebGenerator::generateControlTar(std::string const& md5Filename) const { - std::string filename_control_tar = WorkDir + "/control.tar.gz"; + std::string filename_control_tar = this->WorkDir + "/control.tar.gz"; cmGeneratedFileStream fileStream_control_tar; fileStream_control_tar.Open(filename_control_tar, false, true); @@ -292,7 +293,8 @@ bool DebGenerator::generateControlTar(std::string const& md5Filename) const return false; } cmArchiveWrite control_tar(fileStream_control_tar, - cmArchiveWrite::CompressGZip, DebianArchiveType); + cmArchiveWrite::CompressGZip, + this->DebianArchiveType); control_tar.Open(); // sets permissions and uid/gid for the files @@ -314,24 +316,25 @@ bool DebGenerator::generateControlTar(std::string const& md5Filename) const control_tar.SetPermissions(permission644); // adds control and md5sums - if (!control_tar.Add(md5Filename, WorkDir.length(), ".") || - !control_tar.Add(WorkDir + "/control", WorkDir.length(), ".")) { + if (!control_tar.Add(md5Filename, this->WorkDir.length(), ".") || + !control_tar.Add(this->WorkDir + "/control", this->WorkDir.length(), + ".")) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:" << std::endl - << "#top level directory: " << WorkDir << std::endl + << "#top level directory: " << this->WorkDir << std::endl << "#file: \"control\" or \"md5sums\"" << std::endl << "#error:" << control_tar.GetError() << std::endl); return false; } // adds generated shlibs file - if (GenShLibs) { - if (!control_tar.Add(ShLibsFilename, WorkDir.length(), ".")) { + if (this->GenShLibs) { + if (!control_tar.Add(this->ShLibsFilename, this->WorkDir.length(), ".")) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:" << std::endl - << "#top level directory: " << WorkDir << std::endl + << "#top level directory: " << this->WorkDir << std::endl << "#file: \"shlibs\"" << std::endl << "#error:" << control_tar.GetError() << std::endl); return false; @@ -339,13 +342,13 @@ bool DebGenerator::generateControlTar(std::string const& md5Filename) const } // adds LDCONFIG related files - if (GenPostInst) { + if (this->GenPostInst) { control_tar.SetPermissions(permission755); - if (!control_tar.Add(PostInst, WorkDir.length(), ".")) { + if (!control_tar.Add(this->PostInst, this->WorkDir.length(), ".")) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:" << std::endl - << "#top level directory: " << WorkDir << std::endl + << "#top level directory: " << this->WorkDir << std::endl << "#file: \"postinst\"" << std::endl << "#error:" << control_tar.GetError() << std::endl); return false; @@ -353,13 +356,13 @@ bool DebGenerator::generateControlTar(std::string const& md5Filename) const control_tar.SetPermissions(permission644); } - if (GenPostRm) { + if (this->GenPostRm) { control_tar.SetPermissions(permission755); - if (!control_tar.Add(PostRm, WorkDir.length(), ".")) { + if (!control_tar.Add(this->PostRm, this->WorkDir.length(), ".")) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:" << std::endl - << "#top level directory: " << WorkDir << std::endl + << "#top level directory: " << this->WorkDir << std::endl << "#file: \"postinst\"" << std::endl << "#error:" << control_tar.GetError() << std::endl); return false; @@ -370,7 +373,7 @@ bool DebGenerator::generateControlTar(std::string const& md5Filename) const // for the other files, we use // -either the original permission on the files // -either a permission strictly defined by the Debian policies - if (ControlExtra) { + if (this->ControlExtra) { // permissions are now controlled by the original file permissions static const char* strictFiles[] = { "config", "postinst", "postrm", @@ -381,19 +384,20 @@ bool DebGenerator::generateControlTar(std::string const& md5Filename) const // default control_tar.ClearPermissions(); - std::vector<std::string> controlExtraList = cmExpandedList(ControlExtra); + std::vector<std::string> controlExtraList = + cmExpandedList(this->ControlExtra); for (std::string const& i : controlExtraList) { std::string filenamename = cmsys::SystemTools::GetFilenameName(i); - std::string localcopy = WorkDir + "/" + filenamename; + std::string localcopy = this->WorkDir + "/" + filenamename; - if (PermissionStrictPolicy) { + if (this->PermissionStrictPolicy) { control_tar.SetPermissions( setStrictFiles.count(filenamename) ? permission755 : permission644); } // if we can copy the file, it means it does exist, let's add it: if (cmsys::SystemTools::CopyFileIfDifferent(i, localcopy)) { - control_tar.Add(localcopy, WorkDir.length(), "."); + control_tar.Add(localcopy, this->WorkDir.length(), "."); } } } @@ -408,8 +412,8 @@ bool DebGenerator::generateDeb() const // difference is that debian uses the BSD ar style archive whereas most // Linux distro have a GNU ar. // See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=161593 for more info - std::string const outputPath = TopLevelDir + "/" + OutputName; - std::string const tlDir = WorkDir + "/"; + std::string const outputPath = this->TopLevelDir + "/" + this->OutputName; + std::string const tlDir = this->WorkDir + "/"; cmGeneratedFileStream debStream; debStream.Open(outputPath, false, true); cmArchiveWrite deb(debStream, cmArchiveWrite::CompressNone, "arbsd"); @@ -422,12 +426,13 @@ bool DebGenerator::generateDeb() const if (!deb.Add(tlDir + "debian-binary", tlDir.length()) || !deb.Add(tlDir + "control.tar.gz", tlDir.length()) || - !deb.Add(tlDir + "data.tar" + CompressionSuffix, tlDir.length())) { + !deb.Add(tlDir + "data.tar" + this->CompressionSuffix, tlDir.length())) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Error creating debian package:" << std::endl - << "#top level directory: " << TopLevelDir << std::endl - << "#file: " << OutputName << std::endl + << "#top level directory: " << this->TopLevelDir + << std::endl + << "#file: " << this->OutputName << std::endl << "#error:" << deb.GetError() << std::endl); return false; } @@ -455,7 +460,8 @@ int cmCPackDebGenerator::PackageOnePack(std::string const& initialTopLevel, int retval = 1; // Begin the archive for this pack std::string localToplevel(initialTopLevel); - std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel)); + std::string packageFileName( + cmSystemTools::GetParentDirectory(this->toplevel)); std::string outputFileName( std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) + "-" + packageName + this->GetOutputExtension()); @@ -495,17 +501,17 @@ int cmCPackDebGenerator::PackageOnePack(std::string const& initialTopLevel, << std::endl); return 0; } - packageFiles = gl.GetFiles(); + this->packageFiles = gl.GetFiles(); } - int res = createDeb(); + int res = this->createDeb(); if (res != 1) { retval = 0; } // add the generated package to package file names list packageFileName = cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), '/', this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME")); - packageFileNames.push_back(std::move(packageFileName)); + this->packageFileNames.push_back(std::move(packageFileName)); if (this->IsOn("GEN_CPACK_DEBIAN_DEBUGINFO_PACKAGE") && this->GetOption("GEN_DBGSYMDIR")) { @@ -521,9 +527,9 @@ int cmCPackDebGenerator::PackageOnePack(std::string const& initialTopLevel, << std::endl); return 0; } - packageFiles = gl.GetFiles(); + this->packageFiles = gl.GetFiles(); - res = createDbgsymDDeb(); + res = this->createDbgsymDDeb(); if (res != 1) { retval = 0; } @@ -531,7 +537,7 @@ int cmCPackDebGenerator::PackageOnePack(std::string const& initialTopLevel, packageFileName = cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), '/', this->GetOption("GEN_CPACK_DBGSYM_OUTPUT_FILE_NAME")); - packageFileNames.push_back(std::move(packageFileName)); + this->packageFileNames.push_back(std::move(packageFileName)); } return retval; @@ -542,7 +548,7 @@ int cmCPackDebGenerator::PackageComponents(bool ignoreGroup) int retval = 1; /* Reset package file name list it will be populated during the * component packaging run*/ - packageFileNames.clear(); + this->packageFileNames.clear(); std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY")); // The default behavior is to have one package by component group @@ -552,7 +558,7 @@ int cmCPackDebGenerator::PackageComponents(bool ignoreGroup) cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: " << compG.first << std::endl); // Begin the archive for this group - retval &= PackageOnePack(initialTopLevel, compG.first); + retval &= this->PackageOnePack(initialTopLevel, compG.first); } // Handle Orphan components (components not belonging to any groups) for (auto const& comp : this->Components) { @@ -565,7 +571,7 @@ int cmCPackDebGenerator::PackageComponents(bool ignoreGroup) << "> does not belong to any group, package it separately." << std::endl); // Begin the archive for this orphan component - retval &= PackageOnePack(initialTopLevel, comp.first); + retval &= this->PackageOnePack(initialTopLevel, comp.first); } } } @@ -573,7 +579,7 @@ int cmCPackDebGenerator::PackageComponents(bool ignoreGroup) // We build 1 package per component else { for (auto const& comp : this->Components) { - retval &= PackageOnePack(initialTopLevel, comp.first); + retval &= this->PackageOnePack(initialTopLevel, comp.first); } } return retval; @@ -586,7 +592,7 @@ int cmCPackDebGenerator::PackageComponentsAllInOne( int retval = 1; /* Reset package file name list it will be populated during the * component packaging run*/ - packageFileNames.clear(); + this->packageFileNames.clear(); std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY")); cmCPackLogger(cmCPackLog::LOG_VERBOSE, @@ -596,7 +602,8 @@ int cmCPackDebGenerator::PackageComponentsAllInOne( // The ALL GROUPS in ONE package case std::string localToplevel(initialTopLevel); - std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel)); + std::string packageFileName( + cmSystemTools::GetParentDirectory(this->toplevel)); std::string outputFileName( std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) + this->GetOutputExtension()); @@ -641,38 +648,38 @@ int cmCPackDebGenerator::PackageComponentsAllInOne( << std::endl); return 0; } - packageFiles = gl.GetFiles(); + this->packageFiles = gl.GetFiles(); - int res = createDeb(); + int res = this->createDeb(); if (res != 1) { retval = 0; } // add the generated package to package file names list packageFileName = cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), '/', this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME")); - packageFileNames.push_back(std::move(packageFileName)); + this->packageFileNames.push_back(std::move(packageFileName)); return retval; } int cmCPackDebGenerator::PackageFiles() { /* Are we in the component packaging case */ - if (WantsComponentInstallation()) { + if (this->WantsComponentInstallation()) { // CASE 1 : COMPONENT ALL-IN-ONE package // If ALL GROUPS or ALL COMPONENTS in ONE package has been requested // then the package file is unique and should be open here. - if (componentPackageMethod == ONE_PACKAGE) { - return PackageComponentsAllInOne("ALL_COMPONENTS_IN_ONE"); + if (this->componentPackageMethod == ONE_PACKAGE) { + return this->PackageComponentsAllInOne("ALL_COMPONENTS_IN_ONE"); } // CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one) // There will be 1 package for each component group // however one may require to ignore component group and // in this case you'll get 1 package for each component. - return PackageComponents(componentPackageMethod == - ONE_PACKAGE_PER_COMPONENT); + return this->PackageComponents(this->componentPackageMethod == + ONE_PACKAGE_PER_COMPONENT); } // CASE 3 : NON COMPONENT package. - return PackageComponentsAllInOne(""); + return this->PackageComponentsAllInOne(""); } int cmCPackDebGenerator::createDeb() @@ -787,7 +794,7 @@ int cmCPackDebGenerator::createDeb() } DebGenerator gen( - Logger, this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME"), strGenWDIR, + this->Logger, this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME"), strGenWDIR, this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), this->GetOption("CPACK_TEMPORARY_DIRECTORY"), this->GetOption("GEN_CPACK_DEBIAN_COMPRESSION_TYPE"), @@ -796,7 +803,7 @@ int cmCPackDebGenerator::createDeb() this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM"), postrm, this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA"), this->IsSet("GEN_CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION"), - packageFiles); + this->packageFiles); if (!gen.generate()) { return 0; @@ -842,7 +849,7 @@ int cmCPackDebGenerator::createDbgsymDDeb() } DebGenerator gen( - Logger, this->GetOption("GEN_CPACK_DBGSYM_OUTPUT_FILE_NAME"), + this->Logger, this->GetOption("GEN_CPACK_DBGSYM_OUTPUT_FILE_NAME"), this->GetOption("GEN_DBGSYMDIR"), this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), @@ -851,7 +858,7 @@ int cmCPackDebGenerator::createDbgsymDDeb() this->GetOption("GEN_CPACK_DEBIAN_ARCHIVE_TYPE"), controlValues, false, "", false, "", false, "", nullptr, this->IsSet("GEN_CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION"), - packageFiles); + this->packageFiles); if (!gen.generate()) { return 0; @@ -861,25 +868,25 @@ int cmCPackDebGenerator::createDbgsymDDeb() bool cmCPackDebGenerator::SupportsComponentInstallation() const { - return IsOn("CPACK_DEB_COMPONENT_INSTALL"); + return this->IsOn("CPACK_DEB_COMPONENT_INSTALL"); } std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix( const std::string& componentName) { - if (componentPackageMethod == ONE_PACKAGE_PER_COMPONENT) { + if (this->componentPackageMethod == ONE_PACKAGE_PER_COMPONENT) { return componentName; } - if (componentPackageMethod == ONE_PACKAGE) { + if (this->componentPackageMethod == ONE_PACKAGE) { return std::string("ALL_COMPONENTS_IN_ONE"); } // We have to find the name of the COMPONENT GROUP // the current COMPONENT belongs to. std::string groupVar = "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP"; - if (nullptr != GetOption(groupVar)) { - return std::string(GetOption(groupVar)); + if (nullptr != this->GetOption(groupVar)) { + return std::string(this->GetOption(groupVar)); } return componentName; } |