diff options
Diffstat (limited to 'Source/CPack/cmCPackGenerator.cxx')
-rw-r--r-- | Source/CPack/cmCPackGenerator.cxx | 155 |
1 files changed, 121 insertions, 34 deletions
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index feda52c..5f314c6 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -24,6 +24,7 @@ #include <cmsys/SystemTools.hxx> #include <cmsys/Glob.hxx> #include <memory> // auto_ptr +#include <algorithm> #if defined(__HAIKU__) #include <StorageKit.h> @@ -684,7 +685,14 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( if (componentInstall) { tempInstallDirectory += "/"; - tempInstallDirectory += installComponent; + // Some CPack generators would rather chose + // the local installation directory suffix. + // Some (e.g. RPM) use + // one install directory for each component **GROUP** + // instead of the default + // one install directory for each component. + tempInstallDirectory += + GetComponentInstallDirNameSuffix(installComponent); } if (!setDestDir) @@ -803,7 +811,55 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( { mf->AddDefinition("CMAKE_INSTALL_DO_STRIP", "1"); } + // Remember the list of files before installation + // of the current component (if we are in component install) + const char* InstallPrefix = tempInstallDirectory.c_str(); + std::vector<std::string> filesBefore; + std::string findExpr(InstallPrefix); + if (componentInstall) + { + cmsys::Glob glB; + findExpr += "/*"; + glB.RecurseOn(); + glB.FindFiles(findExpr); + filesBefore = glB.GetFiles(); + std::sort(filesBefore.begin(),filesBefore.end()); + } + // do installation int res = mf->ReadListFile(0, installFile.c_str()); + // Now rebuild the list of files after installation + // of the current component (if we are in component install) + if (componentInstall) + { + cmsys::Glob glA; + glA.RecurseOn(); + glA.FindFiles(findExpr); + std::vector<std::string> filesAfter = glA.GetFiles(); + std::sort(filesAfter.begin(),filesAfter.end()); + std::vector<std::string>::iterator diff; + std::vector<std::string> result(filesAfter.size()); + diff = std::set_difference ( + filesAfter.begin(),filesAfter.end(), + filesBefore.begin(),filesBefore.end(), + result.begin()); + + std::vector<std::string>::iterator fit; + std::string localFileName; + // Populate the File field of each component + for (fit=result.begin();fit!=diff;++fit) + { + localFileName = + cmSystemTools::RelativePath(InstallPrefix, fit->c_str()); + localFileName = + localFileName.substr(localFileName.find('/')+1, + std::string::npos); + Components[installComponent].Files.push_back(localFileName); + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Adding file <" + <<localFileName<<"> to component <" + <<installComponent<<">"<<std::endl); + } + } + if (NULL !=mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) { if (absoluteDestFiles.length()>0) { absoluteDestFiles +=";"; @@ -873,6 +929,12 @@ int cmCPackGenerator::DoPackage() return 0; } + // Digest Component grouping specification + if ( !this->PrepareGroupingKind() ) + { + return 0; + } + if ( cmSystemTools::IsOn( this->GetOption("CPACK_REMOVE_TOPLEVEL_DIRECTORY")) ) { @@ -939,35 +1001,6 @@ int cmCPackGenerator::DoPackage() // The files to be installed files = gl.GetFiles(); - // For component installations, determine which files go into which - // components. - if (!this->Components.empty()) - { - std::vector<std::string>::const_iterator it; - for ( it = files.begin(); it != files.end(); ++ it ) - { - // beware we cannot just use tempDirectory as before - // because some generator will "CPACK_INCLUDE_TOPLEVEL_DIRECTORY" - // we really want "CPACK_TEMPORARY_DIRECTORY" - std::string fileN = - cmSystemTools::RelativePath( - this->GetOption("CPACK_TEMPORARY_DIRECTORY"), it->c_str()); - - // Determine which component we are in. - std::string componentName = fileN.substr(0, fileN.find('/')); - - // Strip off the component part of the path. - fileN = fileN.substr(fileN.find('/')+1, std::string::npos); - - // Add this file to the list of files for the component. - this->Components[componentName].Files.push_back(fileN); - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Adding file <" - <<fileN<<"> to component <" - <<componentName<<">"<<std::endl); - } - } - - packageFileNames.clear(); /* Put at least one file name into the list of * wanted packageFileNames. The specific generator @@ -1251,11 +1284,11 @@ int cmCPackGenerator::PrepareGroupingKind() cmCPackLogger(cmCPackLog::LOG_VERBOSE, "[" << this->Name << "]" << " requested component grouping = "<< groupingType <<std::endl); - if (groupingType == "ALL_GROUP_IN_ONE") + if (groupingType == "ALL_GROUPS_IN_ONE") { allGroupInOne = true; } - else if (groupingType == "ALL_COMPONENT_IN_ONE") + else if (groupingType == "ALL_COMPONENTS_IN_ONE") { allComponentInOne = true; } @@ -1268,11 +1301,19 @@ int cmCPackGenerator::PrepareGroupingKind() 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); + << "> UNKNOWN not in (ALL_GROUPS_IN_ONE," + "ALL_COMPONENTS_IN_ONE,IGNORE)" <<std::endl); } } + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "[" + << this->Name << "]" + << " requested component grouping = (" + << "ALL_GROUPS_IN_ONE=" << allGroupInOne + << ", ALL_COMPONENTS_IN_ONE=" << allComponentInOne + << ", IGNORE_GROUPS=" << ignoreComponentGroup + << ")" + << std::endl); // Some components were defined but NO group // force ignoreGroups if (this->ComponentGroups.empty() && (!this->Components.empty()) @@ -1289,6 +1330,52 @@ int cmCPackGenerator::PrepareGroupingKind() } //---------------------------------------------------------------------- +std::string cmCPackGenerator::GetComponentInstallDirNameSuffix( + const std::string& componentName) { + return componentName; +} +//---------------------------------------------------------------------- +std::string cmCPackGenerator::GetComponentPackageFileName( + const std::string& initialPackageFileName, + const std::string& groupOrComponentName, + bool isGroupName) { + + /* + * the default behavior is to use the + * component [group] name as a suffix + */ + std::string suffix="-"+groupOrComponentName; + /* check if we should use DISPLAY name */ + std::string dispNameVar = "CPACK_"+Name+"_USE_DISPLAY_NAME_IN_FILENAME"; + if (IsOn(dispNameVar.c_str())) + { + /* the component Group case */ + if (isGroupName) + { + std::string groupDispVar = "CPACK_COMPONENT_GROUP_" + + cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME"; + const char* groupDispName = GetOption(groupDispVar.c_str()); + if (groupDispName) + { + suffix = "-"+std::string(groupDispName); + } + } + /* the [single] component case */ + else + { + std::string dispVar = "CPACK_COMPONENT_" + + cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME"; + const char* dispName = GetOption(dispVar.c_str()); + if(dispName) + { + suffix = "-"+std::string(dispName); + } + } + } + return initialPackageFileName + suffix; +} + +//---------------------------------------------------------------------- bool cmCPackGenerator::SupportsComponentInstallation() const { return false; |