summaryrefslogtreecommitdiff
path: root/Source/CPack/cmCPackRPMGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/CPack/cmCPackRPMGenerator.cxx')
-rw-r--r--Source/CPack/cmCPackRPMGenerator.cxx206
1 files changed, 87 insertions, 119 deletions
diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx
index 2640404646..fc6603a575 100644
--- a/Source/CPack/cmCPackRPMGenerator.cxx
+++ b/Source/CPack/cmCPackRPMGenerator.cxx
@@ -25,24 +25,23 @@ cmCPackRPMGenerator::~cmCPackRPMGenerator()
int cmCPackRPMGenerator::InitializeInternal()
{
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
- if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR")))
- {
+ if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR"))) {
this->SetOption("CPACK_SET_DESTDIR", "I_ON");
- }
+ }
/* Replace space in CPACK_PACKAGE_NAME in order to avoid
* rpmbuild scream on unwanted space in filename issue
* Moreover RPM file do not usually embed space in filename
*/
if (this->GetOption("CPACK_PACKAGE_NAME")) {
- std::string packageName=this->GetOption("CPACK_PACKAGE_NAME");
- cmSystemTools::ReplaceString(packageName," ","-");
- this->SetOption("CPACK_PACKAGE_NAME",packageName.c_str());
+ std::string packageName = this->GetOption("CPACK_PACKAGE_NAME");
+ cmSystemTools::ReplaceString(packageName, " ", "-");
+ this->SetOption("CPACK_PACKAGE_NAME", packageName.c_str());
}
/* same for CPACK_PACKAGE_FILE_NAME */
if (this->GetOption("CPACK_PACKAGE_FILE_NAME")) {
- std::string packageName=this->GetOption("CPACK_PACKAGE_FILE_NAME");
- cmSystemTools::ReplaceString(packageName," ","-");
- this->SetOption("CPACK_PACKAGE_FILE_NAME",packageName.c_str());
+ std::string packageName = this->GetOption("CPACK_PACKAGE_FILE_NAME");
+ cmSystemTools::ReplaceString(packageName, " ", "-");
+ this->SetOption("CPACK_PACKAGE_FILE_NAME", packageName.c_str());
}
return this->Superclass::InitializeInternal();
}
@@ -53,14 +52,13 @@ void cmCPackRPMGenerator::AddGeneratedPackageNames()
std::string fileNames(this->GetOption("GEN_CPACK_OUTPUT_FILES"));
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));
+ 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));
}
int cmCPackRPMGenerator::PackageOnePack(std::string initialToplevel,
@@ -69,38 +67,33 @@ int cmCPackRPMGenerator::PackageOnePack(std::string initialToplevel,
int retval = 1;
// Begin the archive for this pack
std::string localToplevel(initialToplevel);
- std::string packageFileName(
- cmSystemTools::GetParentDirectory(toplevel)
- );
+ std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel));
std::string outputFileName(
- GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
- packageName,
- true)
- + this->GetOutputExtension()
- );
+ GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
+ packageName, true) +
+ this->GetOutputExtension());
- localToplevel += "/"+ packageName;
+ localToplevel += "/" + packageName;
/* replace the TEMP DIRECTORY with the component one */
- this->SetOption("CPACK_TEMPORARY_DIRECTORY",localToplevel.c_str());
- packageFileName += "/"+ outputFileName;
+ this->SetOption("CPACK_TEMPORARY_DIRECTORY", localToplevel.c_str());
+ packageFileName += "/" + outputFileName;
/* replace proposed CPACK_OUTPUT_FILE_NAME */
- this->SetOption("CPACK_OUTPUT_FILE_NAME",outputFileName.c_str());
+ this->SetOption("CPACK_OUTPUT_FILE_NAME", outputFileName.c_str());
/* replace the TEMPORARY package file name */
this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME",
packageFileName.c_str());
// Tell CPackRPM.cmake the name of the component NAME.
- this->SetOption("CPACK_RPM_PACKAGE_COMPONENT",packageName.c_str());
+ this->SetOption("CPACK_RPM_PACKAGE_COMPONENT", packageName.c_str());
// Tell CPackRPM.cmake the path where the component is.
std::string component_path = "/";
component_path += packageName;
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);
+ if (!this->ReadListFile("CPackRPM.cmake")) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackRPM.cmake"
+ << std::endl);
retval = 0;
- }
+ }
return retval;
}
@@ -115,56 +108,48 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
// The default behavior is to have one package by component group
// unless CPACK_COMPONENTS_IGNORE_GROUP is specified.
- if (!ignoreGroup)
- {
+ if (!ignoreGroup) {
std::map<std::string, cmCPackComponentGroup>::iterator compGIt;
- for (compGIt=this->ComponentGroups.begin();
- compGIt!=this->ComponentGroups.end(); ++compGIt)
- {
+ for (compGIt = this->ComponentGroups.begin();
+ compGIt != this->ComponentGroups.end(); ++compGIt) {
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: "
- << compGIt->first
- << std::endl);
- retval &= PackageOnePack(initialTopLevel,compGIt->first);
- }
+ << compGIt->first << std::endl);
+ retval &= PackageOnePack(initialTopLevel, compGIt->first);
+ }
// Handle Orphan components (components not belonging to any groups)
std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt=this->Components.begin();
- compIt!=this->Components.end(); ++compIt )
- {
+ for (compIt = this->Components.begin(); compIt != this->Components.end();
+ ++compIt) {
// Does the component belong to a group?
- if (compIt->second.Group==NULL)
- {
- cmCPackLogger(cmCPackLog::LOG_VERBOSE,
- "Component <"
+ if (compIt->second.Group == NULL) {
+ cmCPackLogger(
+ cmCPackLog::LOG_VERBOSE, "Component <"
<< compIt->second.Name
<< "> does not belong to any group, package it separately."
<< std::endl);
- retval &= PackageOnePack(initialTopLevel,compIt->first);
- }
+ retval &= PackageOnePack(initialTopLevel, compIt->first);
}
}
+ }
// CPACK_COMPONENTS_IGNORE_GROUPS is set
// We build 1 package per component
- else
- {
+ else {
std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt=this->Components.begin();
- compIt!=this->Components.end(); ++compIt )
- {
- retval &= PackageOnePack(initialTopLevel,compIt->first);
- }
+ for (compIt = this->Components.begin(); compIt != this->Components.end();
+ ++compIt) {
+ retval &= PackageOnePack(initialTopLevel, compIt->first);
}
+ }
- if(retval)
- {
+ if (retval) {
AddGeneratedPackageNames();
- }
+ }
return retval;
}
int cmCPackRPMGenerator::PackageComponentsAllInOne(
- const std::string& compInstDirName)
+ const std::string& compInstDirName)
{
int retval = 1;
/* Reset package file name list it will be populated during the
@@ -175,98 +160,84 @@ int cmCPackRPMGenerator::PackageComponentsAllInOne(
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Packaging all groups in one package..."
"(CPACK_COMPONENTS_ALL_[GROUPS_]IN_ONE_PACKAGE is set)"
- << std::endl);
+ << std::endl);
// The ALL GROUPS in ONE package case
std::string localToplevel(initialTopLevel);
- std::string packageFileName(
- cmSystemTools::GetParentDirectory(toplevel)
- );
+ std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel));
std::string outputFileName(
- std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))
- + this->GetOutputExtension()
- );
+ std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) +
+ this->GetOutputExtension());
// all GROUP in one vs all COMPONENT in one
- localToplevel += "/"+compInstDirName;
+ localToplevel += "/" + compInstDirName;
/* replace the TEMP DIRECTORY with the component one */
- this->SetOption("CPACK_TEMPORARY_DIRECTORY",localToplevel.c_str());
- packageFileName += "/"+ outputFileName;
+ this->SetOption("CPACK_TEMPORARY_DIRECTORY", localToplevel.c_str());
+ packageFileName += "/" + outputFileName;
/* replace proposed CPACK_OUTPUT_FILE_NAME */
- this->SetOption("CPACK_OUTPUT_FILE_NAME",outputFileName.c_str());
+ this->SetOption("CPACK_OUTPUT_FILE_NAME", outputFileName.c_str());
/* replace the TEMPORARY package file name */
this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME",
- packageFileName.c_str());
+ packageFileName.c_str());
- if(!compInstDirName.empty())
- {
+ if (!compInstDirName.empty()) {
// Tell CPackRPM.cmake the path where the component is.
std::string component_path = "/";
component_path += compInstDirName;
this->SetOption("CPACK_RPM_PACKAGE_COMPONENT_PART_PATH",
component_path.c_str());
- }
+ }
- if (this->ReadListFile("CPackRPM.cmake"))
- {
+ if (this->ReadListFile("CPackRPM.cmake")) {
AddGeneratedPackageNames();
- }
- else
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error while execution CPackRPM.cmake" << std::endl);
+ } else {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackRPM.cmake"
+ << std::endl);
retval = 0;
- }
+ }
return retval;
}
int cmCPackRPMGenerator::PackageFiles()
{
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: "
- << toplevel << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " << toplevel << std::endl);
/* Are we in the component packaging case */
if (WantsComponentInstallation()) {
// CASE 1 : COMPONENT ALL-IN-ONE package
// If ALL COMPONENTS in ONE package has been requested
// then the package file is unique and should be open here.
- if (componentPackageMethod == ONE_PACKAGE)
- {
+ if (componentPackageMethod == ONE_PACKAGE) {
return PackageComponentsAllInOne("ALL_COMPONENTS_IN_ONE");
- }
+ }
// CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one)
// There will be 1 package for each component group
// however one may require to ignore component group and
// in this case you'll get 1 package for each component.
- else
- {
+ else {
return PackageComponents(componentPackageMethod ==
ONE_PACKAGE_PER_COMPONENT);
- }
+ }
}
// CASE 3 : NON COMPONENT package.
- else
- {
+ else {
return PackageComponentsAllInOne("");
- }
+ }
}
bool cmCPackRPMGenerator::SupportsComponentInstallation() const
- {
- if (IsOn("CPACK_RPM_COMPONENT_INSTALL"))
- {
- return true;
- }
- else
- {
- return false;
- }
+{
+ if (IsOn("CPACK_RPM_COMPONENT_INSTALL")) {
+ return true;
+ } else {
+ return false;
}
+}
std::string cmCPackRPMGenerator::GetComponentInstallDirNameSuffix(
- const std::string& componentName)
- {
+ const std::string& componentName)
+{
if (componentPackageMethod == ONE_PACKAGE_PER_COMPONENT) {
return componentName;
}
@@ -276,14 +247,11 @@ std::string cmCPackRPMGenerator::GetComponentInstallDirNameSuffix(
}
// We have to find the name of the COMPONENT GROUP
// the current COMPONENT belongs to.
- std::string groupVar = "CPACK_COMPONENT_" +
- cmSystemTools::UpperCase(componentName) + "_GROUP";
- if (NULL != GetOption(groupVar))
- {
- return std::string(GetOption(groupVar));
- }
- else
- {
- return componentName;
- }
+ std::string groupVar =
+ "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
+ if (NULL != GetOption(groupVar)) {
+ return std::string(GetOption(groupVar));
+ } else {
+ return componentName;
}
+}