diff options
Diffstat (limited to 'Source/CPack')
-rw-r--r-- | Source/CPack/WiX/cmCMakeToWixPath.cxx | 39 | ||||
-rw-r--r-- | Source/CPack/WiX/cmCMakeToWixPath.h | 12 | ||||
-rw-r--r-- | Source/CPack/WiX/cmCPackWIXGenerator.cxx | 41 | ||||
-rw-r--r-- | Source/CPack/WiX/cmCPackWIXGenerator.h | 9 | ||||
-rw-r--r-- | Source/CPack/WiX/cmWIXFilesSourceWriter.cxx | 4 | ||||
-rw-r--r-- | Source/CPack/WiX/cmWIXPatchParser.cxx | 2 | ||||
-rw-r--r-- | Source/CPack/bills-comments.txt | 2 | ||||
-rw-r--r-- | Source/CPack/cmCPackDragNDropGenerator.cxx | 20 | ||||
-rw-r--r-- | Source/CPack/cmCPackGenerator.cxx | 54 | ||||
-rw-r--r-- | Source/CPack/cmCPackGenerator.h | 7 | ||||
-rw-r--r-- | Source/CPack/cmCPackGeneratorFactory.cxx | 4 | ||||
-rw-r--r-- | Source/CPack/cmCPackPKGGenerator.cxx | 2 |
12 files changed, 161 insertions, 35 deletions
diff --git a/Source/CPack/WiX/cmCMakeToWixPath.cxx b/Source/CPack/WiX/cmCMakeToWixPath.cxx new file mode 100644 index 0000000..0b0e42a --- /dev/null +++ b/Source/CPack/WiX/cmCMakeToWixPath.cxx @@ -0,0 +1,39 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmCMakeToWixPath.h" + +#include "cmSystemTools.h" + +#include <string> +#include <vector> + +#ifdef __CYGWIN__ +#include <sys/cygwin.h> +std::string CMakeToWixPath(const std::string& cygpath) +{ + std::vector<char> winpath_chars; + ssize_t winpath_size; + + // Get the required buffer size. + winpath_size = + cygwin_conv_path(CCP_POSIX_TO_WIN_A, cygpath.c_str(), nullptr, 0); + if (winpath_size <= 0) { + return cygpath; + } + + winpath_chars.assign(static_cast<size_t>(winpath_size) + 1, '\0'); + + winpath_size = cygwin_conv_path(CCP_POSIX_TO_WIN_A, cygpath.c_str(), + winpath_chars.data(), winpath_size); + if (winpath_size < 0) { + return cygpath; + } + + return cmSystemTools::TrimWhitespace(winpath_chars.data()); +} +#else +std::string CMakeToWixPath(const std::string& path) +{ + return path; +} +#endif diff --git a/Source/CPack/WiX/cmCMakeToWixPath.h b/Source/CPack/WiX/cmCMakeToWixPath.h new file mode 100644 index 0000000..8bb9e04 --- /dev/null +++ b/Source/CPack/WiX/cmCMakeToWixPath.h @@ -0,0 +1,12 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cmCMakeToWixPath_h +#define cmCMakeToWixPath_h + +#include "cmConfigure.h" //IWYU pragma: keep + +#include <string> + +std::string CMakeToWixPath(const std::string& cygpath); + +#endif // cmCMakeToWixPath_h diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index ba07d08..a0bc0ea 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -22,7 +22,13 @@ #include "cmsys/FStream.hxx" #include "cmsys/SystemTools.hxx" -#include <rpc.h> // for GUID generation +#ifdef _WIN32 +#include <rpc.h> // for GUID generation (windows only) +#else +#include <uuid/uuid.h> // for GUID generation (libuuid) +#endif + +#include "cmCMakeToWixPath.h" cmCPackWIXGenerator::cmCPackWIXGenerator() : Patch(0) @@ -110,7 +116,7 @@ bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles) std::ostringstream command; command << QuotePath(executable); command << " -nologo"; - command << " -out " << QuotePath(packageFileNames.at(0)); + command << " -out " << QuotePath(CMakeToWixPath(packageFileNames.at(0))); for (std::string const& ext : this->LightExtensions) { command << " -ext " << QuotePath(ext); @@ -270,11 +276,12 @@ bool cmCPackWIXGenerator::PackageFilesImpl() std::string objectFilename = this->CPackTopLevel + "/" + uniqueBaseName + ".wixobj"; - if (!RunCandleCommand(sourceFilename, objectFilename)) { + if (!RunCandleCommand(CMakeToWixPath(sourceFilename), + CMakeToWixPath(objectFilename))) { return false; } - objectFiles << " " << QuotePath(objectFilename); + objectFiles << " " << QuotePath(CMakeToWixPath(objectFilename)); } AppendUserSuppliedExtraObjects(objectFiles); @@ -320,10 +327,10 @@ void cmCPackWIXGenerator::CreateWiXVariablesIncludeFile() CopyDefinition(includeFile, "CPACK_PACKAGE_VENDOR"); CopyDefinition(includeFile, "CPACK_PACKAGE_NAME"); CopyDefinition(includeFile, "CPACK_PACKAGE_VERSION"); - CopyDefinition(includeFile, "CPACK_WIX_LICENSE_RTF"); - CopyDefinition(includeFile, "CPACK_WIX_PRODUCT_ICON"); - CopyDefinition(includeFile, "CPACK_WIX_UI_BANNER"); - CopyDefinition(includeFile, "CPACK_WIX_UI_DIALOG"); + CopyDefinition(includeFile, "CPACK_WIX_LICENSE_RTF", DefinitionType::PATH); + CopyDefinition(includeFile, "CPACK_WIX_PRODUCT_ICON", DefinitionType::PATH); + CopyDefinition(includeFile, "CPACK_WIX_UI_BANNER", DefinitionType::PATH); + CopyDefinition(includeFile, "CPACK_WIX_UI_DIALOG", DefinitionType::PATH); SetOptionIfNotSet("CPACK_WIX_PROGRAM_MENU_FOLDER", GetOption("CPACK_PACKAGE_NAME")); CopyDefinition(includeFile, "CPACK_WIX_PROGRAM_MENU_FOLDER"); @@ -390,11 +397,16 @@ void cmCPackWIXGenerator::CreateWiXProductFragmentIncludeFile() } void cmCPackWIXGenerator::CopyDefinition(cmWIXSourceWriter& source, - std::string const& name) + std::string const& name, + DefinitionType type) { const char* value = GetOption(name.c_str()); if (value) { - AddDefinition(source, name, value); + if (type == DefinitionType::PATH) { + AddDefinition(source, name, CMakeToWixPath(value)); + } else { + AddDefinition(source, name, value); + } } } @@ -966,6 +978,7 @@ std::string cmCPackWIXGenerator::GetArchitecture() const std::string cmCPackWIXGenerator::GenerateGUID() { +#ifdef _WIN32 UUID guid; UuidCreate(&guid); @@ -975,6 +988,14 @@ std::string cmCPackWIXGenerator::GenerateGUID() std::string result = cmsys::Encoding::ToNarrow(reinterpret_cast<wchar_t*>(tmp)); RpcStringFreeW(&tmp); +#else + uuid_t guid; + char guid_ch[37] = { 0 }; + + uuid_generate(guid); + uuid_unparse(guid, guid_ch); + std::string result = guid_ch; +#endif return cmSystemTools::UpperCase(result); } diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h index b2633a7..128a04d 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.h +++ b/Source/CPack/WiX/cmCPackWIXGenerator.h @@ -48,6 +48,12 @@ private: typedef std::map<std::string, size_t> ambiguity_map_t; typedef std::set<std::string> extension_set_t; + enum class DefinitionType + { + STRING, + PATH + }; + bool InitializeWiXConfiguration(); bool PackageFilesImpl(); @@ -58,7 +64,8 @@ private: void CreateWiXProductFragmentIncludeFile(); - void CopyDefinition(cmWIXSourceWriter& source, std::string const& name); + void CopyDefinition(cmWIXSourceWriter& source, std::string const& name, + DefinitionType type = DefinitionType::STRING); void AddDefinition(cmWIXSourceWriter& source, std::string const& name, std::string const& value); diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx index b4cd1a3..dd3caf9 100644 --- a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx @@ -11,6 +11,8 @@ #include "cm_sys_stat.h" +#include "cmCMakeToWixPath.h" + cmWIXFilesSourceWriter::cmWIXFilesSourceWriter(cmCPackLog* logger, std::string const& filename, GuidType componentGuidType) @@ -139,7 +141,7 @@ std::string cmWIXFilesSourceWriter::EmitComponentFile( patch.ApplyFragment(componentId, *this); BeginElement("File"); AddAttribute("Id", fileId); - AddAttribute("Source", filePath); + AddAttribute("Source", CMakeToWixPath(filePath)); AddAttribute("KeyPath", "yes"); mode_t fileMode = 0; diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx index e6aeed3..c6ca944 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.cxx +++ b/Source/CPack/WiX/cmWIXPatchParser.cxx @@ -90,7 +90,7 @@ void cmWIXPatchParser::StartFragment(const char** attributes) } } - /* add any additional attributes for the fragement */ + /* add any additional attributes for the fragment */ if (!new_element) { ReportValidationError("No 'Id' specified for 'CPackWixFragment' element"); } else { diff --git a/Source/CPack/bills-comments.txt b/Source/CPack/bills-comments.txt index c3b4ee8..1aaf9af 100644 --- a/Source/CPack/bills-comments.txt +++ b/Source/CPack/bills-comments.txt @@ -31,7 +31,7 @@ cmCPackGenericGenerator::ProcessGenerator // DoPackage cmCPackGenericGenerator::InstallProject is used for both source and binary -packages. It is controled based on values set in CPACK_ variables. +packages. It is controlled based on values set in CPACK_ variables. InstallProject diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index 1e1543f..bb35623 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -411,6 +411,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, std::string temp_image = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); temp_image += "/temp.dmg"; + std::string create_error; std::ostringstream temp_image_command; temp_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); temp_image_command << " create"; @@ -421,9 +422,11 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, temp_image_command << " -format " << temp_image_format; temp_image_command << " \"" << temp_image << "\""; - if (!this->RunCommand(temp_image_command)) { + if (!this->RunCommand(temp_image_command, &create_error)) { cmCPackLogger(cmCPackLog::LOG_ERROR, - "Error generating temporary disk image." << std::endl); + "Error generating temporary disk image." << std::endl + << create_error + << std::endl); return 0; } @@ -464,15 +467,17 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, // Optionally set the custom icon flag for the image ... if (!had_error && !cpack_package_icon.empty()) { + std::string error; std::ostringstream setfile_command; setfile_command << this->GetOption("CPACK_COMMAND_SETFILE"); setfile_command << " -a C"; setfile_command << " \"" << temp_mount << "\""; - if (!this->RunCommand(setfile_command)) { + if (!this->RunCommand(setfile_command, &error)) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Error assigning custom icon to temporary disk image." - << std::endl); + << std::endl + << error << std::endl); had_error = true; } @@ -717,9 +722,12 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, final_image_command << " zlib-level=9"; final_image_command << " -o \"" << output_file << "\""; - if (!this->RunCommand(final_image_command)) { + std::string convert_error; + + if (!this->RunCommand(final_image_command, &convert_error)) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Error compressing disk image." - << std::endl); + << std::endl + << convert_error << std::endl); return 0; } diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index ecb5adb..be75a9f 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -12,6 +12,7 @@ #include "cmCPackComponentGroup.h" #include "cmCPackLog.h" #include "cmCryptoHash.h" +#include "cmFSPermissions.h" #include "cmGeneratedFileStream.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" @@ -201,6 +202,29 @@ int cmCPackGenerator::InstallProject() cmSystemTools::PutEnv("DESTDIR="); } + // prepare default created directory permissions + mode_t default_dir_mode_v = 0; + mode_t* default_dir_mode = nullptr; + const char* default_dir_install_permissions = + this->GetOption("CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS"); + if (default_dir_install_permissions && *default_dir_install_permissions) { + std::vector<std::string> items; + 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 '" + << arg + << "'." + " CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS " + "value is invalid." + << std::endl); + return 0; + } + } + + default_dir_mode = &default_dir_mode_v; + } + // If the CPackConfig file sets CPACK_INSTALL_COMMANDS then run them // as listed if (!this->InstallProjectViaInstallCommands(setDestDir, @@ -218,15 +242,15 @@ int cmCPackGenerator::InstallProject() // If the CPackConfig file sets CPACK_INSTALLED_DIRECTORIES // then glob it and copy it to CPACK_TEMPORARY_DIRECTORY // This is used in Source packaging - if (!this->InstallProjectViaInstalledDirectories(setDestDir, - tempInstallDirectory)) { + if (!this->InstallProjectViaInstalledDirectories( + setDestDir, tempInstallDirectory, default_dir_mode)) { return 0; } // If the project is a CMAKE project then run pre-install // and then read the cmake_install script to run it - if (!this->InstallProjectViaInstallCMakeProjects(setDestDir, - bareTempInstallDirectory)) { + if (!this->InstallProjectViaInstallCMakeProjects( + setDestDir, bareTempInstallDirectory, default_dir_mode)) { return 0; } @@ -274,7 +298,8 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( } int cmCPackGenerator::InstallProjectViaInstalledDirectories( - bool setDestDir, const std::string& tempInstallDirectory) + bool setDestDir, const std::string& tempInstallDirectory, + const mode_t* default_dir_mode) { (void)setDestDir; (void)tempInstallDirectory; @@ -385,7 +410,8 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( // make sure directory exists for symlink std::string destDir = cmSystemTools::GetFilenamePath(symlinked.second); - if (!destDir.empty() && !cmSystemTools::MakeDirectory(destDir)) { + if (!destDir.empty() && + !cmSystemTools::MakeDirectory(destDir, default_dir_mode)) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create dir: " << destDir << "\nTrying to create symlink: " << symlinked.second << "--> " << symlinked.first @@ -464,7 +490,8 @@ int cmCPackGenerator::InstallProjectViaInstallScript( } int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( - bool setDestDir, const std::string& baseTempInstallDirectory) + bool setDestDir, const std::string& baseTempInstallDirectory, + const mode_t* default_dir_mode) { const char* cmakeProjects = this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS"); const char* cmakeGenerator = this->GetOption("CPACK_CMAKE_GENERATOR"); @@ -631,6 +658,13 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( } } + const char* default_dir_inst_permissions = + this->GetOption("CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS"); + if (default_dir_inst_permissions && *default_dir_inst_permissions) { + mf.AddDefinition("CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS", + default_dir_inst_permissions); + } + if (!setDestDir) { tempInstallDirectory += this->GetPackagingInstallPrefix(); } @@ -690,7 +724,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( cmCPackLogger(cmCPackLog::LOG_DEBUG, "- Creating directory: '" << dir << "'" << std::endl); - if (!cmsys::SystemTools::MakeDirectory(dir.c_str())) { + if (!cmsys::SystemTools::MakeDirectory(dir, default_dir_mode)) { cmCPackLogger( cmCPackLog::LOG_ERROR, "Problem creating temporary directory: " << dir << std::endl); @@ -700,8 +734,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( mf.AddDefinition("CMAKE_INSTALL_PREFIX", tempInstallDirectory.c_str()); - if (!cmsys::SystemTools::MakeDirectory( - tempInstallDirectory.c_str())) { + if (!cmsys::SystemTools::MakeDirectory(tempInstallDirectory, + default_dir_mode)) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem creating temporary directory: " << tempInstallDirectory << std::endl); diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index 4e3a6e0..8100b66 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -12,6 +12,7 @@ #include "cmCPackComponentGroup.h" #include "cmSystemTools.h" +#include "cm_sys_stat.h" class cmCPackLog; class cmInstalledFile; @@ -168,9 +169,11 @@ protected: virtual int InstallProjectViaInstallScript( bool setDestDir, const std::string& tempInstallDirectory); virtual int InstallProjectViaInstalledDirectories( - bool setDestDir, const std::string& tempInstallDirectory); + bool setDestDir, const std::string& tempInstallDirectory, + const mode_t* default_dir_mode); virtual int InstallProjectViaInstallCMakeProjects( - bool setDestDir, const std::string& tempInstallDirectory); + bool setDestDir, const std::string& tempInstallDirectory, + const mode_t* default_dir_mode); /** * The various level of support of diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index 4b81bbc..47e7527 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -40,7 +40,7 @@ #include "cmCPackRPMGenerator.h" #endif -#ifdef _WIN32 +#if defined(_WIN32) || (defined(__CYGWIN__) && defined(HAVE_LIBUUID)) #include "WiX/cmCPackWIXGenerator.h" #endif @@ -87,7 +87,7 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() this->RegisterGenerator("7Z", "7-Zip file format", cmCPack7zGenerator::CreateGenerator); } -#ifdef _WIN32 +#if defined(_WIN32) || (defined(__CYGWIN__) && defined(HAVE_LIBUUID)) if (cmCPackWIXGenerator::CanGenerate()) { this->RegisterGenerator("WIX", "MSI file format via WiX tools", cmCPackWIXGenerator::CreateGenerator); diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx index 4f5b2a0..9ea8540 100644 --- a/Source/CPack/cmCPackPKGGenerator.cxx +++ b/Source/CPack/cmCPackPKGGenerator.cxx @@ -189,7 +189,7 @@ void cmCPackPKGGenerator::CreateChoice(const cmCPackComponent& component, // This way, selecting C will automatically select everything it depends // on (B and A), while selecting something that depends on C--either D // or E--will automatically cause C to get selected. - std::ostringstream selected("my.choice.selected"); + std::ostringstream selected("my.choice.selected", std::ios_base::ate); std::set<const cmCPackComponent*> visited; AddDependencyAttributes(component, visited, selected); visited.clear(); |