summaryrefslogtreecommitdiff
path: root/Source/CPack/cmCPackRPMGenerator.cxx
diff options
context:
space:
mode:
authorEric NOULARD <eric.noulard@gmail.com>2010-11-13 17:56:36 +0100
committerEric NOULARD <eric.noulard@gmail.com>2010-11-13 17:56:36 +0100
commit2c84d169b36b1b8713517a8d8799b82dbf59725a (patch)
tree13cef3ebb30eda89fd3907c7b098cb4c8f2b8de9 /Source/CPack/cmCPackRPMGenerator.cxx
parentd95017deec954ad81253c9d545eaeb323c52ac0e (diff)
downloadcmake-2c84d169b36b1b8713517a8d8799b82dbf59725a.tar.gz
CPackRPM add basic component support to CPackRPM
basic means 1 RPM per component and no dependency handling this implies some CPackGenerator refactoring
Diffstat (limited to 'Source/CPack/cmCPackRPMGenerator.cxx')
-rw-r--r--Source/CPack/cmCPackRPMGenerator.cxx59
1 files changed, 56 insertions, 3 deletions
diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx
index 0641418b4c..a06b626777 100644
--- a/Source/CPack/cmCPackRPMGenerator.cxx
+++ b/Source/CPack/cmCPackRPMGenerator.cxx
@@ -37,13 +37,66 @@ int cmCPackRPMGenerator::InitializeInternal()
//----------------------------------------------------------------------
int cmCPackRPMGenerator::PackageFiles()
{
- this->ReadListFile("CPackRPM.cmake");
+ int retval = 1;
+ /* Digest Component grouping specification */
+ retval = PrepareGroupingKind();
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: "
+ << toplevel << std::endl);
+
+ /* Are we in the component packaging case */
+ if (!this->ComponentGroups.empty())
+ {
+ /* Reset package file name list it will be populated during the
+ * component packaging run*/
+ packageFileNames.clear();
+ std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
+ /* One Package per component CASE */
+ /* Iterate over components */
+ std::map<std::string, cmCPackComponent>::iterator compIt;
+ for (compIt=this->Components.begin();
+ compIt!=this->Components.end(); ++compIt )
+ {
+ std::string localToplevel(initialTopLevel);
+ std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel.c_str()));
+ std::string outputFileName(std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))
+ +"-"+compIt->first + this->GetOutputExtension());
+
+ localToplevel += "/"+ compIt->first;
+ /* replace the TEMP DIRECTORY with the component one */
+ 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());
+ /* replace the TEMPORARY package file name */
+ this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME",packageFileName.c_str());
+
+ this->SetOption("CPACK_RPM_PACKAGE_COMPONENT",compIt->first.c_str());
+ if (!this->ReadListFile("CPackRPM.cmake"))
+ {
+ 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);
+ }
+ }
+ /* This is the non component case */
+ 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);
- return 0;
+ retval = 0;
}
- return 1;
+ return retval;
}