CPack fix #11930 and simplifies component packaging options

This commit is contained in:
Eric NOULARD 2011-03-23 18:28:05 +01:00
parent 4344e83fcf
commit 6dfc818394
11 changed files with 193 additions and 303 deletions

View File

@ -207,7 +207,7 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCPackArchiveGenerator::PackageComponentsAllInOne(bool allComponent) int cmCPackArchiveGenerator::PackageComponentsAllInOne()
{ {
// reset the package file names // reset the package file names
packageFileNames.clear(); packageFileNames.clear();
@ -221,30 +221,7 @@ int cmCPackArchiveGenerator::PackageComponentsAllInOne(bool allComponent)
<< std::endl); << std::endl);
DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0],archive); DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0],archive);
// The ALL GROUP in ONE package case // The ALL COMPONENTS in ONE package case
if (! allComponent) {
// iterate over the component groups
std::map<std::string, cmCPackComponentGroup>::iterator compGIt;
for (compGIt=this->ComponentGroups.begin();
compGIt!=this->ComponentGroups.end(); ++compGIt)
{
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: "
<< compGIt->first
<< std::endl);
// now iterate over the component of this group
std::vector<cmCPackComponent*>::iterator compIt;
for (compIt=(compGIt->second).Components.begin();
compIt!=(compGIt->second).Components.end();
++compIt)
{
// Add the files of this component to the archive
addOneComponentToArchive(archive,*compIt);
}
}
}
// The ALL COMPONENT in ONE package case
else
{
std::map<std::string, cmCPackComponent>::iterator compIt; std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt=this->Components.begin();compIt!=this->Components.end(); for (compIt=this->Components.begin();compIt!=this->Components.end();
++compIt ) ++compIt )
@ -252,7 +229,7 @@ int cmCPackArchiveGenerator::PackageComponentsAllInOne(bool allComponent)
// Add the files of this component to the archive // Add the files of this component to the archive
addOneComponentToArchive(archive,&(compIt->second)); addOneComponentToArchive(archive,&(compIt->second));
} }
}
// archive goes out of scope so it will finalized and closed. // archive goes out of scope so it will finalized and closed.
return 1; return 1;
} }
@ -265,19 +242,17 @@ int cmCPackArchiveGenerator::PackageFiles()
if (SupportsComponentInstallation()) { if (SupportsComponentInstallation()) {
// CASE 1 : COMPONENT ALL-IN-ONE package // CASE 1 : COMPONENT ALL-IN-ONE package
// If ALL GROUPS or ALL COMPONENTS in ONE package has been requested // If ALL COMPONENTS in ONE package has been requested
// then the package file is unique and should be open here. // then the package file is unique and should be open here.
if (allComponentInOne || if (allComponentInOne)
(allGroupInOne && (!this->ComponentGroups.empty()))
)
{ {
return PackageComponentsAllInOne(allComponentInOne); return PackageComponentsAllInOne();
} }
// CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one) // CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one)
// There will be 1 package for each component group // There will be 1 package for each component group
// however one may require to ignore component group and // however one may require to ignore component group and
// in this case you'll get 1 package for each component. // in this case you'll get 1 package for each component.
else if ((!this->ComponentGroups.empty()) || (ignoreComponentGroup)) else
{ {
return PackageComponents(ignoreComponentGroup); return PackageComponents(ignoreComponentGroup);
} }

View File

@ -65,7 +65,7 @@ protected:
* Special case of component install where all * Special case of component install where all
* components will be put in a single installer. * components will be put in a single installer.
*/ */
int PackageComponentsAllInOne(bool allComponent); int PackageComponentsAllInOne();
virtual const char* GetOutputExtension() = 0; virtual const char* GetOutputExtension() = 0;
cmArchiveWrite::Compress Compress; cmArchiveWrite::Compress Compress;
cmArchiveWrite::Type Archive; cmArchiveWrite::Type Archive;

View File

@ -50,6 +50,62 @@ int cmCPackDebGenerator::InitializeInternal()
return this->Superclass::InitializeInternal(); return this->Superclass::InitializeInternal();
} }
//----------------------------------------------------------------------
int cmCPackDebGenerator::PackageOnePack(std::string initialTopLevel,
std::string packageName)
{
int retval = 1;
// Begin the archive for this pack
std::string localToplevel(initialTopLevel);
std::string packageFileName(
cmSystemTools::GetParentDirectory(toplevel.c_str())
);
std::string outputFileName(
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))
+"-"+packageName + this->GetOutputExtension()
);
localToplevel += "/"+ packageName;
/* 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());
// Tell CPackDeb.cmake the name of the component GROUP.
this->SetOption("CPACK_DEB_PACKAGE_COMPONENT",packageName.c_str());
if (!this->ReadListFile("CPackDeb.cmake"))
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error while execution CPackDeb.cmake" << std::endl);
retval = 0;
return retval;
}
cmsys::Glob gl;
std::string findExpr(this->GetOption("WDIR"));
findExpr += "/*";
gl.RecurseOn();
if ( !gl.FindFiles(findExpr) )
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot find any files in the installed directory" << std::endl);
return 0;
}
packageFiles = gl.GetFiles();
int res = createDeb();
if (res != 1)
{
retval = 0;
}
// add the generated package to package file names list
packageFileNames.push_back(packageFileName);
return retval;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCPackDebGenerator::PackageComponents(bool ignoreGroup) int cmCPackDebGenerator::PackageComponents(bool ignoreGroup)
{ {
@ -71,53 +127,24 @@ int cmCPackDebGenerator::PackageComponents(bool ignoreGroup)
<< compGIt->first << compGIt->first
<< std::endl); << std::endl);
// Begin the archive for this group // Begin the archive for this group
std::string localToplevel(initialTopLevel); retval &= PackageOnePack(initialTopLevel,compGIt->first);
std::string packageFileName(
cmSystemTools::GetParentDirectory(toplevel.c_str())
);
std::string outputFileName(
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))
+"-"+compGIt->first + this->GetOutputExtension()
);
localToplevel += "/"+ compGIt->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());
// Tell CPackDeb.cmake the name of the component GROUP.
this->SetOption("CPACK_DEB_PACKAGE_COMPONENT",compGIt->first.c_str());
if (!this->ReadListFile("CPackDeb.cmake"))
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error while execution CPackDeb.cmake" << std::endl);
retval = 0;
return retval;
} }
// Handle Orphan components (components not belonging to any groups)
cmsys::Glob gl; std::map<std::string, cmCPackComponent>::iterator compIt;
std::string findExpr(this->GetOption("WDIR")); for (compIt=this->Components.begin();
findExpr += "/*"; compIt!=this->Components.end(); ++compIt )
gl.RecurseOn();
if ( !gl.FindFiles(findExpr) )
{ {
cmCPackLogger(cmCPackLog::LOG_ERROR, // Does the component belong to a group?
"Cannot find any files in the installed directory" << std::endl); if (compIt->second.Group==NULL)
return 0;
}
packageFiles = gl.GetFiles();
int res = createDeb();
if (res != 1)
{ {
retval = 0; cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Component <"
<< compIt->second.Name
<< "> does not belong to any group, package it separately."
<< std::endl);
// Begin the archive for this orphan component
retval &= PackageOnePack(initialTopLevel,compIt->first);
} }
// add the generated package to package file names list
packageFileNames.push_back(packageFileName);
} }
} }
// CPACK_COMPONENTS_IGNORE_GROUPS is set // CPACK_COMPONENTS_IGNORE_GROUPS is set
@ -128,59 +155,14 @@ int cmCPackDebGenerator::PackageComponents(bool ignoreGroup)
for (compIt=this->Components.begin(); for (compIt=this->Components.begin();
compIt!=this->Components.end(); ++compIt ) compIt!=this->Components.end(); ++compIt )
{ {
std::string localToplevel(initialTopLevel); retval &= PackageOnePack(initialTopLevel,compIt->first);
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_DEB_PACKAGE_COMPONENT",compIt->first.c_str());
if (!this->ReadListFile("CPackDeb.cmake"))
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error while execution CPackDeb.cmake" << std::endl);
retval = 0;
return retval;
}
cmsys::Glob gl;
std::string findExpr(this->GetOption("WDIR"));
findExpr += "/*";
gl.RecurseOn();
if ( !gl.FindFiles(findExpr) )
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot find any files in the installed directory" << std::endl);
return 0;
}
packageFiles = gl.GetFiles();
int res = createDeb();
if (res != 1)
{
retval = 0;
}
// add the generated package to package file names list
packageFileNames.push_back(packageFileName);
} }
} }
return retval; return retval;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCPackDebGenerator::PackageComponentsAllInOne(bool allComponent) int cmCPackDebGenerator::PackageComponentsAllInOne()
{ {
int retval = 1; int retval = 1;
std::string compInstDirName; std::string compInstDirName;
@ -189,15 +171,7 @@ int cmCPackDebGenerator::PackageComponentsAllInOne(bool allComponent)
packageFileNames.clear(); packageFileNames.clear();
std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY")); std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
// all GROUP in one vs all COMPONENT in one
if (allComponent)
{
compInstDirName = "ALL_COMPONENTS_IN_ONE"; compInstDirName = "ALL_COMPONENTS_IN_ONE";
}
else
{
compInstDirName = "ALL_GROUPS_IN_ONE";
}
cmCPackLogger(cmCPackLog::LOG_VERBOSE, cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Packaging all groups in one package..." "Packaging all groups in one package..."
@ -266,17 +240,15 @@ int cmCPackDebGenerator::PackageFiles()
// CASE 1 : COMPONENT ALL-IN-ONE package // CASE 1 : COMPONENT ALL-IN-ONE package
// If ALL GROUPS or ALL COMPONENTS in ONE package has been requested // If ALL GROUPS or ALL COMPONENTS in ONE package has been requested
// then the package file is unique and should be open here. // then the package file is unique and should be open here.
if (allComponentInOne || if (allComponentInOne)
(allGroupInOne && (!this->ComponentGroups.empty()))
)
{ {
return PackageComponentsAllInOne(allComponentInOne); return PackageComponentsAllInOne();
} }
// CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one) // CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one)
// There will be 1 package for each component group // There will be 1 package for each component group
// however one may require to ignore component group and // however one may require to ignore component group and
// in this case you'll get 1 package for each component. // in this case you'll get 1 package for each component.
else if ((!this->ComponentGroups.empty()) || (ignoreComponentGroup)) else
{ {
return PackageComponents(ignoreComponentGroup); return PackageComponents(ignoreComponentGroup);
} }
@ -600,16 +572,9 @@ std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix(
std::string groupVar = "CPACK_COMPONENT_" + std::string groupVar = "CPACK_COMPONENT_" +
cmSystemTools::UpperCase(componentName) + "_GROUP"; cmSystemTools::UpperCase(componentName) + "_GROUP";
if (NULL != GetOption(groupVar.c_str())) if (NULL != GetOption(groupVar.c_str()))
{
if (allGroupInOne)
{
return std::string("ALL_GROUPS_IN_ONE");
}
else
{ {
return std::string(GetOption(groupVar.c_str())); return std::string(GetOption(groupVar.c_str()));
} }
}
else else
{ {
return componentName; return componentName;

View File

@ -33,6 +33,10 @@ public:
protected: protected:
virtual int InitializeInternal(); virtual int InitializeInternal();
/**
* This method factors out the work done in component packaging case.
*/
int PackageOnePack(std::string initialToplevel, std::string packageName);
/** /**
* The method used to package files when component * The method used to package files when component
* install is used. This will create one * install is used. This will create one
@ -43,7 +47,7 @@ protected:
* Special case of component install where all * Special case of component install where all
* components will be put in a single installer. * components will be put in a single installer.
*/ */
int PackageComponentsAllInOne(bool allComponent); int PackageComponentsAllInOne();
virtual int PackageFiles(); virtual int PackageFiles();
virtual const char* GetOutputExtension() { return ".deb"; } virtual const char* GetOutputExtension() { return ".deb"; }
virtual bool SupportsComponentInstallation() const; virtual bool SupportsComponentInstallation() const;

