summaryrefslogtreecommitdiffstats
path: root/Source/CPack/cmCPackRPMGenerator.cxx
diff options
context:
space:
mode:
authorDomen Vrankar <domen.vrankar@gmail.com>2016-05-15 01:01:34 (GMT)
committerDomen Vrankar <domen.vrankar@gmail.com>2016-05-15 01:01:34 (GMT)
commit44ee2d717a0f0552d4d1d5978c473d60625a0b3c (patch)
tree058d32470b4afd1e3b37c411db51fd90347c6c50 /Source/CPack/cmCPackRPMGenerator.cxx
parentb952336902e9206ba51e1d77b8e489bdd759f73f (diff)
downloadCMake-44ee2d717a0f0552d4d1d5978c473d60625a0b3c.zip
CMake-44ee2d717a0f0552d4d1d5978c473d60625a0b3c.tar.gz
CMake-44ee2d717a0f0552d4d1d5978c473d60625a0b3c.tar.bz2
CPack/RPM different package names
Packagers may now set their own rpm package file names or request that rpmbuild tool chooses one for them. It also supports handing of situations where one spec file may produce multiple rpm packages.
Diffstat (limited to 'Source/CPack/cmCPackRPMGenerator.cxx')
-rw-r--r--Source/CPack/cmCPackRPMGenerator.cxx72
1 files changed, 42 insertions, 30 deletions
diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx
index 6349e05..2640404 100644
--- a/Source/CPack/cmCPackRPMGenerator.cxx
+++ b/Source/CPack/cmCPackRPMGenerator.cxx
@@ -47,6 +47,22 @@ int cmCPackRPMGenerator::InitializeInternal()
return this->Superclass::InitializeInternal();
}
+void cmCPackRPMGenerator::AddGeneratedPackageNames()
+{
+ // add the generated packages to package file names list
+ 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));
+}
+
int cmCPackRPMGenerator::PackageOnePack(std::string initialToplevel,
std::string packageName)
{
@@ -85,8 +101,7 @@ int cmCPackRPMGenerator::PackageOnePack(std::string initialToplevel,
"Error while execution CPackRPM.cmake" << std::endl);
retval = 0;
}
- // add the generated package to package file names list
- packageFileNames.push_back(packageFileName);
+
return retval;
}
@@ -139,20 +154,24 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
retval &= PackageOnePack(initialTopLevel,compIt->first);
}
}
+
+ if(retval)
+ {
+ AddGeneratedPackageNames();
+ }
+
return retval;
}
-int cmCPackRPMGenerator::PackageComponentsAllInOne()
+int cmCPackRPMGenerator::PackageComponentsAllInOne(
+ const std::string& compInstDirName)
{
int retval = 1;
- std::string compInstDirName;
/* Reset package file name list it will be populated during the
* component packaging run*/
packageFileNames.clear();
std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
- compInstDirName = "ALL_COMPONENTS_IN_ONE";
-
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Packaging all groups in one package..."
"(CPACK_COMPONENTS_ALL_[GROUPS_]IN_ONE_PACKAGE is set)"
@@ -178,27 +197,32 @@ int cmCPackRPMGenerator::PackageComponentsAllInOne()
/* replace the TEMPORARY package file name */
this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME",
packageFileName.c_str());
- // 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(!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"))
+ {
+ AddGeneratedPackageNames();
+ }
+ else
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error while execution CPackRPM.cmake" << std::endl);
retval = 0;
}
- // add the generated package to package file names list
- packageFileNames.push_back(packageFileName);
return retval;
}
int cmCPackRPMGenerator::PackageFiles()
{
- int retval = 1;
-
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: "
<< toplevel << std::endl);
@@ -209,7 +233,7 @@ int cmCPackRPMGenerator::PackageFiles()
// then the package file is unique and should be open here.
if (componentPackageMethod == ONE_PACKAGE)
{
- return PackageComponentsAllInOne();
+ 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
@@ -224,20 +248,8 @@ int cmCPackRPMGenerator::PackageFiles()
// CASE 3 : NON COMPONENT package.
else
{
- if (!this->ReadListFile("CPackRPM.cmake"))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error while execution CPackRPM.cmake" << std::endl);
- retval = 0;
- }
- }
-
- if (!this->IsSet("RPMBUILD_EXECUTABLE"))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find rpmbuild" << std::endl);
- retval = 0;
+ return PackageComponentsAllInOne("");
}
- return retval;
}
bool cmCPackRPMGenerator::SupportsComponentInstallation() const