summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorEric NOULARD <eric.noulard@gmail.com>2010-11-13 16:56:36 (GMT)
committerEric NOULARD <eric.noulard@gmail.com>2010-11-13 16:56:36 (GMT)
commit2c84d169b36b1b8713517a8d8799b82dbf59725a (patch)
tree13cef3ebb30eda89fd3907c7b098cb4c8f2b8de9 /Source
parentd95017deec954ad81253c9d545eaeb323c52ac0e (diff)
downloadCMake-2c84d169b36b1b8713517a8d8799b82dbf59725a.zip
CMake-2c84d169b36b1b8713517a8d8799b82dbf59725a.tar.gz
CMake-2c84d169b36b1b8713517a8d8799b82dbf59725a.tar.bz2
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')
-rw-r--r--Source/CPack/cmCPackArchiveGenerator.cxx65
-rw-r--r--Source/CPack/cmCPackArchiveGenerator.h4
-rw-r--r--Source/CPack/cmCPackGenerator.cxx84
-rw-r--r--Source/CPack/cmCPackGenerator.h25
-rw-r--r--Source/CPack/cmCPackRPMGenerator.cxx59
-rw-r--r--Source/CPack/cmCPackRPMGenerator.h1
6 files changed, 170 insertions, 68 deletions
diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx
index c86434e..424c1a0 100644
--- a/Source/CPack/cmCPackArchiveGenerator.cxx
+++ b/Source/CPack/cmCPackArchiveGenerator.cxx
@@ -105,12 +105,12 @@ if (!archive) \
}
//----------------------------------------------------------------------
-int cmCPackArchiveGenerator::PackageComponents(bool ignoreComponentGroup)
+int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup)
{
packageFileNames.clear();
// The default behavior is to have one package by component group
// unless CPACK_COMPONENTS_IGNORE_GROUP is specified.
- if (!ignoreComponentGroup)
+ if (!ignoreGroup)
{
std::map<std::string, cmCPackComponentGroup>::iterator compGIt;
for (compGIt=this->ComponentGroups.begin();
@@ -170,7 +170,7 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreComponentGroup)
}
//----------------------------------------------------------------------
-int cmCPackArchiveGenerator::PackageComponentsAllInOne(bool allComponentInOne)
+int cmCPackArchiveGenerator::PackageComponentsAllInOne(bool allComponent)
{
// reset the package file names
packageFileNames.clear();
@@ -185,7 +185,7 @@ int cmCPackArchiveGenerator::PackageComponentsAllInOne(bool allComponentInOne)
DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0],archive);
// The ALL GROUP in ONE package case
- if (! allComponentInOne) {
+ if (! allComponent) {
// iterate over the component groups
std::map<std::string, cmCPackComponentGroup>::iterator compGIt;
for (compGIt=this->ComponentGroups.begin();
@@ -226,63 +226,8 @@ int cmCPackArchiveGenerator::PackageFiles()
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: "
<< toplevel << std::endl);
- // The default behavior is to create 1 package by component group
- // unless the user asked to put all COMPONENTS in a single package
- bool allGroupInOne = (NULL !=
- (this->GetOption(
- "CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE")));
- bool allComponentInOne = (NULL !=
- (this->GetOption(
- "CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE")));
- bool ignoreComponentGroup = ( NULL !=
- (this->GetOption(
- "CPACK_COMPONENTS_IGNORE_GROUPS")));
+ PrepareGroupingKind();
- std::string groupingType;
-
- // Second way to specify grouping
- if (NULL != this->GetOption("CPACK_COMPONENTS_GROUPING")) {
- groupingType = this->GetOption("CPACK_COMPONENTS_GROUPING");
- }
-
- if (groupingType.length()>0)
- {
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "["
- << this->Name << "]"
- << " requested component grouping = "<< groupingType <<std::endl);
- if (groupingType == "ALL_GROUP_IN_ONE")
- {
- allGroupInOne = true;
- }
- else if (groupingType == "ALL_COMPONENT_IN_ONE")
- {
- allComponentInOne = true;
- }
- else if (groupingType == "IGNORE")
- {
- ignoreComponentGroup = true;
- }
- else
- {
- cmCPackLogger(cmCPackLog::LOG_WARNING, "["
- << this->Name << "]"
- << " requested component grouping type <"<< groupingType
- << "> UNKNOWN not in (ALL_GROUP_IN_ONE,"
- "ALL_COMPONENT_IN_ONE,IGNORE)" <<std::endl);
- }
- }
-
- // Some components were defined but NO group
- // force ignoreGroups
- if (this->ComponentGroups.empty() && (!this->Components.empty())
- && (!ignoreComponentGroup)) {
- cmCPackLogger(cmCPackLog::LOG_WARNING, "["
- << this->Name << "]"
- << " Some Components defined but NO component group:"
- << " Ignoring component group."
- << std::endl);
- ignoreComponentGroup = true;
- }
// CASE 1 : COMPONENT ALL-IN-ONE package
// If ALL GROUPS or ALL COMPONENTS in ONE package has been requested
// then the package file is unique and should be open here.
diff --git a/Source/CPack/cmCPackArchiveGenerator.h b/Source/CPack/cmCPackArchiveGenerator.h
index 6e173bd..dc17257 100644
--- a/Source/CPack/cmCPackArchiveGenerator.h
+++ b/Source/CPack/cmCPackArchiveGenerator.h
@@ -60,12 +60,12 @@ protected:
* install is used. This will create one
* archive for each component group.
*/
- int PackageComponents(bool ignoreComponentGroup);
+ int PackageComponents(bool ignoreGroup);
/**
* Special case of component install where all
* components will be put in a single installer.
*/
- int PackageComponentsAllInOne(bool allComponentInOne);
+ int PackageComponentsAllInOne(bool allComponent);
virtual const char* GetOutputExtension() = 0;
cmArchiveWrite::Compress Compress;
cmArchiveWrite::Type Archive;
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index c39aea4..d9f2b47 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -35,6 +35,9 @@ cmCPackGenerator::cmCPackGenerator()
this->GeneratorVerbose = false;
this->MakefileMap = 0;
this->Logger = 0;
+ this->allGroupInOne = false;
+ this->allComponentInOne = false;
+ this->ignoreComponentGroup = false;
}
//----------------------------------------------------------------------
@@ -220,7 +223,7 @@ 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 packageing
+ // This is used in Source packaging
if ( !this->InstallProjectViaInstalledDirectories(
setDestDir, tempInstallDirectory) )
{
@@ -691,7 +694,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
//
// If DESTDIR has been 'internally set ON' this means that
// the underlying CPack specific generator did ask for that
- // In this case we may overrode CPACK_INSTALL_PREFIX with
+ // In this case we may override CPACK_INSTALL_PREFIX with
// CPACK_PACKAGING_INSTALL_PREFIX
// I know this is tricky and awkward but it's the price for
// CPACK_SET_DESTDIR backward compatibility.
@@ -727,7 +730,18 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
{
dir = tempInstallDirectory + "/" + dir;
}
-
+ /*
+ * We must re-set DESTDIR for each component
+ * We must not add the CPACK_INSTALL_PREFIX part because
+ * it will be added using the override of CMAKE_INSTALL_PREFIX
+ * The main reason for this awkward trick is that
+ * are using DESTDIR for 2 different reasons:
+ * - Because it was asked by the CPack Generator or the user
+ * using CPACK_SET_DESTDIR
+ * - Because it was already used for component install
+ * in order to put things in subdirs...
+ */
+ cmSystemTools::PutEnv((std::string("DESTDIR=")+tempInstallDirectory).c_str());
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"- Creating directory: '" << dir << "'" << std::endl);
@@ -1196,6 +1210,70 @@ int cmCPackGenerator::CleanTemporaryDirectory()
}
//----------------------------------------------------------------------
+int cmCPackGenerator::PrepareGroupingKind()
+{
+ // The default behavior is to create 1 package by component group
+ // unless the user asked to put all COMPONENTS in a single package
+ allGroupInOne = (NULL !=
+ (this->GetOption(
+ "CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE")));
+ allComponentInOne = (NULL !=
+ (this->GetOption(
+ "CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE")));
+ ignoreComponentGroup = (NULL !=
+ (this->GetOption(
+ "CPACK_COMPONENTS_IGNORE_GROUPS")));
+
+ std::string groupingType;
+
+ // Second way to specify grouping
+ if (NULL != this->GetOption("CPACK_COMPONENTS_GROUPING")) {
+ groupingType = this->GetOption("CPACK_COMPONENTS_GROUPING");
+ }
+
+ if (groupingType.length()>0)
+ {
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE, "["
+ << this->Name << "]"
+ << " requested component grouping = "<< groupingType <<std::endl);
+ if (groupingType == "ALL_GROUP_IN_ONE")
+ {
+ allGroupInOne = true;
+ }
+ else if (groupingType == "ALL_COMPONENT_IN_ONE")
+ {
+ allComponentInOne = true;
+ }
+ else if (groupingType == "IGNORE")
+ {
+ ignoreComponentGroup = true;
+ }
+ else
+ {
+ cmCPackLogger(cmCPackLog::LOG_WARNING, "["
+ << this->Name << "]"
+ << " requested component grouping type <"<< groupingType
+ << "> UNKNOWN not in (ALL_GROUP_IN_ONE,"
+ "ALL_COMPONENT_IN_ONE,IGNORE)" <<std::endl);
+ }
+ }
+
+ // Some components were defined but NO group
+ // force ignoreGroups
+ if (this->ComponentGroups.empty() && (!this->Components.empty())
+ && (!ignoreComponentGroup)) {
+ cmCPackLogger(cmCPackLog::LOG_WARNING, "["
+ << this->Name << "]"
+ << " Some Components defined but NO component group:"
+ << " Ignoring component group."
+ << std::endl);
+ ignoreComponentGroup = true;
+ }
+
+ return 1;
+}
+
+//----------------------------------------------------------------------
bool cmCPackGenerator::SupportsComponentInstallation() const
{
return false;
diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h
index 74b780d..c450763 100644
--- a/Source/CPack/cmCPackGenerator.h
+++ b/Source/CPack/cmCPackGenerator.h
@@ -120,6 +120,17 @@ protected:
virtual const char* GetOutputPostfix() { return 0; }
/**
+ * Prepare requested grouping kind from CPACK_xxx vars
+ * CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE
+ * CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE
+ * CPACK_COMPONENTS_IGNORE_GROUPS
+ * or
+ * CPACK_COMPONENTS_GROUPING
+ * @return 1 on success 0 on failure.
+ */
+ virtual int PrepareGroupingKind();
+
+ /**
* Package the list of files and/or components which
* has been prepared by the beginning of DoPackage.
* @pre @ref toplevel has been filled-in
@@ -200,6 +211,20 @@ protected:
*/
std::map<std::string, cmCPackComponent> Components;
std::map<std::string, cmCPackComponentGroup> ComponentGroups;
+ /**
+ * If true All component groups will be put in a single package.
+ */
+ bool allGroupInOne;
+ /**
+ * If true All component will be put in a single package.
+ */
+ bool allComponentInOne;
+ /**
+ * If true component grouping will be ignored.
+ * You will still get 1 package for each component unless
+ * allComponentInOne is true.
+ */
+ bool ignoreComponentGroup;
cmCPackLog* Logger;
private:
diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx
index 0641418..a06b626 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;
}
diff --git a/Source/CPack/cmCPackRPMGenerator.h b/Source/CPack/cmCPackRPMGenerator.h
index 570e45f..9063ea7 100644
--- a/Source/CPack/cmCPackRPMGenerator.h
+++ b/Source/CPack/cmCPackRPMGenerator.h
@@ -39,6 +39,7 @@ protected:
virtual int InitializeInternal();
virtual int PackageFiles();
virtual const char* GetOutputExtension() { return ".rpm"; }
+ virtual bool SupportsComponentInstallation() const {return true;}
};