View File

@ -36,7 +36,6 @@ cmCPackGenerator::cmCPackGenerator()
this->GeneratorVerbose = false; this->GeneratorVerbose = false;
this->MakefileMap = 0; this->MakefileMap = 0;
this->Logger = 0; this->Logger = 0;
this->allGroupInOne = false;
this->allComponentInOne = false; this->allComponentInOne = false;
this->ignoreComponentGroup = false; this->ignoreComponentGroup = false;
} }
@ -1266,15 +1265,12 @@ int cmCPackGenerator::PrepareGroupingKind()
{ {
// The default behavior is to create 1 package by component group // The default behavior is to create 1 package by component group
// unless the user asked to put all COMPONENTS in a single package // unless the user asked to put all COMPONENTS in a single package
allGroupInOne = (NULL != allComponentInOne = (NULL != (this->GetOption(
(this->GetOption( "CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE"))
"CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE"))); );
allComponentInOne = (NULL != ignoreComponentGroup = (NULL != (this->GetOption(
(this->GetOption( "CPACK_COMPONENTS_IGNORE_GROUPS"))
"CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE"))); );
ignoreComponentGroup = (NULL !=
(this->GetOption(
"CPACK_COMPONENTS_IGNORE_GROUPS")));
std::string groupingType; std::string groupingType;
@ -1288,11 +1284,7 @@ int cmCPackGenerator::PrepareGroupingKind()
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "[" cmCPackLogger(cmCPackLog::LOG_VERBOSE, "["
<< this->Name << "]" << this->Name << "]"
<< " requested component grouping = "<< groupingType <<std::endl); << " requested component grouping = "<< groupingType <<std::endl);
if (groupingType == "ALL_GROUPS_IN_ONE") if (groupingType == "ALL_COMPONENTS_IN_ONE")
{
allGroupInOne = true;
}
else if (groupingType == "ALL_COMPONENTS_IN_ONE")
{ {
allComponentInOne = true; allComponentInOne = true;
} }
@ -1305,15 +1297,14 @@ int cmCPackGenerator::PrepareGroupingKind()
cmCPackLogger(cmCPackLog::LOG_WARNING, "[" cmCPackLogger(cmCPackLog::LOG_WARNING, "["
<< this->Name << "]" << this->Name << "]"
<< " requested component grouping type <"<< groupingType << " requested component grouping type <"<< groupingType
<< "> UNKNOWN not in (ALL_GROUPS_IN_ONE," << "> UNKNOWN not in (ALL_COMPONENTS_IN_ONE,IGNORE)"
"ALL_COMPONENTS_IN_ONE,IGNORE)" <<std::endl); << std::endl);
} }
} }
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "[" cmCPackLogger(cmCPackLog::LOG_VERBOSE, "["
<< this->Name << "]" << this->Name << "]"
<< " requested component grouping = (" << " requested component grouping = ("
<< "ALL_GROUPS_IN_ONE=" << allGroupInOne
<< ", ALL_COMPONENTS_IN_ONE=" << allComponentInOne << ", ALL_COMPONENTS_IN_ONE=" << allComponentInOne
<< ", IGNORE_GROUPS=" << ignoreComponentGroup << ", IGNORE_GROUPS=" << ignoreComponentGroup
<< ")" << ")"

View File

@ -122,7 +122,6 @@ protected:
/** /**
* Prepare requested grouping kind from CPACK_xxx vars * Prepare requested grouping kind from CPACK_xxx vars
* CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE
* CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE * CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE
* CPACK_COMPONENTS_IGNORE_GROUPS * CPACK_COMPONENTS_IGNORE_GROUPS
* or * or
@ -238,10 +237,6 @@ protected:
*/ */
std::map<std::string, cmCPackComponent> Components; std::map<std::string, cmCPackComponent> Components;
std::map<std::string, cmCPackComponentGroup> ComponentGroups; 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. * If true All component will be put in a single package.
*/ */

View File

@ -49,6 +49,45 @@ int cmCPackRPMGenerator::InitializeInternal()
return this->Superclass::InitializeInternal(); return this->Superclass::InitializeInternal();
} }
//----------------------------------------------------------------------
int cmCPackRPMGenerator::PackageOnePack(std::string initialToplevel,
std::string packageName)
{
int retval = 1;
// Begin the archive for this pack
std::string localToplevel(initialToplevel);
std::string packageFileName(
cmSystemTools::GetParentDirectory(toplevel.c_str())
);
std::string outputFileName(
GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
packageName,
true)
+ this->GetOutputExtension()
);
localToplevel += "/"+ packageName;
/* 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());
// Tell CPackRPM.cmake the name of the component NAME.
this->SetOption("CPACK_RPM_PACKAGE_COMPONENT",packageName.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);
return retval;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup) int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
{ {
@ -69,37 +108,23 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: " cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: "
<< compGIt->first << compGIt->first
<< std::endl); << std::endl);
// Begin the archive for this group retval &= PackageOnePack(initialTopLevel,compGIt->first);
std::string localToplevel(initialTopLevel); }
std::string packageFileName( // Handle Orphan components (components not belonging to any groups)
cmSystemTools::GetParentDirectory(toplevel.c_str()) std::map<std::string, cmCPackComponent>::iterator compIt;
); for (compIt=this->Components.begin();
std::string outputFileName( compIt!=this->Components.end(); ++compIt )
GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"), {
compGIt->first, // Does the component belong to a group?
true) if (compIt->second.Group==NULL)
+ this->GetOutputExtension() {
); cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Component <"
localToplevel += "/"+ compGIt->first; << compIt->second.Name
/* replace the TEMP DIRECTORY with the component one */ << "> does not belong to any group, package it separately."
this->SetOption("CPACK_TEMPORARY_DIRECTORY",localToplevel.c_str()); << std::endl);
packageFileName += "/"+ outputFileName; retval &= PackageOnePack(initialTopLevel,compIt->first);
/* 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());
// Tell CPackRPM.cmake the name of the component GROUP.
this->SetOption("CPACK_RPM_PACKAGE_COMPONENT",compGIt->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);
} }
} }
// CPACK_COMPONENTS_IGNORE_GROUPS is set // CPACK_COMPONENTS_IGNORE_GROUPS is set
@ -110,42 +135,14 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
for (compIt=this->Components.begin(); for (compIt=this->Components.begin();
compIt!=this->Components.end(); ++compIt ) compIt!=this->Components.end(); ++compIt )
{ {
std::string localToplevel(initialTopLevel); retval &= PackageOnePack(initialTopLevel,compIt->first);
std::string packageFileName(
cmSystemTools::GetParentDirectory(toplevel.c_str())
);
std::string outputFileName(
GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
compIt->first,
false)
+ 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);
} }
} }
return retval; return retval;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCPackRPMGenerator::PackageComponentsAllInOne(bool allComponent) int cmCPackRPMGenerator::PackageComponentsAllInOne()
{ {
int retval = 1; int retval = 1;
std::string compInstDirName; std::string compInstDirName;
@ -154,15 +151,7 @@ int cmCPackRPMGenerator::PackageComponentsAllInOne(bool allComponent)
packageFileNames.clear(); packageFileNames.clear();
std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY")); std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
// all GROUP in one vs all COMPONENT in one
if (allComponent)
{
compInstDirName = "ALL_COMPONENTS_IN_ONE"; compInstDirName = "ALL_COMPONENTS_IN_ONE";
}
else
{
compInstDirName = "ALL_GROUPS_IN_ONE";
}
cmCPackLogger(cmCPackLog::LOG_VERBOSE, cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Packaging all groups in one package..." "Packaging all groups in one package..."
@ -214,19 +203,17 @@ int cmCPackRPMGenerator::PackageFiles()
/* Are we in the component packaging case */ /* Are we in the component packaging case */
if (SupportsComponentInstallation()) { if (SupportsComponentInstallation()) {
// CASE 1 : COMPONENT ALL-IN-ONE package // CASE 1 : COMPONENT ALL-IN-ONE package
// If ALL GROUPS or ALL COMPONENTS in ONE package has been requested // If ALL COMPONENTS in ONE package has been requested
// then the package file is unique and should be open here. // then the package file is unique and should be open here.
if (allComponentInOne || if (allComponentInOne)
(allGroupInOne && (!this->ComponentGroups.empty()))
)
{ {
return PackageComponentsAllInOne(allComponentInOne); return PackageComponentsAllInOne();
} }
// CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one) // CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one)
// There will be 1 package for each component group // There will be 1 package for each component group
// however one may require to ignore component group and // however one may require to ignore component group and
// in this case you'll get 1 package for each component. // in this case you'll get 1 package for each component.
else if ((!this->ComponentGroups.empty()) || (ignoreComponentGroup)) else
{ {
return PackageComponents(ignoreComponentGroup); return PackageComponents(ignoreComponentGroup);
} }
@ -277,16 +264,9 @@ std::string cmCPackRPMGenerator::GetComponentInstallDirNameSuffix(
std::string groupVar = "CPACK_COMPONENT_" + std::string groupVar = "CPACK_COMPONENT_" +
cmSystemTools::UpperCase(componentName) + "_GROUP"; cmSystemTools::UpperCase(componentName) + "_GROUP";
if (NULL != GetOption(groupVar.c_str())) if (NULL != GetOption(groupVar.c_str()))
{
if (allGroupInOne)
{
return std::string("ALL_GROUPS_IN_ONE");
}
else
{ {
return std::string(GetOption(groupVar.c_str())); return std::string(GetOption(groupVar.c_str()));
} }
}
else else
{ {
return componentName; return componentName;

View File

@ -38,6 +38,10 @@ public:
protected: protected:
virtual int InitializeInternal(); virtual int InitializeInternal();
virtual int PackageFiles(); virtual int PackageFiles();
/**
* This method factors out the work done in component packaging case.
*/
int PackageOnePack(std::string initialToplevel, std::string packageName);
/** /**
* The method used to package files when component * The method used to package files when component
* install is used. This will create one * install is used. This will create one
@ -48,7 +52,7 @@ protected:
* Special case of component install where all * Special case of component install where all
* components will be put in a single installer. * components will be put in a single installer.
*/ */
int PackageComponentsAllInOne(bool allComponent); int PackageComponentsAllInOne();
virtual const char* GetOutputExtension() { return ".rpm"; } virtual const char* GetOutputExtension() { return ".rpm"; }
virtual bool SupportsComponentInstallation() const; virtual bool SupportsComponentInstallation() const;
virtual std::string GetComponentInstallDirNameSuffix( virtual std::string GetComponentInstallDirNameSuffix(

View File

@ -583,7 +583,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
list(APPEND CWAYLST "OnePackPerGroup") list(APPEND CWAYLST "OnePackPerGroup")
list(APPEND CWAYLST "IgnoreGroup") list(APPEND CWAYLST "IgnoreGroup")
list(APPEND CWAYLST "AllInOne") list(APPEND CWAYLST "AllInOne")
list(APPEND CWAYLST "AllGroupsInOne")
foreach(CPackGen ${GENLST}) foreach(CPackGen ${GENLST})
set(CPackRun_CPackGen "-DCPackGen=${CPackGen}") set(CPackRun_CPackGen "-DCPackGen=${CPackGen}")
foreach(CPackComponentWay ${CWAYLST}) foreach(CPackComponentWay ${CWAYLST})

View File

@ -1,22 +0,0 @@
#
# Activate component packaging
#
if(CPACK_GENERATOR MATCHES "ZIP")
set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON")
endif(CPACK_GENERATOR MATCHES "ZIP")
if(CPACK_GENERATOR MATCHES "RPM")
set(CPACK_RPM_COMPONENT_INSTALL "ON")
endif(CPACK_GENERATOR MATCHES "RPM")
if(CPACK_GENERATOR MATCHES "DEB")
set(CPACK_DEB_COMPONENT_INSTALL "ON")
endif(CPACK_GENERATOR MATCHES "DEB")
#
# Choose grouping way
#
set(CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE 1)
#set(CPACK_COMPONENTS_GROUPING)
#set(CPACK_COMPONENTS_IGNORE_GROUPS 1)
#set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)

View File

@ -37,38 +37,37 @@ if(CPackGen MATCHES "ZIP")
set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.zip") set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.zip")
if (${CPackComponentWay} STREQUAL "default") if (${CPackComponentWay} STREQUAL "default")
set(expected_count 1) set(expected_count 1)
endif(${CPackComponentWay} STREQUAL "default") elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup")
if (${CPackComponentWay} STREQUAL "OnePackPerGroup")
set(expected_count 3) set(expected_count 3)
endif (${CPackComponentWay} STREQUAL "OnePackPerGroup") elseif (${CPackComponentWay} STREQUAL "IgnoreGroup")
if (${CPackComponentWay} STREQUAL "IgnoreGroup")
set(expected_count 4) set(expected_count 4)
endif (${CPackComponentWay} STREQUAL "IgnoreGroup") elseif (${CPackComponentWay} STREQUAL "AllInOne")
if (${CPackComponentWay} STREQUAL "AllInOne")
set(expected_count 1) set(expected_count 1)
endif (${CPackComponentWay} STREQUAL "AllInOne") endif ()
if (${CPackComponentWay} STREQUAL "AllGroupsInOne")
set(expected_count 1)
endif (${CPackComponentWay} STREQUAL "AllGroupsInOne")
elseif (CPackGen MATCHES "RPM") elseif (CPackGen MATCHES "RPM")
set(config_verbose -D "CPACK_RPM_PACKAGE_DEBUG=1") set(config_verbose -D "CPACK_RPM_PACKAGE_DEBUG=1")
set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.rpm") set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.rpm")
if (${CPackComponentWay} STREQUAL "default") if (${CPackComponentWay} STREQUAL "default")
set(expected_count 1) set(expected_count 1)
endif (${CPackComponentWay} STREQUAL "default") elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup")
if (${CPackComponentWay} STREQUAL "OnePackPerGroup") set(expected_count 3)
set(expected_count 2) elseif (${CPackComponentWay} STREQUAL "IgnoreGroup")
endif (${CPackComponentWay} STREQUAL "OnePackPerGroup")
if (${CPackComponentWay} STREQUAL "IgnoreGroup")
set(expected_count 4) set(expected_count 4)
endif (${CPackComponentWay} STREQUAL "IgnoreGroup") elseif (${CPackComponentWay} STREQUAL "AllInOne")
if (${CPackComponentWay} STREQUAL "AllInOne")
set(expected_count 1) set(expected_count 1)
endif (${CPackComponentWay} STREQUAL "AllInOne") endif ()
if (${CPackComponentWay} STREQUAL "AllGroupsInOne") elseif (CPackGen MATCHES "DEB")
set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.deb")
if (${CPackComponentWay} STREQUAL "default")
set(expected_count 1) set(expected_count 1)
endif (${CPackComponentWay} STREQUAL "AllGroupsInOne") elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup")
endif(CPackGen MATCHES "ZIP") set(expected_count 3)
elseif (${CPackComponentWay} STREQUAL "IgnoreGroup")
set(expected_count 4)
elseif (${CPackComponentWay} STREQUAL "AllInOne")
set(expected_count 1)
endif ()
endif()
# clean-up previously CPack generated files # clean-up previously CPack generated files
if(expected_file_mask) if(expected_file_mask)