diff options
author | Konstantin Podsvirov <konstantin@podsvirov.pro> | 2017-01-24 13:51:42 (GMT) |
---|---|---|
committer | Konstantin Podsvirov <konstantin@podsvirov.pro> | 2017-01-24 14:03:37 (GMT) |
commit | e5089c562cdb516bb2a502754788864390c429be (patch) | |
tree | b44c714f36d73c1d7abf2753ca8ef9eecdf03a1d /Source | |
parent | 7b4514fb33cf256ef165b2b28ba4affd1930a957 (diff) | |
download | CMake-e5089c562cdb516bb2a502754788864390c429be.zip CMake-e5089c562cdb516bb2a502754788864390c429be.tar.gz CMake-e5089c562cdb516bb2a502754788864390c429be.tar.bz2 |
CPackIFW: Add some options
The cpack_ifw_configure_component_group command gained options:
- DEPENDS.
The cpack_ifw_configure_component and
cpack_ifw_configure_component_group commands gained options:
- REQUIRES_ADMIN_RIGHTS;
- UPDATE_TEXT;
- SORTING_PRIORITY; # New name for PRIORITY
- DEPENDENCIES; # Alias for DEPENDS
- AUTO_DEPEND_ON;
- TRANSLATIONS.
For both commands PRIORITY option now is depreceted. Please
use SORTING_PRIORITY instead.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWPackage.cxx | 172 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWPackage.h | 11 |
2 files changed, 165 insertions, 18 deletions
diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx index c868a14..e23b1b9 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.cxx +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -62,6 +62,13 @@ cmCPackIFWPackage::DependenceStruct::DependenceStruct( } else if ((pos = dependence.find('>')) != std::string::npos) { Compare.Type = CompareGreater; Compare.Value = dependence.substr(pos + 1); + } else if ((pos = dependence.find('-')) != std::string::npos) { + Compare.Type = CompareNone; + Compare.Value = dependence.substr(pos + 1); + } + size_t dashPos = dependence.find('-'); + if (dashPos != std::string::npos) { + pos = dashPos; } Name = pos == std::string::npos ? dependence : dependence.substr(0, pos); } @@ -74,6 +81,10 @@ std::string cmCPackIFWPackage::DependenceStruct::NameWithCompare() const std::string result = Name; + if (Compare.Type != CompareNone || !Compare.Value.empty()) { + result += "-"; + } + if (Compare.Type == CompareLessOrEqual) { result += "<="; } else if (Compare.Type == CompareGreaterOrEqual) { @@ -154,11 +165,14 @@ void cmCPackIFWPackage::DefaultConfiguration() Script = ""; Licenses.clear(); UserInterfaces.clear(); + Translations.clear(); SortingPriority = ""; + UpdateText = ""; Default = ""; Essential = ""; Virtual = ""; ForcedInstallation = ""; + RequiresAdminRights = ""; } // Defaul configuration (all in one package) @@ -245,24 +259,6 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component) } } - // QtIFW dependencies - if (const char* option = this->GetOption(prefix + "DEPENDS")) { - std::vector<std::string> deps; - cmSystemTools::ExpandListArgument(option, deps); - for (std::vector<std::string>::iterator dit = deps.begin(); - dit != deps.end(); ++dit) { - DependenceStruct dep(*dit); - if (!Generator->Packages.count(dep.Name)) { - bool hasDep = Generator->DependentPackages.count(dep.Name) > 0; - DependenceStruct& depRef = Generator->DependentPackages[dep.Name]; - if (!hasDep) { - depRef = dep; - } - AlienDependencies.insert(&depRef); - } - } - } - // Licenses if (const char* option = this->GetOption(prefix + "LICENSES")) { Licenses.clear(); @@ -280,6 +276,11 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component) // Priority if (const char* option = this->GetOption(prefix + "PRIORITY")) { SortingPriority = option; + cmCPackLogger( + cmCPackLog::LOG_WARNING, "The \"PRIORITY\" option is set " + << "for component \"" << component->Name << "\", but there option is " + << "deprecated. Please use \"SORTING_PRIORITY\" option instead." + << std::endl); } // Default @@ -352,6 +353,12 @@ int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group) // Priority if (const char* option = this->GetOption(prefix + "PRIORITY")) { SortingPriority = option; + cmCPackLogger( + cmCPackLog::LOG_WARNING, "The \"PRIORITY\" option is set " + << "for component group \"" << group->Name + << "\", but there option is " + << "deprecated. Please use \"SORTING_PRIORITY\" option instead." + << std::endl); } return ConfigureFromPrefix(prefix); @@ -420,6 +427,79 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix) ReleaseDate = value; } + // Sorting priority + option = prefix + "SORTING_PRIORITY"; + if (IsSetToEmpty(option)) { + SortingPriority.clear(); + } else if (const char* value = GetOption(option)) { + SortingPriority = value; + } + + // Update text + option = prefix + "UPDATE_TEXT"; + if (IsSetToEmpty(option)) { + UpdateText.clear(); + } else if (const char* value = GetOption(option)) { + UpdateText = value; + } + + // Translations + option = prefix + "TRANSLATIONS"; + if (IsSetToEmpty(option)) { + Translations.clear(); + } else if (const char* value = this->GetOption(option)) { + Translations.clear(); + cmSystemTools::ExpandListArgument(value, Translations); + } + + // QtIFW dependencies + std::vector<std::string> deps; + option = prefix + "DEPENDS"; + if (const char* value = this->GetOption(option)) { + cmSystemTools::ExpandListArgument(value, deps); + } + option = prefix + "DEPENDENCIES"; + if (const char* value = this->GetOption(option)) { + cmSystemTools::ExpandListArgument(value, deps); + } + for (std::vector<std::string>::iterator dit = deps.begin(); + dit != deps.end(); ++dit) { + DependenceStruct dep(*dit); + if (Generator->Packages.count(dep.Name)) { + cmCPackIFWPackage& depPkg = Generator->Packages[dep.Name]; + dep.Name = depPkg.Name; + } + bool hasDep = Generator->DependentPackages.count(dep.Name) > 0; + DependenceStruct& depRef = Generator->DependentPackages[dep.Name]; + if (!hasDep) { + depRef = dep; + } + AlienDependencies.insert(&depRef); + } + + // Automatic dependency on + option = prefix + "AUTO_DEPEND_ON"; + if (IsSetToEmpty(option)) { + AlienAutoDependOn.clear(); + } else if (const char* value = this->GetOption(option)) { + std::vector<std::string> depsOn; + cmSystemTools::ExpandListArgument(value, depsOn); + for (std::vector<std::string>::iterator dit = depsOn.begin(); + dit != depsOn.end(); ++dit) { + DependenceStruct dep(*dit); + if (Generator->Packages.count(dep.Name)) { + cmCPackIFWPackage& depPkg = Generator->Packages[dep.Name]; + dep.Name = depPkg.Name; + } + bool hasDep = Generator->DependentPackages.count(dep.Name) > 0; + DependenceStruct& depRef = Generator->DependentPackages[dep.Name]; + if (!hasDep) { + depRef = dep; + } + AlienAutoDependOn.insert(&depRef); + } + } + // Visibility option = prefix + "VIRTUAL"; if (IsSetToEmpty(option)) { @@ -455,6 +535,16 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix) ForcedInstallation = "false"; } + // Requires admin rights + option = prefix + "REQUIRES_ADMIN_RIGHTS"; + if (IsSetToEmpty(option)) { + RequiresAdminRights.clear(); + } else if (IsOn(option)) { + RequiresAdminRights = "true"; + } else if (IsSetToOff(option)) { + RequiresAdminRights = "false"; + } + return 1; } @@ -481,6 +571,12 @@ void cmCPackIFWPackage::GeneratePackageFile() xout.Element("DisplayName", DisplayName); xout.Element("Description", Description); + + // Update text + if (!UpdateText.empty()) { + xout.Element("UpdateText", UpdateText); + } + xout.Element("Name", Name); xout.Element("Version", Version); @@ -515,6 +611,23 @@ void cmCPackIFWPackage::GeneratePackageFile() xout.EndElement(); } + // Translations (copy to meta dir) + std::vector<std::string> translations = Translations; + for (size_t i = 0; i < translations.size(); i++) { + std::string name = cmSystemTools::GetFilenameName(translations[i]); + std::string path = Directory + "/meta/" + name; + cmsys::SystemTools::CopyFileIfDifferent(translations[i].data(), + path.data()); + translations[i] = name; + } + if (!translations.empty()) { + xout.StartElement("Translations"); + for (size_t i = 0; i < translations.size(); i++) { + xout.Element("Translation", translations[i]); + } + xout.EndElement(); + } + // Dependencies std::set<DependenceStruct> compDepSet; for (std::set<DependenceStruct*>::iterator ait = AlienDependencies.begin(); @@ -538,6 +651,25 @@ void cmCPackIFWPackage::GeneratePackageFile() xout.Element("Dependencies", dependencies.str()); } + // Automatic dependency on + std::set<DependenceStruct> compAutoDepSet; + for (std::set<DependenceStruct*>::iterator ait = AlienAutoDependOn.begin(); + ait != AlienAutoDependOn.end(); ++ait) { + compAutoDepSet.insert(*(*ait)); + } + // Write automatic dependency on + if (!compAutoDepSet.empty()) { + std::ostringstream dependencies; + std::set<DependenceStruct>::iterator it = compAutoDepSet.begin(); + dependencies << it->NameWithCompare(); + ++it; + while (it != compAutoDepSet.end()) { + dependencies << "," << it->NameWithCompare(); + ++it; + } + xout.Element("AutoDependOn", dependencies.str()); + } + // Licenses (copy to meta dir) std::vector<std::string> licenses = Licenses; for (size_t i = 1; i < licenses.size(); i += 2) { @@ -561,6 +693,10 @@ void cmCPackIFWPackage::GeneratePackageFile() xout.Element("ForcedInstallation", ForcedInstallation); } + if (!RequiresAdminRights.empty()) { + xout.Element("RequiresAdminRights", RequiresAdminRights); + } + if (!Virtual.empty()) { xout.Element("Virtual", Virtual); } else if (!Default.empty()) { diff --git a/Source/CPack/IFW/cmCPackIFWPackage.h b/Source/CPack/IFW/cmCPackIFWPackage.h index 76ed540..bd1d6c5 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.h +++ b/Source/CPack/IFW/cmCPackIFWPackage.h @@ -92,9 +92,15 @@ public: /// List of pages to load std::vector<std::string> UserInterfaces; + /// List of translation files to load + std::vector<std::string> Translations; + /// Priority of the component in the tree std::string SortingPriority; + /// Description added to the component description + std::string UpdateText; + /// Set to true to preselect the component in the installer std::string Default; @@ -107,6 +113,9 @@ public: /// Determines that the package must always be installed std::string ForcedInstallation; + /// Package needs to be installed with elevated permissions + std::string RequiresAdminRights; + public: // Internal implementation @@ -139,6 +148,8 @@ public: std::set<cmCPackIFWPackage*> Dependencies; // Collection of unresolved dependencies std::set<DependenceStruct*> AlienDependencies; + // Collection of unresolved automatic dependency on + std::set<DependenceStruct*> AlienAutoDependOn; // Patch to package directory std::string Directory; |