diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2021-10-08 09:13:24 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2021-10-08 09:13:24 +0900 |
commit | e42c4abb646a39cdd5d1ccb22a9619990ce2a898 (patch) | |
tree | 5c4a99e76409f26c9525137e845d0bac7efa8c7b /Source/CPack | |
parent | 07408dd83a3637a29a56a7d5fbe49f63cbb41e8f (diff) | |
download | cmake-e42c4abb646a39cdd5d1ccb22a9619990ce2a898.tar.gz cmake-e42c4abb646a39cdd5d1ccb22a9619990ce2a898.tar.bz2 cmake-e42c4abb646a39cdd5d1ccb22a9619990ce2a898.zip |
Imported Upstream version 3.12.0upstream/3.12.0
Diffstat (limited to 'Source/CPack')
27 files changed, 697 insertions, 371 deletions
diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index 9f1a15e25..cf8334aef 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -61,7 +61,8 @@ int cmCPackIFWGenerator::PackageFiles() ifwCmd += " --repository " + rd; } } else { - cmCPackIFWLogger(WARNING, "The \"CPACK_IFW_REPOSITORIES_DIRECTORIES\" " + cmCPackIFWLogger(WARNING, + "The \"CPACK_IFW_REPOSITORIES_DIRECTORIES\" " << "variable is set, but content will be skipped, " << "because this feature available only since " << "QtIFW 3.1. Please update your QtIFW instance." @@ -93,7 +94,8 @@ int cmCPackIFWGenerator::PackageFiles() ofs << "# Run command: " << ifwCmd << std::endl << "# Output:" << std::endl << output << std::endl; - cmCPackIFWLogger(ERROR, "Problem running IFW command: " + cmCPackIFWLogger(ERROR, + "Problem running IFW command: " << ifwCmd << std::endl << "Please check " << ifwTmpFile << " for errors" << std::endl); @@ -102,15 +104,16 @@ int cmCPackIFWGenerator::PackageFiles() if (!this->Repository.RepositoryUpdate.empty() && !this->Repository.PatchUpdatesXml()) { - cmCPackIFWLogger(WARNING, "Problem patch IFW \"Updates\" " + cmCPackIFWLogger(WARNING, + "Problem patch IFW \"Updates\" " << "file: " << this->toplevel + "/repository/Updates.xml" << std::endl); } - cmCPackIFWLogger(OUTPUT, "- repository: " << this->toplevel - << "/repository generated" - << std::endl); + cmCPackIFWLogger(OUTPUT, + "- repository: " << this->toplevel + << "/repository generated" << std::endl); } // Run binary creator @@ -145,7 +148,8 @@ int cmCPackIFWGenerator::PackageFiles() ifwCmd += " --repository " + rd; } } else { - cmCPackIFWLogger(WARNING, "The \"CPACK_IFW_REPOSITORIES_DIRECTORIES\" " + cmCPackIFWLogger(WARNING, + "The \"CPACK_IFW_REPOSITORIES_DIRECTORIES\" " << "variable is set, but content will be skipped, " << "because this feature available only since " << "QtIFW 3.1. Please update your QtIFW instance." @@ -203,7 +207,8 @@ int cmCPackIFWGenerator::PackageFiles() ofs << "# Run command: " << ifwCmd << std::endl << "# Output:" << std::endl << output << std::endl; - cmCPackIFWLogger(ERROR, "Problem running IFW command: " + cmCPackIFWLogger(ERROR, + "Problem running IFW command: " << ifwCmd << std::endl << "Please check " << ifwTmpFile << " for errors" << std::endl); @@ -257,8 +262,9 @@ int cmCPackIFWGenerator::InitializeInternal() } if (this->BinCreator.empty()) { - cmCPackIFWLogger(ERROR, "Cannot find QtIFW compiler \"binarycreator\": " - "likely it is not installed, or not in your PATH" + cmCPackIFWLogger(ERROR, + "Cannot find QtIFW compiler \"binarycreator\": " + "likely it is not installed, or not in your PATH" << std::endl); return 0; } @@ -415,7 +421,8 @@ cmCPackComponent* cmCPackIFWGenerator::GetComponent( } } else { this->Packages.erase(name); - cmCPackIFWLogger(ERROR, "Cannot configure package \"" + cmCPackIFWLogger(ERROR, + "Cannot configure package \"" << name << "\" for component \"" << component->Name << "\"" << std::endl); } @@ -450,7 +457,8 @@ cmCPackComponentGroup* cmCPackIFWGenerator::GetComponentGroup( this->BinaryPackages.insert(package); } else { this->Packages.erase(name); - cmCPackIFWLogger(ERROR, "Cannot configure package \"" + cmCPackIFWLogger(ERROR, + "Cannot configure package \"" << name << "\" for component group \"" << group->Name << "\"" << std::endl); } @@ -596,7 +604,8 @@ cmCPackIFWRepository* cmCPackIFWGenerator::GetRepository( } else { this->Repositories.erase(repositoryName); repository = nullptr; - cmCPackIFWLogger(WARNING, "Invalid repository \"" + cmCPackIFWLogger(WARNING, + "Invalid repository \"" << repositoryName << "\"" << " configuration. Repository will be skipped." << std::endl); diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.h b/Source/CPack/IFW/cmCPackIFWGenerator.h index 919dd4678..0430122c9 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.h +++ b/Source/CPack/IFW/cmCPackIFWGenerator.h @@ -22,7 +22,9 @@ * * http://qt-project.org/doc/qtinstallerframework/index.html */ -class cmCPackIFWGenerator : public cmCPackGenerator, public cmCPackIFWCommon +class cmCPackIFWGenerator + : public cmCPackGenerator + , public cmCPackIFWCommon { public: cmCPackTypeMacro(cmCPackIFWGenerator, cmCPackGenerator); diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx index 05a852d1d..36cf08cfc 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx +++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx @@ -24,7 +24,8 @@ void cmCPackIFWInstaller::printSkippedOptionWarning( const std::string& optionName, const std::string& optionValue) { cmCPackIFWLogger( - WARNING, "Option " + WARNING, + "Option " << optionName << " is set to \"" << optionValue << "\" but will be skipped because the specified file does not exist." << std::endl); @@ -146,7 +147,8 @@ void cmCPackIFWInstaller::ConfigureFromOptions() if (this->WizardStyle != "Modern" && this->WizardStyle != "Aero" && this->WizardStyle != "Mac" && this->WizardStyle != "Classic") { cmCPackIFWLogger( - WARNING, "Option CPACK_IFW_PACKAGE_WIZARD_STYLE has unknown value \"" + WARNING, + "Option CPACK_IFW_PACKAGE_WIZARD_STYLE has unknown value \"" << option << "\". Expected values are: Modern, Aero, Mac, Classic." << std::endl); } @@ -469,7 +471,8 @@ void cmCPackIFWInstaller::GenerateInstallerFile() cmsys::SystemTools::CopyFileIfDifferent(this->Resources[i], path); resources.push_back(std::move(name)); } else { - cmCPackIFWLogger(WARNING, "Can't copy resources from \"" + cmCPackIFWLogger(WARNING, + "Can't copy resources from \"" << this->Resources[i] << "\". Resource will be skipped." << std::endl); } diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx index d3ce15c86..f24ab6997 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.cxx +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -126,10 +126,10 @@ void cmCPackIFWPackage::DefaultConfiguration() this->RequiresAdminRights.clear(); } -// Defaul configuration (all in one package) +// Default configuration (all in one package) int cmCPackIFWPackage::ConfigureFromOptions() { - // Restore defaul configuration + // Restore default configuration this->DefaultConfiguration(); // Name @@ -168,7 +168,7 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component) return 0; } - // Restore defaul configuration + // Restore default configuration this->DefaultConfiguration(); std::string prefix = "CPACK_IFW_COMPONENT_" + @@ -226,7 +226,8 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component) if (const char* option = this->GetOption(prefix + "PRIORITY")) { this->SortingPriority = option; cmCPackIFWLogger( - WARNING, "The \"PRIORITY\" option is set " + WARNING, + "The \"PRIORITY\" option is set " << "for component \"" << component->Name << "\", but there option is " << "deprecated. Please use \"SORTING_PRIORITY\" option instead." << std::endl); @@ -255,7 +256,7 @@ int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group) return 0; } - // Restore defaul configuration + // Restore default configuration this->DefaultConfiguration(); std::string prefix = "CPACK_IFW_COMPONENT_GROUP_" + @@ -303,7 +304,8 @@ int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group) if (const char* option = this->GetOption(prefix + "PRIORITY")) { this->SortingPriority = option; cmCPackIFWLogger( - WARNING, "The \"PRIORITY\" option is set " + WARNING, + "The \"PRIORITY\" option is set " << "for component group \"" << group->Name << "\", but there option is " << "deprecated. Please use \"SORTING_PRIORITY\" option instead." diff --git a/Source/CPack/WiX/cmCMakeToWixPath.cxx b/Source/CPack/WiX/cmCMakeToWixPath.cxx index 0b0e42aa9..b3889cf2e 100644 --- a/Source/CPack/WiX/cmCMakeToWixPath.cxx +++ b/Source/CPack/WiX/cmCMakeToWixPath.cxx @@ -8,7 +8,7 @@ #include <vector> #ifdef __CYGWIN__ -#include <sys/cygwin.h> +# include <sys/cygwin.h> std::string CMakeToWixPath(const std::string& cygpath) { std::vector<char> winpath_chars; diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index a0bc0eabd..e06efdafd 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -23,9 +23,9 @@ #include "cmsys/SystemTools.hxx" #ifdef _WIN32 -#include <rpc.h> // for GUID generation (windows only) +# include <rpc.h> // for GUID generation (windows only) #else -#include <uuid/uuid.h> // for GUID generation (libuuid) +# include <uuid/uuid.h> // for GUID generation (libuuid) #endif #include "cmCMakeToWixPath.h" @@ -55,8 +55,8 @@ bool cmCPackWIXGenerator::RunWiXCommand(std::string const& command) { std::string logFileName = this->CPackTopLevel + "/wix.log"; - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Running WiX command: " << command - << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "Running WiX command: " << command << std::endl); std::string output; @@ -71,8 +71,9 @@ bool cmCPackWIXGenerator::RunWiXCommand(std::string const& command) logFile.close(); if (!status || returnValue) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running WiX candle. " - "Please check '" + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem running WiX candle. " + "Please check '" << logFileName << "' for errors." << std::endl); return false; @@ -137,8 +138,8 @@ bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles) int cmCPackWIXGenerator::PackageFiles() { if (!PackageFilesImpl() || cmSystemTools::GetErrorOccuredFlag()) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Fatal WiX Generator Error" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Fatal WiX Generator Error" << std::endl); return false; } @@ -148,8 +149,8 @@ int cmCPackWIXGenerator::PackageFiles() bool cmCPackWIXGenerator::InitializeWiXConfiguration() { if (!ReadListFile("CPackWIX.cmake")) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while executing CPackWIX.cmake" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error while executing CPackWIX.cmake" << std::endl); return false; } @@ -166,12 +167,13 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration() std::string guid = GenerateGUID(); SetOption("CPACK_WIX_UPGRADE_GUID", guid.c_str()); - cmCPackLogger( - cmCPackLog::LOG_WARNING, "CPACK_WIX_UPGRADE_GUID implicitly set to " - << guid << " . " - "Please refer to the documentation on how and why " - "you might want to set this explicitly." - << std::endl); + cmCPackLogger(cmCPackLog::LOG_WARNING, + "CPACK_WIX_UPGRADE_GUID implicitly set to " + << guid + << " . " + "Please refer to the documentation on how and why " + "you might want to set this explicitly." + << std::endl); } if (!RequireOption("CPACK_TOPLEVEL_DIRECTORY", this->CPackTopLevel)) { @@ -370,8 +372,9 @@ void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile() includeFile.AddAttribute("Id", "FindInstallLocation"); includeFile.AddAttribute("Root", "HKLM"); includeFile.AddAttribute( - "Key", "Software\\Microsoft\\Windows\\" - "CurrentVersion\\Uninstall\\[WIX_UPGRADE_DETECTED]"); + "Key", + "Software\\Microsoft\\Windows\\" + "CurrentVersion\\Uninstall\\[WIX_UPGRADE_DETECTED]"); includeFile.AddAttribute("Name", "InstallLocation"); includeFile.AddAttribute("Type", "raw"); includeFile.EndElement("RegistrySearch"); @@ -613,8 +616,9 @@ bool cmCPackWIXGenerator::GenerateMainSourceFileFromTemplate() std::string mainSourceFilePath = this->CPackTopLevel + "/main.wxs"; if (!ConfigureFile(wixTemplate.c_str(), mainSourceFilePath.c_str())) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Failed creating '" - << mainSourceFilePath << "'' from template." << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Failed creating '" << mainSourceFilePath + << "'' from template." << std::endl); return false; } @@ -957,8 +961,8 @@ bool cmCPackWIXGenerator::RequireOption(std::string const& name, return true; } else { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Required variable " - << name << " not set" << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Required variable " << name << " not set" << std::endl); return false; } diff --git a/Source/CPack/WiX/cmWIXAccessControlList.cxx b/Source/CPack/WiX/cmWIXAccessControlList.cxx index 1603bf868..563de02ae 100644 --- a/Source/CPack/WiX/cmWIXAccessControlList.cxx +++ b/Source/CPack/WiX/cmWIXAccessControlList.cxx @@ -66,8 +66,9 @@ void cmWIXAccessControlList::CreatePermissionElement(std::string const& entry) void cmWIXAccessControlList::ReportError(std::string const& entry, std::string const& message) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Failed processing ACL entry '" - << entry << "': " << message << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Failed processing ACL entry '" << entry << "': " << message + << std::endl); } bool cmWIXAccessControlList::IsBooleanAttribute(std::string const& name) diff --git a/Source/CPack/WiX/cmWIXPatch.cxx b/Source/CPack/WiX/cmWIXPatch.cxx index dec95fb6e..ca232f94b 100644 --- a/Source/CPack/WiX/cmWIXPatch.cxx +++ b/Source/CPack/WiX/cmWIXPatch.cxx @@ -13,8 +13,9 @@ bool cmWIXPatch::LoadFragments(std::string const& patchFilePath) { cmWIXPatchParser parser(Fragments, Logger); if (!parser.ParseFile(patchFilePath.c_str())) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Failed parsing XML patch file: '" - << patchFilePath << "'" << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Failed parsing XML patch file: '" << patchFilePath << "'" + << std::endl); return false; } diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx index dc730e00c..6adf80bac 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx @@ -32,7 +32,8 @@ cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger, cmWIXSourceWriter::~cmWIXSourceWriter() { if (Elements.size() > 1) { - cmCPackLogger(cmCPackLog::LOG_ERROR, Elements.size() - 1 + cmCPackLogger(cmCPackLog::LOG_ERROR, + Elements.size() - 1 << " WiX elements were still open when closing '" << SourceFilename << "'" << std::endl); return; @@ -65,7 +66,8 @@ void cmWIXSourceWriter::EndElement(std::string const& name) } if (Elements.back() != name) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "WiX element <" + cmCPackLogger(cmCPackLog::LOG_ERROR, + "WiX element <" << Elements.back() << "> can not be closed by </" << name << "> in '" << SourceFilename << "'" << std::endl); return; diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index 9ff547a49..b734bb460 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -9,6 +9,7 @@ #include "cmSystemTools.h" #include "cmWorkingDirectory.h" +#include <cstring> #include <ostream> #include <utility> #include <vector> @@ -51,6 +52,7 @@ int cmCPackArchiveGenerator::InitializeInternal() this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "1"); return this->Superclass::InitializeInternal(); } + int cmCPackArchiveGenerator::addOneComponentToArchive( cmArchiveWrite& archive, cmCPackComponent* component) { @@ -61,6 +63,13 @@ int cmCPackArchiveGenerator::addOneComponentToArchive( localToplevel += "/" + component->Name; // Change to local toplevel cmWorkingDirectory workdir(localToplevel); + if (workdir.Failed()) { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Failed to change working directory to " + << localToplevel << " : " + << std::strerror(workdir.GetLastResult()) << std::endl); + return 0; + } std::string filePrefix; if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) { filePrefix = this->GetOption("CPACK_PACKAGE_FILE_NAME"); @@ -78,8 +87,9 @@ int cmCPackArchiveGenerator::addOneComponentToArchive( cmCPackLogger(cmCPackLog::LOG_DEBUG, "Adding file: " << rp << std::endl); archive.Add(rp, 0, nullptr, false); if (!archive) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "ERROR while packaging files: " - << archive.GetError() << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "ERROR while packaging files: " << archive.GetError() + << std::endl); return 0; } } @@ -102,7 +112,8 @@ int cmCPackArchiveGenerator::addOneComponentToArchive( } \ cmArchiveWrite archive(gf, this->Compress, this->ArchiveFormat); \ if (!(archive)) { \ - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem to create archive < " \ + cmCPackLogger(cmCPackLog::LOG_ERROR, \ + "Problem to create archive < " \ << (filename) << ">. ERROR =" << (archive).GetError() \ << std::endl); \ return 0; \ @@ -139,7 +150,8 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup) // Does the component belong to a group? if (comp.second.Group == nullptr) { cmCPackLogger( - cmCPackLog::LOG_VERBOSE, "Component <" + cmCPackLog::LOG_VERBOSE, + "Component <" << comp.second.Name << "> does not belong to any group, package it separately." << std::endl); @@ -237,12 +249,20 @@ int cmCPackArchiveGenerator::PackageFiles() // CASE 3 : NON COMPONENT package. DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0], archive); cmWorkingDirectory workdir(toplevel); + if (workdir.Failed()) { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Failed to change working directory to " + << toplevel << " : " + << std::strerror(workdir.GetLastResult()) << std::endl); + return 0; + } for (std::string const& file : files) { // Get the relative path to the file std::string rp = cmSystemTools::RelativePath(toplevel, file); archive.Add(rp, 0, nullptr, false); if (!archive) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem while adding file< " + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem while adding file< " << file << "> to archive <" << packageFileNames[0] << "> .ERROR =" << archive.GetError() << std::endl); return 0; diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx index f47ca7a74..f8fd108d3 100644 --- a/Source/CPack/cmCPackBundleGenerator.cxx +++ b/Source/CPack/cmCPackBundleGenerator.cxx @@ -32,8 +32,8 @@ int cmCPackBundleGenerator::InitializeInternal() "codesign", std::vector<std::string>(), false); if (codesign_path.empty()) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate codesign command" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot locate codesign command" << std::endl); return 0; } this->SetOptionIfNotSet("CPACK_COMMAND_CODESIGN", codesign_path.c_str()); @@ -59,8 +59,8 @@ int cmCPackBundleGenerator::ConstructBundle() ? this->GetOption("CPACK_BUNDLE_NAME") : ""; if (cpack_bundle_name.empty()) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_BUNDLE_NAME must be set." - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "CPACK_BUNDLE_NAME must be set." << std::endl); return 0; } @@ -69,8 +69,8 @@ int cmCPackBundleGenerator::ConstructBundle() ? this->GetOption("CPACK_BUNDLE_PLIST") : ""; if (cpack_bundle_plist.empty()) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_BUNDLE_PLIST must be set." - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "CPACK_BUNDLE_PLIST must be set." << std::endl); return 0; } @@ -79,8 +79,8 @@ int cmCPackBundleGenerator::ConstructBundle() ? this->GetOption("CPACK_BUNDLE_ICON") : ""; if (cpack_bundle_icon.empty()) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_BUNDLE_ICON must be set." - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "CPACK_BUNDLE_ICON must be set." << std::endl); return 0; } @@ -269,8 +269,8 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir) return 0; } - cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Application has been codesigned" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_OUTPUT, + "- Application has been codesigned" << std::endl); cmCPackLogger(cmCPackLog::LOG_VERBOSE, (this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS") ? "with entitlement sandboxing" diff --git a/Source/CPack/cmCPackCygwinSourceGenerator.cxx b/Source/CPack/cmCPackCygwinSourceGenerator.cxx index 2c289f668..889f29a59 100644 --- a/Source/CPack/cmCPackCygwinSourceGenerator.cxx +++ b/Source/CPack/cmCPackCygwinSourceGenerator.cxx @@ -15,8 +15,8 @@ // system tools because it is not implemented robustly enough to move // files across directories. #ifdef _WIN32 -#include "cm_sys_stat.h" -#include <windows.h> +# include "cm_sys_stat.h" +# include <windows.h> #endif cmCPackCygwinSourceGenerator::cmCPackCygwinSourceGenerator() @@ -73,7 +73,8 @@ int cmCPackCygwinSourceGenerator::PackageFiles() if (!cmSystemTools::CopyFileAlways( this->GetOption("CPACK_CYGWIN_PATCH_FILE"), this->GetOption("CPACK_TOPLEVEL_DIRECTORY"))) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "problem copying: [" + cmCPackLogger(cmCPackLog::LOG_ERROR, + "problem copying: [" << this->GetOption("CPACK_CYGWIN_PATCH_FILE") << "]\nto\n[" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n"); return 0; @@ -87,7 +88,8 @@ int cmCPackCygwinSourceGenerator::PackageFiles() if (!cmSystemTools::CopyFileAlways( this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"), this->GetOption("CPACK_TOPLEVEL_DIRECTORY"))) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "problem copying: " + cmCPackLogger(cmCPackLog::LOG_ERROR, + "problem copying: " << this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT") << "\nto\n" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n"); return 0; @@ -96,7 +98,8 @@ int cmCPackCygwinSourceGenerator::PackageFiles() outerTarFile += "-"; const char* patch = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER"); if (!patch) { - cmCPackLogger(cmCPackLog::LOG_WARNING, "CPACK_CYGWIN_PATCH_NUMBER" + cmCPackLogger(cmCPackLog::LOG_WARNING, + "CPACK_CYGWIN_PATCH_NUMBER" << " not specified, defaulting to 1\n"); patch = "1"; } @@ -147,7 +150,8 @@ const char* cmCPackCygwinSourceGenerator::GetOutputExtension() this->OutputExtension = "-"; const char* patch = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER"); if (!patch) { - cmCPackLogger(cmCPackLog::LOG_WARNING, "CPACK_CYGWIN_PATCH_NUMBER" + cmCPackLogger(cmCPackLog::LOG_WARNING, + "CPACK_CYGWIN_PATCH_NUMBER" << " not specified, defaulting to 1\n"); patch = "1"; } diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 8ec54f88e..8a4c00427 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -62,8 +62,8 @@ int cmCPackDebGenerator::PackageOnePack(std::string const& initialTopLevel, this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH", component_path.c_str()); if (!this->ReadListFile("CPackDeb.cmake")) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackDeb.cmake" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error while execution CPackDeb.cmake" << std::endl); retval = 0; return retval; } @@ -115,7 +115,8 @@ int cmCPackDebGenerator::PackageComponents(bool ignoreGroup) // Does the component belong to a group? if (comp.second.Group == nullptr) { cmCPackLogger( - cmCPackLog::LOG_VERBOSE, "Component <" + cmCPackLog::LOG_VERBOSE, + "Component <" << comp.second.Name << "> does not belong to any group, package it separately." << std::endl); @@ -179,8 +180,8 @@ int cmCPackDebGenerator::PackageComponentsAllInOne( component_path.c_str()); } if (!this->ReadListFile("CPackDeb.cmake")) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackDeb.cmake" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error while execution CPackDeb.cmake" << std::endl); retval = 0; return retval; } @@ -413,7 +414,8 @@ int cmCPackDebGenerator::createDeb() cmGeneratedFileStream fileStream_data_tar; fileStream_data_tar.Open(filename_data_tar.c_str(), false, true); if (!fileStream_data_tar) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Error opening the file \"" + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error opening the file \"" << filename_data_tar << "\" for writing" << std::endl); return 0; } @@ -430,9 +432,9 @@ int cmCPackDebGenerator::createDeb() // e.g. /opt/bin/foo, /usr/bin/bar and /usr/bin/baz would // give /usr and /opt size_t topLevelLength = strGenWDIR.length(); - cmCPackLogger(cmCPackLog::LOG_DEBUG, "WDIR: \"" - << strGenWDIR << "\", length = " << topLevelLength - << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "WDIR: \"" << strGenWDIR << "\", length = " << topLevelLength + << std::endl); std::set<std::string> orderedFiles; // we have to reconstruct the parent folders as well @@ -448,13 +450,13 @@ int cmCPackDebGenerator::createDeb() } for (std::string const& file : orderedFiles) { - cmCPackLogger(cmCPackLog::LOG_DEBUG, "FILEIT: \"" << file << "\"" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "FILEIT: \"" << file << "\"" << std::endl); std::string::size_type slashPos = file.find('/', topLevelLength + 1); std::string relativeDir = file.substr(topLevelLength, slashPos - topLevelLength); - cmCPackLogger(cmCPackLog::LOG_DEBUG, "RELATIVEDIR: \"" - << relativeDir << "\"" << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "RELATIVEDIR: \"" << relativeDir << "\"" << std::endl); #ifdef WIN32 std::string mode_t_adt_filename = file + ":cmake_mode_t"; @@ -477,7 +479,8 @@ int cmCPackDebGenerator::createDeb() // do not recurse because the loop will do it if (!data_tar.Add(file, topLevelLength, ".", false)) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem adding file to tar:" + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem adding file to tar:" << std::endl << "#top level directory: " << strGenWDIR << std::endl << "#file: " << file << std::endl @@ -505,8 +508,8 @@ int cmCPackDebGenerator::createDeb() std::string output = cmSystemTools::ComputeFileHash(file, cmCryptoHash::AlgoMD5); if (output.empty()) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem computing the md5 of " - << file << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem computing the md5 of " << file << std::endl); } output += " " + file + "\n"; @@ -527,9 +530,10 @@ int cmCPackDebGenerator::createDeb() cmGeneratedFileStream fileStream_control_tar; fileStream_control_tar.Open(filename_control_tar.c_str(), false, true); if (!fileStream_control_tar) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Error opening the file \"" - << filename_control_tar << "\" for writing" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error opening the file \"" << filename_control_tar + << "\" for writing" + << std::endl); return 0; } cmArchiveWrite control_tar(fileStream_control_tar, @@ -557,7 +561,8 @@ int cmCPackDebGenerator::createDeb() // adds control and md5sums if (!control_tar.Add(md5filename, strGenWDIR.length(), ".") || !control_tar.Add(strGenWDIR + "/control", strGenWDIR.length(), ".")) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:" + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error adding file to tar:" << std::endl << "#top level directory: " << strGenWDIR << std::endl << "#file: \"control\" or \"md5sums\"" << std::endl @@ -568,7 +573,8 @@ int cmCPackDebGenerator::createDeb() // adds generated shlibs file if (gen_shibs) { if (!control_tar.Add(shlibsfilename, strGenWDIR.length(), ".")) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:" + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error adding file to tar:" << std::endl << "#top level directory: " << strGenWDIR << std::endl << "#file: \"shlibs\"" << std::endl @@ -581,7 +587,8 @@ int cmCPackDebGenerator::createDeb() if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST")) { control_tar.SetPermissions(permission755); if (!control_tar.Add(postinst, strGenWDIR.length(), ".")) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:" + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error adding file to tar:" << std::endl << "#top level directory: " << strGenWDIR << std::endl << "#file: \"postinst\"" << std::endl @@ -594,7 +601,8 @@ int cmCPackDebGenerator::createDeb() if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM")) { control_tar.SetPermissions(permission755); if (!control_tar.Add(postrm, strGenWDIR.length(), ".")) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:" + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error adding file to tar:" << std::endl << "#top level directory: " << strGenWDIR << std::endl << "#file: \"postinst\"" << std::endl @@ -656,10 +664,17 @@ int cmCPackDebGenerator::createDeb() cmGeneratedFileStream debStream; debStream.Open(outputPath.c_str(), false, true); cmArchiveWrite deb(debStream, cmArchiveWrite::CompressNone, "arbsd"); + + // uid/gid should be the one of the root user, and this root user has + // always uid/gid equal to 0. + deb.SetUIDAndGID(0u, 0u); + deb.SetUNAMEAndGNAME("root", "root"); + if (!deb.Add(tlDir + "debian-binary", tlDir.length()) || !deb.Add(tlDir + "control.tar.gz", tlDir.length()) || !deb.Add(tlDir + "data.tar" + compression_suffix, tlDir.length())) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Error creating debian package:" + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error creating debian package:" << std::endl << "#top level directory: " << outputDir << std::endl << "#file: " << outputName << std::endl diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index e95b96dfe..561652305 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -21,7 +21,7 @@ // For the old LocaleStringToLangAndRegionCodes() function, to convert // to the old Script Manager RegionCode values needed for the 'LPic' data // structure used for generating multi-lingual SLAs. -#include <CoreServices/CoreServices.h> +# include <CoreServices/CoreServices.h> #endif static const char* SLAHeader = @@ -77,8 +77,8 @@ int cmCPackDragNDropGenerator::InitializeInternal() const std::string hdiutil_path = cmSystemTools::FindProgram("hdiutil", std::vector<std::string>(), false); if (hdiutil_path.empty()) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate hdiutil command" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot locate hdiutil command" << std::endl); return 0; } this->SetOptionIfNotSet("CPACK_COMMAND_HDIUTIL", hdiutil_path.c_str()); @@ -86,16 +86,16 @@ int cmCPackDragNDropGenerator::InitializeInternal() const std::string setfile_path = cmSystemTools::FindProgram("SetFile", paths, false); if (setfile_path.empty()) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate SetFile command" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot locate SetFile command" << std::endl); return 0; } this->SetOptionIfNotSet("CPACK_COMMAND_SETFILE", setfile_path.c_str()); const std::string rez_path = cmSystemTools::FindProgram("Rez", paths, false); if (rez_path.empty()) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate Rez command" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot locate Rez command" << std::endl); return 0; } this->SetOptionIfNotSet("CPACK_COMMAND_REZ", rez_path.c_str()); @@ -124,8 +124,8 @@ int cmCPackDragNDropGenerator::InitializeInternal() return 0; } if (!cmSystemTools::FileExists(slaDirectory, false)) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_DMG_SLA_DIR does not exist" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "CPACK_DMG_SLA_DIR does not exist" << std::endl); return 0; } @@ -140,14 +140,16 @@ int cmCPackDragNDropGenerator::InitializeInternal() for (auto const& language : languages) { std::string license = slaDirectory + "/" + language + ".license.txt"; if (!singleLicense && !cmSystemTools::FileExists(license)) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Missing license file " - << language << ".license.txt" << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Missing license file " << language << ".license.txt" + << std::endl); return 0; } std::string menu = slaDirectory + "/" + language + ".menu.txt"; if (!cmSystemTools::FileExists(menu)) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Missing menu file " - << language << ".menu.txt" << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Missing menu file " << language << ".menu.txt" + << std::endl); return 0; } } @@ -212,8 +214,9 @@ bool cmCPackDragNDropGenerator::CopyFile(std::ostringstream& source, { if (!cmSystemTools::CopyFileIfDifferent(source.str().c_str(), target.str().c_str())) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Error copying " - << source.str() << " to " << target.str() << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error copying " << source.str() << " to " << target.str() + << std::endl); return false; } @@ -248,8 +251,8 @@ bool cmCPackDragNDropGenerator::RunCommand(std::ostringstream& command, this->GeneratorVerbose, cmDuration::zero()); if (!result || exit_code) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Error executing: " << command.str() - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error executing: " << command.str() << std::endl); return false; } @@ -400,8 +403,8 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, std::ostringstream dummy_padding; dummy_padding << staging.str() << "/.dummy-padding-file"; if (!this->CreateEmptyFile(dummy_padding, 1048576)) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Error creating dummy padding file." - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error creating dummy padding file." << std::endl); return 0; } @@ -460,8 +463,8 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, std::ostringstream dummy_padding; dummy_padding << temp_mount << "/.dummy-padding-file"; if (!cmSystemTools::RemoveFile(dummy_padding.str())) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Error removing dummy padding file." - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error removing dummy padding file." << std::endl); had_error = true; } @@ -565,8 +568,9 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, CFLocaleCreateCanonicalLanguageIdentifierFromString( nullptr, language_cfstring); if (!iso_language) { - cmCPackLogger(cmCPackLog::LOG_ERROR, languages[i] - << " is not a recognized language" << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + languages[i] << " is not a recognized language" + << std::endl); } char iso_language_cstr[65]; CFStringGetCString(iso_language, iso_language_cstr, @@ -638,9 +642,10 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, ofs.Close(); if (have_write_license_error) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Error writing license file to SLA." - << std::endl - << error << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error writing license file to SLA." << std::endl + << error + << std::endl); return 0; } @@ -692,9 +697,9 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, embed_sla_command << "\"" << temp_image << "\""; if (!this->RunCommand(embed_sla_command, &error)) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding SLA." << std::endl - << error - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error adding SLA." << std::endl + << error << std::endl); return 0; } @@ -726,9 +731,10 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, std::string convert_error; if (!this->RunCommand(final_image_command, &convert_error)) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Error compressing disk image." - << std::endl - << convert_error << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error compressing disk image." << std::endl + << convert_error + << std::endl); return 0; } diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index d838b301f..f15445b1a 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -6,6 +6,7 @@ #include "cmsys/Glob.hxx" #include "cmsys/RegularExpression.hxx" #include <algorithm> +#include <cstring> #include <memory> // IWYU pragma: keep #include <utility> @@ -24,8 +25,8 @@ #include "cmake.h" #if defined(__HAIKU__) -#include <FindDirectory.h> -#include <StorageDefs.h> +# include <FindDirectory.h> +# include <StorageDefs.h> #endif cmCPackGenerator::cmCPackGenerator() @@ -60,9 +61,10 @@ int cmCPackGenerator::PrepareNames() // checks CPACK_SET_DESTDIR support if (IsOn("CPACK_SET_DESTDIR")) { if (SETDESTDIR_UNSUPPORTED == SupportsSetDestdir()) { - cmCPackLogger( - cmCPackLog::LOG_ERROR, "CPACK_SET_DESTDIR is set to ON but the '" - << Name << "' generator does NOT support it." << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "CPACK_SET_DESTDIR is set to ON but the '" + << Name << "' generator does NOT support it." + << std::endl); return 0; } if (SETDESTDIR_SHOULD_NOT_BE_USED == SupportsSetDestdir()) { @@ -91,8 +93,8 @@ int cmCPackGenerator::PrepareNames() std::string outName = pfname; tempDirectory += "/" + outName; if (!this->GetOutputExtension()) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "No output extension specified" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "No output extension specified" << std::endl); return 0; } outName += this->GetOutputExtension(); @@ -124,8 +126,8 @@ int cmCPackGenerator::PrepareNames() "Look for: CPACK_PACKAGE_DESCRIPTION_FILE" << std::endl); const char* descFileName = this->GetOption("CPACK_PACKAGE_DESCRIPTION_FILE"); if (descFileName) { - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for: " << descFileName - << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "Look for: " << descFileName << std::endl); if (!cmSystemTools::FileExists(descFileName)) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find description file name: [" @@ -160,8 +162,9 @@ int cmCPackGenerator::PrepareNames() const char* algoSignature = this->GetOption("CPACK_PACKAGE_CHECKSUM"); if (algoSignature) { if (!cmCryptoHash::New(algoSignature)) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot recognize algorithm: " - << algoSignature << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot recognize algorithm: " << algoSignature + << std::endl); return 0; } } @@ -214,7 +217,8 @@ int cmCPackGenerator::InstallProject() cmSystemTools::ExpandListArgument(default_dir_install_permissions, items); for (const auto& arg : items) { if (!cmFSPermissions::stringToModeT(arg, default_dir_mode_v)) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Invalid permission value '" + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Invalid permission value '" << arg << "'." " CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS " @@ -288,10 +292,11 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( ofs << "# Run command: " << ic << std::endl << "# Output:" << std::endl << output << std::endl; - cmCPackLogger( - cmCPackLog::LOG_ERROR, "Problem running install command: " - << ic << std::endl - << "Please check " << tmpFile << " for errors" << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem running install command: " + << ic << std::endl + << "Please check " << tmpFile << " for errors" + << std::endl); return 0; } } @@ -375,8 +380,9 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( } std::string filePath = tempDir; filePath += "/" + subdir + "/" + cmSystemTools::RelativePath(top, gf); - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: " - << inFile << " -> " << filePath << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "Copy file: " << inFile << " -> " << filePath + << std::endl); /* If the file is a symlink we will have to re-create it */ if (cmSystemTools::FileIsSymlink(inFile)) { std::string targetFile; @@ -391,8 +397,9 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( filePath.c_str()) && cmSystemTools::CopyFileTime(inFile.c_str(), filePath.c_str()))) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying file: " - << inFile << " -> " << filePath << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem copying file: " << inFile << " -> " + << filePath << std::endl); return 0; } } @@ -401,33 +408,44 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( std::string curDir = cmSystemTools::GetCurrentWorkingDirectory(); std::string goToDir = tempDir; goToDir += "/" + subdir; - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Change dir to: " << goToDir - << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "Change dir to: " << goToDir << std::endl); cmWorkingDirectory workdir(goToDir); - for (auto const& symlinked : symlinkedFiles) { - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Will create a symlink: " - << symlinked.second << "--> " << symlinked.first + if (workdir.Failed()) { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Failed to change working directory to " + << goToDir << " : " + << std::strerror(workdir.GetLastResult()) << std::endl); + return 0; + } + for (auto const& symlinked : symlinkedFiles) { + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "Will create a symlink: " << symlinked.second << "--> " + << symlinked.first + << std::endl); // make sure directory exists for symlink std::string destDir = cmSystemTools::GetFilenamePath(symlinked.second); if (!destDir.empty() && !cmSystemTools::MakeDirectory(destDir, default_dir_mode)) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create dir: " + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot create dir: " << destDir << "\nTrying to create symlink: " << symlinked.second << "--> " << symlinked.first << std::endl); } if (!cmSystemTools::CreateSymlink(symlinked.first, symlinked.second)) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create symlink: " + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot create symlink: " << symlinked.second << "--> " << symlinked.first << std::endl); return 0; } } - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Going back to: " << curDir - << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "Going back to: " << curDir << std::endl); } } } @@ -439,8 +457,8 @@ int cmCPackGenerator::InstallProjectViaInstallScript( { const char* cmakeScripts = this->GetOption("CPACK_INSTALL_SCRIPT"); if (cmakeScripts && *cmakeScripts) { - cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Install scripts: " << cmakeScripts - << std::endl); + cmCPackLogger(cmCPackLog::LOG_OUTPUT, + "- Install scripts: " << cmakeScripts << std::endl); std::vector<std::string> cmakeScriptsVector; cmSystemTools::ExpandListArgument(cmakeScripts, cmakeScriptsVector); for (std::string const& installScript : cmakeScriptsVector) { @@ -595,8 +613,9 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( preinstall, buildConfig, "", false); cmCPackLogger(cmCPackLog::LOG_DEBUG, "- Install command: " << buildCommand << std::endl); - cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Run preinstall target for: " - << installProjectName << std::endl); + cmCPackLogger(cmCPackLog::LOG_OUTPUT, + "- Run preinstall target for: " << installProjectName + << std::endl); std::string output; int retVal = 1; bool resB = cmSystemTools::RunSingleCommand( @@ -611,10 +630,11 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( << "# Directory: " << installDirectory << std::endl << "# Output:" << std::endl << output << std::endl; - cmCPackLogger( - cmCPackLog::LOG_ERROR, "Problem running install command: " - << buildCommand << std::endl - << "Please check " << tmpFile << " for errors" << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem running install command: " + << buildCommand << std::endl + << "Please check " << tmpFile << " for errors" + << std::endl); return 0; } } @@ -628,8 +648,9 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( std::string tempInstallDirectory = baseTempInstallDirectory; installComponent = component; if (componentInstall) { - cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Install component: " - << installComponent << std::endl); + cmCPackLogger(cmCPackLog::LOG_OUTPUT, + "- Install component: " << installComponent + << std::endl); } cmake cm(cmake::RoleScript); @@ -725,8 +746,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( */ cmSystemTools::PutEnv(std::string("DESTDIR=") + tempInstallDirectory); - cmCPackLogger(cmCPackLog::LOG_DEBUG, "- Creating directory: '" - << dir << "'" << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "- Creating directory: '" << dir << "'" << std::endl); if (!cmsys::SystemTools::MakeDirectory(dir, default_dir_mode)) { cmCPackLogger( @@ -832,7 +853,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( localFileName = localFileName.substr(localFileName.find_first_not_of('/')); Components[installComponent].Files.push_back(localFileName); - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Adding file <" + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "Adding file <" << localFileName << "> to component <" << installComponent << ">" << std::endl); } @@ -904,16 +926,16 @@ void cmCPackGenerator::SetOption(const std::string& op, const char* value) this->MakefileMap->RemoveDefinition(op); return; } - cmCPackLogger(cmCPackLog::LOG_DEBUG, this->GetNameOfClass() - << "::SetOption(" << op << ", " << value << ")" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + this->GetNameOfClass() << "::SetOption(" << op << ", " << value + << ")" << std::endl); this->MakefileMap->AddDefinition(op, value); } int cmCPackGenerator::DoPackage() { - cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Create package using " << this->Name - << std::endl); + cmCPackLogger(cmCPackLog::LOG_OUTPUT, + "Create package using " << this->Name << std::endl); // Prepare CPack internal name and check // values for many CPACK_xxx vars @@ -931,8 +953,9 @@ int cmCPackGenerator::DoPackage() const char* toplevelDirectory = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); if (cmSystemTools::FileExists(toplevelDirectory)) { - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Remove toplevel directory: " - << toplevelDirectory << std::endl); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Remove toplevel directory: " << toplevelDirectory + << std::endl); if (!cmSystemTools::RepeatedRemoveDirectory(toplevelDirectory)) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem removing toplevel directory: " @@ -941,8 +964,8 @@ int cmCPackGenerator::DoPackage() } } } - cmCPackLogger(cmCPackLog::LOG_DEBUG, "About to install project " - << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "About to install project " << std::endl); if (!this->InstallProject()) { return 0; @@ -967,12 +990,13 @@ int cmCPackGenerator::DoPackage() } cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Create package" << std::endl); - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Package files to: " + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Package files to: " << (tempPackageFileName ? tempPackageFileName : "(NULL)") << std::endl); if (cmSystemTools::FileExists(tempPackageFileName)) { - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Remove old package file" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Remove old package file" << std::endl); cmSystemTools::RemoveFile(tempPackageFileName); } if (cmSystemTools::IsOn( @@ -994,11 +1018,12 @@ int cmCPackGenerator::DoPackage() { // scope that enables package generators to run internal scripts with // latest CMake policies enabled cmMakefile::ScopePushPop pp{ this->MakefileMap }; - this->MakefileMap->SetPolicyVersion(cmVersion::GetCMakeVersion()); + this->MakefileMap->SetPolicyVersion(cmVersion::GetCMakeVersion(), + std::string()); if (!this->PackageFiles() || cmSystemTools::GetErrorOccuredFlag()) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem compressing the directory" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem compressing the directory" << std::endl); return 0; } } @@ -1013,8 +1038,9 @@ int cmCPackGenerator::DoPackage() * - the initially provided name may have changed * (because the specific generator did 'normalize' it) */ - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Copying final package(s) [" - << packageFileNames.size() << "]:" << std::endl); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Copying final package(s) [" << packageFileNames.size() + << "]:" << std::endl); /* now copy package one by one */ for (std::string const& pkgFileName : packageFileNames) { std::string tmpPF(this->GetOption("CPACK_OUTPUT_FILE_PREFIX")); @@ -1022,20 +1048,23 @@ int cmCPackGenerator::DoPackage() tempPackageFileName = pkgFileName.c_str(); tmpPF += "/" + filename; const char* packageFileName = tmpPF.c_str(); - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy final package(s): " + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "Copy final package(s): " << (tempPackageFileName ? tempPackageFileName : "(NULL)") << " to " << (packageFileName ? packageFileName : "(NULL)") << std::endl); if (!cmSystemTools::CopyFileIfDifferent(tempPackageFileName, packageFileName)) { cmCPackLogger( - cmCPackLog::LOG_ERROR, "Problem copying the package: " + cmCPackLog::LOG_ERROR, + "Problem copying the package: " << (tempPackageFileName ? tempPackageFileName : "(NULL)") << " to " << (packageFileName ? packageFileName : "(NULL)") << std::endl); return 0; } - cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- package: " - << packageFileName << " generated." << std::endl); + cmCPackLogger(cmCPackLog::LOG_OUTPUT, + "- package: " << packageFileName << " generated." + << std::endl); /* Generate checksum file */ if (crypto) { @@ -1044,13 +1073,15 @@ int cmCPackGenerator::DoPackage() hashFile += "." + cmSystemTools::LowerCase(algo); cmsys::ofstream outF(hashFile.c_str()); if (!outF) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create checksum file: " - << hashFile << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot create checksum file: " << hashFile + << std::endl); return 0; } outF << crypto->HashFile(packageFileName) << " " << filename << "\n"; - cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- checksum file: " - << hashFile << " generated." << std::endl); + cmCPackLogger(cmCPackLog::LOG_OUTPUT, + "- checksum file: " << hashFile << " generated." + << std::endl); } } @@ -1170,7 +1201,8 @@ const char* cmCPackGenerator::GetInstallPath() const char* cmCPackGenerator::GetPackagingInstallPrefix() { - cmCPackLogger(cmCPackLog::LOG_DEBUG, "GetPackagingInstallPrefix: '" + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "GetPackagingInstallPrefix: '" << this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX") << "'" << std::endl); @@ -1179,11 +1211,12 @@ const char* cmCPackGenerator::GetPackagingInstallPrefix() std::string cmCPackGenerator::FindTemplate(const char* name) { - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for template: " - << (name ? name : "(NULL)") << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "Look for template: " << (name ? name : "(NULL)") + << std::endl); std::string ffile = this->MakefileMap->GetModulesFile(name); - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Found template: " << ffile - << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "Found template: " << ffile << std::endl); return ffile; } @@ -1251,10 +1284,10 @@ int cmCPackGenerator::PrepareGroupingKind() } if (!groupingType.empty()) { - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "[" - << this->Name << "]" - << " requested component grouping = " << groupingType - << std::endl); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "[" << this->Name << "]" + << " requested component grouping = " << groupingType + << std::endl); if (groupingType == "ALL_COMPONENTS_IN_ONE") { method = ONE_PACKAGE; } else if (groupingType == "IGNORE") { @@ -1263,11 +1296,11 @@ int cmCPackGenerator::PrepareGroupingKind() method = ONE_PACKAGE_PER_GROUP; } else { cmCPackLogger( - cmCPackLog::LOG_WARNING, "[" - << this->Name << "]" - << " requested component grouping type <" << groupingType - << "> UNKNOWN not in (ALL_COMPONENTS_IN_ONE,IGNORE,ONE_PER_GROUP)" - << std::endl); + cmCPackLog::LOG_WARNING, + "[" << this->Name << "]" + << " requested component grouping type <" << groupingType + << "> UNKNOWN not in (ALL_COMPONENTS_IN_ONE,IGNORE,ONE_PER_GROUP)" + << std::endl); } } @@ -1281,11 +1314,11 @@ int cmCPackGenerator::PrepareGroupingKind() method = ONE_PACKAGE_PER_COMPONENT; } cmCPackLogger( - cmCPackLog::LOG_WARNING, "[" - << this->Name << "]" - << " One package per component group requested, " - << "but NO component groups exist: Ignoring component group." - << std::endl); + cmCPackLog::LOG_WARNING, + "[" << this->Name << "]" + << " One package per component group requested, " + << "but NO component groups exist: Ignoring component group." + << std::endl); } // if user specified packaging method, override the default packaging method @@ -1296,10 +1329,10 @@ int cmCPackGenerator::PrepareGroupingKind() const char* method_names[] = { "ALL_COMPONENTS_IN_ONE", "IGNORE_GROUPS", "ONE_PER_GROUP" }; - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "[" - << this->Name << "]" - << " requested component grouping = " - << method_names[componentPackageMethod] << std::endl); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "[" << this->Name << "]" + << " requested component grouping = " + << method_names[componentPackageMethod] << std::endl); return 1; } @@ -1362,7 +1395,8 @@ bool cmCPackGenerator::SupportsComponentInstallation() const bool cmCPackGenerator::WantsComponentInstallation() const { - return (!IsOn("CPACK_MONOLITHIC_INSTALL") && SupportsComponentInstallation() + return (!IsOn("CPACK_MONOLITHIC_INSTALL") && + SupportsComponentInstallation() // check that we have at least one group or component && (!this->ComponentGroups.empty() || !this->Components.empty())); } diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index 47e752707..d47e5ed28 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -9,12 +9,13 @@ #include "cmAlgorithms.h" #include "cmCPack7zGenerator.h" #ifdef HAVE_FREEBSD_PKG -#include "cmCPackFreeBSDGenerator.h" +# include "cmCPackFreeBSDGenerator.h" #endif #include "cmCPackDebGenerator.h" #include "cmCPackGenerator.h" #include "cmCPackLog.h" #include "cmCPackNSISGenerator.h" +#include "cmCPackNuGetGenerator.h" #include "cmCPackSTGZGenerator.h" #include "cmCPackTGZGenerator.h" #include "cmCPackTXZGenerator.h" @@ -23,25 +24,25 @@ #include "cmCPackZIPGenerator.h" #ifdef __APPLE__ -#include "cmCPackBundleGenerator.h" -#include "cmCPackDragNDropGenerator.h" -#include "cmCPackOSXX11Generator.h" -#include "cmCPackPackageMakerGenerator.h" -#include "cmCPackProductBuildGenerator.h" +# include "cmCPackBundleGenerator.h" +# include "cmCPackDragNDropGenerator.h" +# include "cmCPackOSXX11Generator.h" +# include "cmCPackPackageMakerGenerator.h" +# include "cmCPackProductBuildGenerator.h" #endif #ifdef __CYGWIN__ -#include "cmCPackCygwinBinaryGenerator.h" -#include "cmCPackCygwinSourceGenerator.h" +# include "cmCPackCygwinBinaryGenerator.h" +# include "cmCPackCygwinSourceGenerator.h" #endif #if !defined(_WIN32) && !defined(__QNXNTO__) && !defined(__BEOS__) && \ !defined(__HAIKU__) -#include "cmCPackRPMGenerator.h" +# include "cmCPackRPMGenerator.h" #endif #if defined(_WIN32) || (defined(__CYGWIN__) && defined(HAVE_LIBUUID)) -#include "WiX/cmCPackWIXGenerator.h" +# include "WiX/cmCPackWIXGenerator.h" #endif cmCPackGeneratorFactory::cmCPackGeneratorFactory() @@ -105,6 +106,10 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() this->RegisterGenerator("DEB", "Debian packages", cmCPackDebGenerator::CreateGenerator); } + if (cmCPackNuGetGenerator::CanGenerate()) { + this->RegisterGenerator("NuGet", "NuGet packages", + cmCPackNuGetGenerator::CreateGenerator); + } #ifdef __APPLE__ if (cmCPackDragNDropGenerator::CanGenerate()) { this->RegisterGenerator("DragNDrop", "Mac OSX Drag And Drop", diff --git a/Source/CPack/cmCPackLog.h b/Source/CPack/cmCPackLog.h index 10deda450..8e9922121 100644 --- a/Source/CPack/cmCPackLog.h +++ b/Source/CPack/cmCPackLog.h @@ -84,7 +84,7 @@ public: bool SetLogOutputFile(const char* fname); //! Set the various prefixes for the logging. SetPrefix sets the generic - // prefix that overwrittes missing ones. + // prefix that overwrites missing ones. void SetPrefix(std::string const& pfx) { this->Prefix = pfx; } void SetOutputPrefix(std::string const& pfx) { this->OutputPrefix = pfx; } void SetVerbosePrefix(std::string const& pfx) { this->VerbosePrefix = pfx; } diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 3f7164a5d..a893a0f72 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -20,9 +20,9 @@ /* NSIS uses different command line syntax on Windows and others */ #ifdef _WIN32 -#define NSIS_OPT "/" +# define NSIS_OPT "/" #else -#define NSIS_OPT "-" +# define NSIS_OPT "-" #endif cmCPackNSISGenerator::cmCPackNSISGenerator(bool nsis64) @@ -81,8 +81,8 @@ int cmCPackNSISGenerator::PackageFiles() str << " Delete \"" << outputDir << "\\" << fileN << "\"" << std::endl; } - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Files: " << str.str() - << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "Uninstall Files: " << str.str() << std::endl); this->SetOptionIfNotSet("CPACK_NSIS_DELETE_FILES", str.str().c_str()); std::vector<std::string> dirs; this->GetListOfSubdirectories(toplevel.c_str(), dirs); @@ -117,12 +117,13 @@ int cmCPackNSISGenerator::PackageFiles() this->Components[componentName].Directories.push_back(std::move(fileN)); } } - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Dirs: " << dstr.str() - << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "Uninstall Dirs: " << dstr.str() << std::endl); this->SetOptionIfNotSet("CPACK_NSIS_DELETE_DIRECTORIES", dstr.str().c_str()); - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " - << nsisInFileName << " to " << nsisFileName << std::endl); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Configure file: " << nsisInFileName << " to " << nsisFileName + << std::endl); if (this->IsSet("CPACK_NSIS_MUI_ICON") || this->IsSet("CPACK_NSIS_MUI_UNIICON")) { std::string installerIconCode; @@ -308,10 +309,11 @@ int cmCPackNSISGenerator::PackageFiles() ofs << "# Run command: " << nsisCmd << std::endl << "# Output:" << std::endl << output << std::endl; - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running NSIS command: " - << nsisCmd << std::endl - << "Please check " << tmpFile << " for errors" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem running NSIS command: " << nsisCmd << std::endl + << "Please check " + << tmpFile << " for errors" + << std::endl); return 0; } return 1; @@ -329,28 +331,31 @@ int cmCPackNSISGenerator::InitializeInternal() this->SetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", nullptr); } - cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackNSISGenerator::Initialize()" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "cmCPackNSISGenerator::Initialize()" << std::endl); std::vector<std::string> path; std::string nsisPath; bool gotRegValue = false; #ifdef _WIN32 if (Nsis64) { - if (!gotRegValue && cmsys::SystemTools::ReadRegistryValue( - "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode", - nsisPath, cmsys::SystemTools::KeyWOW64_64)) { + if (!gotRegValue && + cmsys::SystemTools::ReadRegistryValue( + "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode", nsisPath, + cmsys::SystemTools::KeyWOW64_64)) { gotRegValue = true; } - if (!gotRegValue && cmsys::SystemTools::ReadRegistryValue( - "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath, - cmsys::SystemTools::KeyWOW64_64)) { + if (!gotRegValue && + cmsys::SystemTools::ReadRegistryValue( + "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath, + cmsys::SystemTools::KeyWOW64_64)) { gotRegValue = true; } } - if (!gotRegValue && cmsys::SystemTools::ReadRegistryValue( - "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode", - nsisPath, cmsys::SystemTools::KeyWOW64_32)) { + if (!gotRegValue && + cmsys::SystemTools::ReadRegistryValue( + "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode", nsisPath, + cmsys::SystemTools::KeyWOW64_32)) { gotRegValue = true; } if (!gotRegValue && @@ -358,13 +363,15 @@ int cmCPackNSISGenerator::InitializeInternal() "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode", nsisPath)) { gotRegValue = true; } - if (!gotRegValue && cmsys::SystemTools::ReadRegistryValue( - "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath, - cmsys::SystemTools::KeyWOW64_32)) { + if (!gotRegValue && + cmsys::SystemTools::ReadRegistryValue( + "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath, + cmsys::SystemTools::KeyWOW64_32)) { gotRegValue = true; } - if (!gotRegValue && cmsys::SystemTools::ReadRegistryValue( - "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath)) { + if (!gotRegValue && + cmsys::SystemTools::ReadRegistryValue( + "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath)) { gotRegValue = true; } @@ -395,8 +402,8 @@ int cmCPackNSISGenerator::InitializeInternal() } std::string nsisCmd = "\"" + nsisPath + "\" " NSIS_OPT "VERSION"; - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Test NSIS version: " << nsisCmd - << std::endl); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Test NSIS version: " << nsisCmd << std::endl); std::string output; int retVal = 1; bool resS = cmSystemTools::RunSingleCommand( @@ -413,17 +420,18 @@ int cmCPackNSISGenerator::InitializeInternal() ofs << "# Run command: " << nsisCmd << std::endl << "# Output:" << std::endl << output << std::endl; - cmCPackLogger( - cmCPackLog::LOG_ERROR, "Problem checking NSIS version with command: " - << nsisCmd << std::endl - << "Please check " << tmpFile << " for errors" << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem checking NSIS version with command: " + << nsisCmd << std::endl + << "Please check " << tmpFile << " for errors" + << std::endl); return 0; } if (versionRex.find(output)) { double nsisVersion = atof(versionRex.match(1).c_str()); double minNSISVersion = 2.09; - cmCPackLogger(cmCPackLog::LOG_DEBUG, "NSIS Version: " << nsisVersion - << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "NSIS Version: " << nsisVersion << std::endl); if (nsisVersion < minNSISVersion) { cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack requires NSIS Version 2.09 or greater. " @@ -434,8 +442,8 @@ int cmCPackNSISGenerator::InitializeInternal() } if (versionRexCVS.find(output)) { // No version check for NSIS cvs build - cmCPackLogger(cmCPackLog::LOG_DEBUG, "NSIS Version: CVS " - << versionRexCVS.match(1) << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "NSIS Version: CVS " << versionRexCVS.match(1) << std::endl); } this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", nsisPath.c_str()); this->SetOptionIfNotSet("CPACK_NSIS_EXECUTABLES_DIRECTORY", "bin"); @@ -447,8 +455,9 @@ int cmCPackNSISGenerator::InitializeInternal() this->GetOption("CPACK_NSIS_EXECUTABLES_DIRECTORY"); std::vector<std::string> cpackPackageDesktopLinksVector; if (cpackPackageDeskTopLinks) { - cmCPackLogger(cmCPackLog::LOG_DEBUG, "CPACK_CREATE_DESKTOP_LINKS: " - << cpackPackageDeskTopLinks << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "CPACK_CREATE_DESKTOP_LINKS: " << cpackPackageDeskTopLinks + << std::endl); cmSystemTools::ExpandListArgument(cpackPackageDeskTopLinks, cpackPackageDesktopLinksVector); @@ -457,7 +466,8 @@ int cmCPackNSISGenerator::InitializeInternal() "CPACK_CREATE_DESKTOP_LINKS: " << cpdl << std::endl); } } else { - cmCPackLogger(cmCPackLog::LOG_DEBUG, "CPACK_CREATE_DESKTOP_LINKS: " + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "CPACK_CREATE_DESKTOP_LINKS: " << "not set" << std::endl); } @@ -465,8 +475,9 @@ int cmCPackNSISGenerator::InitializeInternal() std::ostringstream deleteStr; if (cpackPackageExecutables) { - cmCPackLogger(cmCPackLog::LOG_DEBUG, "The cpackPackageExecutables: " - << cpackPackageExecutables << "." << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "The cpackPackageExecutables: " << cpackPackageExecutables + << "." << std::endl); std::vector<std::string> cpackPackageExecutablesVector; cmSystemTools::ExpandListArgument(cpackPackageExecutables, cpackPackageExecutablesVector); @@ -683,8 +694,9 @@ std::string cmCPackNSISGenerator::CreateComponentDescription( << std::endl); if (cmSystemTools::FileExists(archiveFile, true)) { if (!cmSystemTools::RemoveFile(archiveFile)) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Unable to remove archive file " - << archiveFile << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Unable to remove archive file " << archiveFile + << std::endl); return ""; } } @@ -694,8 +706,8 @@ std::string cmCPackNSISGenerator::CreateComponentDescription( this->ReadListFile("CPackZIP.cmake"); if (!this->IsSet("ZIP_EXECUTABLE")) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Unable to find ZIP program" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Unable to find ZIP program" << std::endl); return ""; } } @@ -746,10 +758,11 @@ std::string cmCPackNSISGenerator::CreateComponentDescription( ofs << "# Run command: " << cmd << std::endl << "# Output:" << std::endl << output << std::endl; - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running zip command: " - << cmd << std::endl - << "Please check " << tmpFile << " for errors" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem running zip command: " << cmd << std::endl + << "Please check " + << tmpFile << " for errors" + << std::endl); return ""; } diff --git a/Source/CPack/cmCPackNuGetGenerator.cxx b/Source/CPack/cmCPackNuGetGenerator.cxx new file mode 100644 index 000000000..2ae8cbac8 --- /dev/null +++ b/Source/CPack/cmCPackNuGetGenerator.cxx @@ -0,0 +1,141 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmCPackNuGetGenerator.h" + +#include "cmAlgorithms.h" +#include "cmCPackComponentGroup.h" +#include "cmCPackLog.h" +#include "cmSystemTools.h" + +#include <algorithm> +#include <iterator> +#include <map> +#include <ostream> +#include <string> +#include <utility> +#include <vector> + +bool cmCPackNuGetGenerator::SupportsComponentInstallation() const +{ + return IsOn("CPACK_NUGET_COMPONENT_INSTALL"); +} + +int cmCPackNuGetGenerator::PackageFiles() +{ + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " << toplevel << std::endl); + + /* Reset package file name list it will be populated after the + * `CPackNuGet.cmake` run */ + packageFileNames.clear(); + + /* Are we in the component packaging case */ + if (WantsComponentInstallation()) { + if (componentPackageMethod == ONE_PACKAGE) { + // CASE 1 : COMPONENT ALL-IN-ONE package + // Meaning that all per-component pre-installed files + // goes into the single package. + this->SetOption("CPACK_NUGET_ALL_IN_ONE", "TRUE"); + SetupGroupComponentVariables(true); + } else { + // 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. + SetupGroupComponentVariables(componentPackageMethod == + ONE_PACKAGE_PER_COMPONENT); + } + } else { + // CASE 3 : NON COMPONENT package. + this->SetOption("CPACK_NUGET_ORDINAL_MONOLITIC", "TRUE"); + } + + auto retval = this->ReadListFile("CPackNuGet.cmake"); + if (retval) { + AddGeneratedPackageNames(); + } else { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error while execution CPackNuGet.cmake" << std::endl); + } + + return retval; +} + +void cmCPackNuGetGenerator::SetupGroupComponentVariables(bool ignoreGroup) +{ + // The default behavior is to have one package by component group + // unless CPACK_COMPONENTS_IGNORE_GROUP is specified. + if (!ignoreGroup) { + std::vector<std::string> groups; + for (auto const& compG : this->ComponentGroups) { + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Packaging component group: " << compG.first << std::endl); + groups.push_back(compG.first); + auto compGUp = + cmSystemTools::UpperCase(cmSystemTools::MakeCidentifier(compG.first)); + + // Collect components for this group + std::vector<std::string> components; + std::transform(begin(compG.second.Components), + end(compG.second.Components), + std::back_inserter(components), + [](cmCPackComponent const* comp) { return comp->Name; }); + this->SetOption("CPACK_NUGET_" + compGUp + "_GROUP_COMPONENTS", + cmJoin(components, ";").c_str()); + } + if (!groups.empty()) { + this->SetOption("CPACK_NUGET_GROUPS", cmJoin(groups, ";").c_str()); + } + + // Handle Orphan components (components not belonging to any groups) + std::vector<std::string> components; + for (auto const& comp : this->Components) { + // Does the component belong to a group? + if (comp.second.Group == nullptr) { + cmCPackLogger( + cmCPackLog::LOG_VERBOSE, + "Component <" + << comp.second.Name + << "> does not belong to any group, package it separately." + << std::endl); + components.push_back(comp.first); + } + } + if (!components.empty()) { + this->SetOption("CPACK_NUGET_COMPONENTS", + cmJoin(components, ";").c_str()); + } + + } else { + std::vector<std::string> components; + components.reserve(this->Components.size()); + std::transform(begin(this->Components), end(this->Components), + std::back_inserter(components), + [](std::pair<std::string, cmCPackComponent> const& comp) { + return comp.first; + }); + this->SetOption("CPACK_NUGET_COMPONENTS", cmJoin(components, ";").c_str()); + } +} + +void cmCPackNuGetGenerator::AddGeneratedPackageNames() +{ + const char* const files_list = this->GetOption("GEN_CPACK_OUTPUT_FILES"); + if (!files_list) { + cmCPackLogger( + cmCPackLog::LOG_ERROR, + "Error while execution CPackNuGet.cmake: No NuGet package has generated" + << std::endl); + return; + } + // add the generated packages to package file names list + std::string fileNames{ files_list }; + const char sep = ';'; + std::string::size_type pos1 = 0; + std::string::size_type pos2 = fileNames.find(sep, pos1 + 1); + while (pos2 != std::string::npos) { + packageFileNames.push_back(fileNames.substr(pos1, pos2 - pos1)); + pos1 = pos2 + 1; + pos2 = fileNames.find(sep, pos1 + 1); + } + packageFileNames.push_back(fileNames.substr(pos1, pos2 - pos1)); +} diff --git a/Source/CPack/cmCPackNuGetGenerator.h b/Source/CPack/cmCPackNuGetGenerator.h new file mode 100644 index 000000000..a59db2d04 --- /dev/null +++ b/Source/CPack/cmCPackNuGetGenerator.h @@ -0,0 +1,37 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cmCPackNuGetGenerator_h +#define cmCPackNuGetGenerator_h + +#include "cmCPackGenerator.h" + +/** \class cmCPackNuGetGenerator + * \brief A generator for RPM packages + */ +class cmCPackNuGetGenerator : public cmCPackGenerator +{ +public: + cmCPackTypeMacro(cmCPackNuGetGenerator, cmCPackGenerator); + + // NOTE In fact, it is possible to have NuGet not only for Windows... + // https://docs.microsoft.com/en-us/nuget/install-nuget-client-tools + static bool CanGenerate() { return true; } + +protected: + bool SupportsComponentInstallation() const override; + int PackageFiles() override; + + const char* GetOutputExtension() override { return ".nupkg"; } + bool SupportsAbsoluteDestination() const override { return false; } + /** + * The method used to prepare variables when component + * install is used. + */ + void SetupGroupComponentVariables(bool ignoreGroup); + /** + * Populate \c packageFileNames vector of built packages. + */ + void AddGeneratedPackageNames(); +}; + +#endif diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index e750de3ea..dab72832c 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -27,8 +27,9 @@ int cmCPackOSXX11Generator::PackageFiles() const char* cpackPackageExecutables = this->GetOption("CPACK_PACKAGE_EXECUTABLES"); if (cpackPackageExecutables) { - cmCPackLogger(cmCPackLog::LOG_DEBUG, "The cpackPackageExecutables: " - << cpackPackageExecutables << "." << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "The cpackPackageExecutables: " << cpackPackageExecutables + << "." << std::endl); std::ostringstream str; std::ostringstream deleteStr; std::vector<std::string> cpackPackageExecutablesVector; @@ -78,7 +79,8 @@ int cmCPackOSXX11Generator::PackageFiles() if (iconFile) { std::string iconFileName = cmsys::SystemTools::GetFilenameName(iconFile); if (!cmSystemTools::FileExists(iconFile)) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find icon file: " + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot find icon file: " << iconFile << ". Please check CPACK_PACKAGE_ICON setting." << std::endl); @@ -109,8 +111,8 @@ int cmCPackOSXX11Generator::PackageFiles() !this->CopyResourcePlistFile("OSXScriptLauncher", appdir, this->GetOption("CPACK_PACKAGE_FILE_NAME"), true)) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem copying the resource files" << std::endl); return 0; } @@ -147,8 +149,9 @@ int cmCPackOSXX11Generator::PackageFiles() dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE") << "\" create -ov -fs HFS+ -format UDZO -srcfolder \"" << diskImageDirectory << "\" \"" << packageFileNames[0] << "\""; - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Compress disk image using command: " - << dmgCmd.str() << std::endl); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Compress disk image using command: " << dmgCmd.str() + << std::endl); // since we get random dashboard failures with this one // try running it more than once int retVal = 1; @@ -170,7 +173,8 @@ int cmCPackOSXX11Generator::PackageFiles() ofs << "# Run command: " << dmgCmd.str() << std::endl << "# Output:" << std::endl << output << std::endl; - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running hdiutil command: " + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem running hdiutil command: " << dmgCmd.str() << std::endl << "Please check " << tmpFile << " for errors" << std::endl); @@ -182,13 +186,13 @@ int cmCPackOSXX11Generator::PackageFiles() int cmCPackOSXX11Generator::InitializeInternal() { - cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackOSXX11Generator::Initialize()" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "cmCPackOSXX11Generator::Initialize()" << std::endl); std::vector<std::string> path; std::string pkgPath = cmSystemTools::FindProgram("hdiutil", path, false); if (pkgPath.empty()) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find hdiutil compiler" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot find hdiutil compiler" << std::endl); return 0; } this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM_DISK_IMAGE", @@ -263,8 +267,9 @@ bool cmCPackOSXX11Generator::CopyResourcePlistFile( destFileName += "/"; destFileName += outputFileName; - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " - << inFileName << " to " << destFileName << std::endl); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Configure file: " << inFileName << " to " << destFileName + << std::endl); this->ConfigureFile(inFileName.c_str(), destFileName.c_str(), copyOnly); return true; } diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx index 9ea85405c..bdda38660 100644 --- a/Source/CPack/cmCPackPKGGenerator.cxx +++ b/Source/CPack/cmCPackPKGGenerator.cxx @@ -26,8 +26,8 @@ bool cmCPackPKGGenerator::SupportsComponentInstallation() const int cmCPackPKGGenerator::InitializeInternal() { - cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackPKGGenerator::Initialize()" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "cmCPackPKGGenerator::Initialize()" << std::endl); return this->Superclass::InitializeInternal(); } @@ -52,8 +52,9 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile) std::string distributionTemplate = this->FindTemplate("CPack.distribution.dist.in"); if (distributionTemplate.empty()) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find input file: " - << distributionTemplate << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot find input file: " << distributionTemplate + << std::endl); return; } @@ -270,23 +271,26 @@ bool cmCPackPKGGenerator::CopyCreateResourceFile(const std::string& name, std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname; const char* inFileName = this->GetOption(cpackVar); if (!inFileName) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack option: " - << cpackVar.c_str() - << " not specified. It should point to " - << (!name.empty() ? name : "<empty>") << ".rtf, " << name - << ".html, or " << name << ".txt file" << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "CPack option: " << cpackVar.c_str() + << " not specified. It should point to " + << (!name.empty() ? name : "<empty>") + << ".rtf, " << name << ".html, or " << name + << ".txt file" << std::endl); return false; } if (!cmSystemTools::FileExists(inFileName)) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find " - << (!name.empty() ? name : "<empty>") - << " resource file: " << inFileName << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot find " << (!name.empty() ? name : "<empty>") + << " resource file: " << inFileName + << std::endl); return false; } std::string ext = cmSystemTools::GetFilenameLastExtension(inFileName); if (ext != ".rtfd" && ext != ".rtf" && ext != ".html" && ext != ".txt") { cmCPackLogger( - cmCPackLog::LOG_ERROR, "Bad file extension specified: " + cmCPackLog::LOG_ERROR, + "Bad file extension specified: " << ext << ". Currently only .rtfd, .rtf, .html, and .txt files allowed." << std::endl); @@ -330,8 +334,9 @@ bool cmCPackPKGGenerator::CopyResourcePlistFile(const std::string& name, destFileName += "/"; destFileName += outName; - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " - << inFileName << " to " << destFileName << std::endl); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Configure file: " << inFileName << " to " << destFileName + << std::endl); this->ConfigureFile(inFileName.c_str(), destFileName.c_str()); return true; } diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index c515b857f..5b1a641a0 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -251,8 +251,8 @@ int cmCPackPackageMakerGenerator::PackageFiles() !this->CopyCreateResourceFile("Welcome", resDir) || !this->CopyResourcePlistFile("Info.plist") || !this->CopyResourcePlistFile("Description.plist")) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem copying the resource files" << std::endl); return 0; } @@ -311,7 +311,8 @@ int cmCPackPackageMakerGenerator::PackageFiles() ofs << "# Run command: " << dmgCmd.str() << std::endl << "# Output:" << std::endl << output << std::endl; - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running hdiutil command: " + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem running hdiutil command: " << dmgCmd.str() << std::endl << "Please check " << tmpFile << " for errors" << std::endl); @@ -357,8 +358,8 @@ int cmCPackPackageMakerGenerator::InitializeInternal() } else { pkgPath = cmSystemTools::FindProgram("PackageMaker", paths, false); if (pkgPath.empty()) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find PackageMaker compiler" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot find PackageMaker compiler" << std::endl); return 0; } this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", pkgPath.c_str()); @@ -415,12 +416,13 @@ int cmCPackPackageMakerGenerator::InitializeInternal() } this->PackageMakerVersion = atof(rexVersion.match(1).c_str()); if (this->PackageMakerVersion < 1.0) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Require PackageMaker 1.0 or higher" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Require PackageMaker 1.0 or higher" << std::endl); return 0; } - cmCPackLogger(cmCPackLog::LOG_DEBUG, "PackageMaker version is: " - << this->PackageMakerVersion << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "PackageMaker version is: " << this->PackageMakerVersion + << std::endl); // Determine the package compatibility version. If it wasn't // specified by the user, we define it based on which features the @@ -448,8 +450,8 @@ int cmCPackPackageMakerGenerator::InitializeInternal() std::vector<std::string> no_paths; pkgPath = cmSystemTools::FindProgram("hdiutil", no_paths, false); if (pkgPath.empty()) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find hdiutil compiler" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot find hdiutil compiler" << std::endl); return 0; } this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM_DISK_IMAGE", @@ -470,17 +472,18 @@ bool cmCPackPackageMakerGenerator::RunPackageMaker(const char* command, bool res = cmSystemTools::RunSingleCommand( command, &output, &output, &retVal, nullptr, this->GeneratorVerbose, cmDuration::zero()); - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running package maker" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Done running package maker" << std::endl); if (!res || retVal) { cmGeneratedFileStream ofs(tmpFile.c_str()); ofs << "# Run command: " << command << std::endl << "# Output:" << std::endl << output << std::endl; - cmCPackLogger( - cmCPackLog::LOG_ERROR, "Problem running PackageMaker command: " - << command << std::endl - << "Please check " << tmpFile << " for errors" << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem running PackageMaker command: " + << command << std::endl + << "Please check " << tmpFile << " for errors" + << std::endl); return false; } // sometimes the command finishes but the directory is not yet @@ -505,8 +508,9 @@ bool cmCPackPackageMakerGenerator::GenerateComponentPackage( const char* packageFile, const char* packageDir, const cmCPackComponent& component) { - cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Building component package: " - << packageFile << std::endl); + cmCPackLogger(cmCPackLog::LOG_OUTPUT, + "- Building component package: " << packageFile + << std::endl); // The command that will be used to run PackageMaker std::ostringstream pkgCmd; diff --git a/Source/CPack/cmCPackProductBuildGenerator.cxx b/Source/CPack/cmCPackProductBuildGenerator.cxx index 57cf7ea11..4ca0fa82b 100644 --- a/Source/CPack/cmCPackProductBuildGenerator.cxx +++ b/Source/CPack/cmCPackProductBuildGenerator.cxx @@ -67,8 +67,8 @@ int cmCPackProductBuildGenerator::PackageFiles() this->GetOption("CPACK_PRODUCTBUILD_RESOURCES_DIR"); if (!cmSystemTools::CopyADirectory(userResDir, resDir)) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem copying the resource files" << std::endl); return 0; } } @@ -121,16 +121,16 @@ int cmCPackProductBuildGenerator::InitializeInternal() std::string program = cmSystemTools::FindProgram("pkgbuild", no_paths, false); if (program.empty()) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find pkgbuild executable" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot find pkgbuild executable" << std::endl); return 0; } this->SetOptionIfNotSet("CPACK_COMMAND_PKGBUILD", program.c_str()); program = cmSystemTools::FindProgram("productbuild", no_paths, false); if (program.empty()) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find productbuild executable" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot find productbuild executable" << std::endl); return 0; } this->SetOptionIfNotSet("CPACK_COMMAND_PRODUCTBUILD", program.c_str()); @@ -172,8 +172,9 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage( packageFile += '/'; packageFile += packageFileName; - cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Building component package: " - << packageFile << std::endl); + cmCPackLogger(cmCPackLog::LOG_OUTPUT, + "- Building component package: " << packageFile + << std::endl); const char* comp_name = component ? component->Name.c_str() : nullptr; diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index e40b74d7e..c38988403 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -90,8 +90,8 @@ int cmCPackRPMGenerator::PackageOnePack(std::string const& initialToplevel, this->SetOption("CPACK_RPM_PACKAGE_COMPONENT_PART_PATH", component_path.c_str()); if (!this->ReadListFile("CPackRPM.cmake")) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackRPM.cmake" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error while execution CPackRPM.cmake" << std::endl); retval = 0; } @@ -165,7 +165,8 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup) } if (shouldSet) { - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Setting " + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Setting " << "CPACK_RPM_DEBUGINFO_PACKAGE because " << "CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE is set but " << " none of the " @@ -203,8 +204,9 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup) continue; } - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: " - << compGIt->first << std::endl); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Packaging component group: " << compGIt->first + << std::endl); retval &= PackageOnePack(initialTopLevel, compGIt->first); } // Handle Orphan components (components not belonging to any groups) @@ -226,7 +228,8 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup) } cmCPackLogger( - cmCPackLog::LOG_VERBOSE, "Component <" + cmCPackLog::LOG_VERBOSE, + "Component <" << compIt->second.Name << "> does not belong to any group, package it separately." << std::endl); @@ -242,7 +245,8 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup) } else if (mainCompIt != this->Components.end()) { retval &= PackageOnePack(initialTopLevel, mainCompIt->first); } else { - cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_RPM_MAIN_COMPONENT set" + cmCPackLogger(cmCPackLog::LOG_ERROR, + "CPACK_RPM_MAIN_COMPONENT set" << " to non existing component.\n"); retval = 0; } @@ -276,7 +280,8 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup) if (mainCompIt != this->Components.end()) { retval &= PackageOnePack(initialTopLevel, mainCompIt->first); } else { - cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_RPM_MAIN_COMPONENT set" + cmCPackLogger(cmCPackLog::LOG_ERROR, + "CPACK_RPM_MAIN_COMPONENT set" << " to non existing component.\n"); retval = 0; } @@ -290,8 +295,9 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup) std::map<std::string, cmCPackComponentGroup>::iterator compGIt; for (compGIt = this->ComponentGroups.begin(); compGIt != this->ComponentGroups.end(); ++compGIt) { - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: " - << compGIt->first << std::endl); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Packaging component group: " << compGIt->first + << std::endl); retval &= PackageOnePack(initialTopLevel, compGIt->first); } // Handle Orphan components (components not belonging to any groups) @@ -301,7 +307,8 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup) // Does the component belong to a group? if (compIt->second.Group == nullptr) { cmCPackLogger( - cmCPackLog::LOG_VERBOSE, "Component <" + cmCPackLog::LOG_VERBOSE, + "Component <" << compIt->second.Name << "> does not belong to any group, package it separately." << std::endl); @@ -320,7 +327,8 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup) } } else { cmCPackLogger( - cmCPackLog::LOG_ERROR, "CPACK_RPM_MAIN_COMPONENT not set but" + cmCPackLog::LOG_ERROR, + "CPACK_RPM_MAIN_COMPONENT not set but" << " it is mandatory with CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE" << " being set.\n"); retval = 0; @@ -380,8 +388,8 @@ int cmCPackRPMGenerator::PackageComponentsAllInOne( if (this->ReadListFile("CPackRPM.cmake")) { AddGeneratedPackageNames(); } else { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackRPM.cmake" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error while execution CPackRPM.cmake" << std::endl); retval = 0; } diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index 3d7fd3c14..ef0d1182c 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -56,7 +56,7 @@ int cmCPackSTGZGenerator::PackageFiles() S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH #endif - ); + ); } return retval; } @@ -100,8 +100,8 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os) ++ptr; } counter++; - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Number of lines: " << counter - << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "Number of lines: " << counter << std::endl); char buffer[1024]; sprintf(buffer, "%d", counter); cmSystemTools::ReplaceString(res, headerLengthTag, buffer); diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index b6ff38b84..c08394530 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -13,7 +13,7 @@ #include <vector> #if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE) -#include "cmsys/ConsoleBuf.hxx" +# include "cmsys/ConsoleBuf.hxx" #endif #include "cmCPackGenerator.h" @@ -33,23 +33,25 @@ static const char* cmDocumentationName[][2] = { }; static const char* cmDocumentationUsage[][2] = { - { nullptr, " cpack -G <generator> [options]" }, + // clang-format off + { nullptr, " cpack [options]" }, { nullptr, nullptr } + // clang-format on }; static const char* cmDocumentationOptions[][2] = { - { "-G <generator>", "Use the specified generator to generate package." }, + { "-G <generators>", "Override/define CPACK_GENERATOR" }, { "-C <Configuration>", "Specify the project configuration" }, { "-D <var>=<value>", "Set a CPack variable." }, - { "--config <config file>", "Specify the config file." }, - { "--verbose,-V", "enable verbose output" }, + { "--config <configFile>", "Specify the config file." }, + { "--verbose,-V", "Enable verbose output" }, { "--trace", "Put underlying cmake scripts in trace mode." }, { "--trace-expand", "Put underlying cmake scripts in expanded trace mode." }, - { "--debug", "enable debug output (for CPack developers)" }, - { "-P <package name>", "override/define CPACK_PACKAGE_NAME" }, - { "-R <package version>", "override/define CPACK_PACKAGE_VERSION" }, - { "-B <package directory>", "override/define CPACK_PACKAGE_DIRECTORY" }, - { "--vendor <vendor name>", "override/define CPACK_PACKAGE_VENDOR" }, + { "--debug", "Enable debug output (for CPack developers)" }, + { "-P <packageName>", "Override/define CPACK_PACKAGE_NAME" }, + { "-R <packageVersion>", "Override/define CPACK_PACKAGE_VERSION" }, + { "-B <packageDirectory>", "Override/define CPACK_PACKAGE_DIRECTORY" }, + { "--vendor <vendorName>", "Override/define CPACK_PACKAGE_VENDOR" }, { nullptr, nullptr } }; @@ -80,8 +82,9 @@ int cpackDefinitionArgument(const char* argument, const char* cValue, std::string key = value.substr(0, pos); value = value.c_str() + pos + 1; def->Map[key] = value; - cmCPack_Log(def->Log, cmCPackLog::LOG_DEBUG, "Set CPack variable: " - << key << " to \"" << value << "\"" << std::endl); + cmCPack_Log(def->Log, cmCPackLog::LOG_DEBUG, + "Set CPack variable: " << key << " to \"" << value << "\"" + << std::endl); return 1; } @@ -318,8 +321,8 @@ int main(int argc, char const* const* argv) } const char* genList = globalMF.GetDefinition("CPACK_GENERATOR"); if (!genList) { - cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "CPack generator not specified" - << std::endl); + cmCPack_Log(&log, cmCPackLog::LOG_ERROR, + "CPack generator not specified" << std::endl); } else { std::vector<std::string> generatorsVector; cmSystemTools::ExpandListArgument(genList, generatorsVector); @@ -382,8 +385,9 @@ int main(int argc, char const* const* argv) } if (parsed) { const char* projName = mf->GetDefinition("CPACK_PACKAGE_NAME"); - cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: " - << cpackGenerator->GetNameOfClass() << std::endl); + cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, + "Use generator: " << cpackGenerator->GetNameOfClass() + << std::endl); cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "For project: " << projName << std::endl); |