CPack/Deb proper package file naming

Proper Debian packages file naming for single package
setup (breaks compatibility with previous versions)
This commit is contained in:
Domen Vrankar 2016-05-10 18:31:05 +02:00 committed by Brad King
parent 271e03f089
commit 316dd61367
3 changed files with 29 additions and 38 deletions

View File

@ -835,15 +835,6 @@ function(cpack_deb_prepare_package_vars)
endif() endif()
endif() endif()
# Patch package file name to be in corrent form
if(CPACK_DEB_PACKAGE_COMPONENT)
set(CPACK_OUTPUT_FILE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb")
set(CPACK_TEMPORARY_PACKAGE_FILE_NAME "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_OUTPUT_FILE_NAME}")
get_filename_component(BINARY_DIR "${CPACK_OUTPUT_FILE_PATH}" DIRECTORY)
set(CPACK_OUTPUT_FILE_PATH "${BINARY_DIR}/${CPACK_OUTPUT_FILE_NAME}")
endif()
# add ldconfig call in default postrm and postint # add ldconfig call in default postrm and postint
set(CPACK_ADD_LDCONFIG_CALL 0) set(CPACK_ADD_LDCONFIG_CALL 0)
foreach(_FILE ${CPACK_DEB_SHARED_OBJECT_FILES}) foreach(_FILE ${CPACK_DEB_SHARED_OBJECT_FILES})
@ -871,6 +862,14 @@ function(cpack_deb_prepare_package_vars)
set(CPACK_DEBIAN_GENERATE_POSTRM 0) set(CPACK_DEBIAN_GENERATE_POSTRM 0)
endif() endif()
# Patch package file name to be in corrent debian format:
# <foo>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
set(CPACK_OUTPUT_FILE_NAME
"${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb")
set(CPACK_TEMPORARY_PACKAGE_FILE_NAME "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_OUTPUT_FILE_NAME}")
get_filename_component(BINARY_DIR "${CPACK_OUTPUT_FILE_PATH}" DIRECTORY)
set(CPACK_OUTPUT_FILE_PATH "${BINARY_DIR}/${CPACK_OUTPUT_FILE_NAME}")
# Print out some debug information if we were asked for that # Print out some debug information if we were asked for that
if(CPACK_DEBIAN_PACKAGE_DEBUG) if(CPACK_DEBIAN_PACKAGE_DEBUG)
message("CPackDeb:Debug: CPACK_TOPLEVEL_DIRECTORY = '${CPACK_TOPLEVEL_DIRECTORY}'") message("CPackDeb:Debug: CPACK_TOPLEVEL_DIRECTORY = '${CPACK_TOPLEVEL_DIRECTORY}'")

View File

@ -60,7 +60,8 @@ int cmCPackDebGenerator::PackageOnePack(std::string initialTopLevel,
cmSystemTools::GetParentDirectory(toplevel) cmSystemTools::GetParentDirectory(toplevel)
); );
std::string outputFileName( std::string outputFileName(
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) cmsys::SystemTools::LowerCase(
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")))
+"-"+packageName + this->GetOutputExtension() +"-"+packageName + this->GetOutputExtension()
); );
@ -168,17 +169,16 @@ int cmCPackDebGenerator::PackageComponents(bool ignoreGroup)
return retval; return retval;
} }
int cmCPackDebGenerator::PackageComponentsAllInOne() //----------------------------------------------------------------------
int cmCPackDebGenerator::PackageComponentsAllInOne(
const std::string& compInstDirName)
{ {
int retval = 1; int retval = 1;
std::string compInstDirName;
/* Reset package file name list it will be populated during the /* Reset package file name list it will be populated during the
* component packaging run*/ * component packaging run*/
packageFileNames.clear(); packageFileNames.clear();
std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY")); std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
compInstDirName = "ALL_COMPONENTS_IN_ONE";
cmCPackLogger(cmCPackLog::LOG_VERBOSE, cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Packaging all groups in one package..." "Packaging all groups in one package..."
"(CPACK_COMPONENTS_ALL_[GROUPS_]IN_ONE_PACKAGE is set)" "(CPACK_COMPONENTS_ALL_[GROUPS_]IN_ONE_PACKAGE is set)"
@ -190,7 +190,8 @@ int cmCPackDebGenerator::PackageComponentsAllInOne()
cmSystemTools::GetParentDirectory(toplevel) cmSystemTools::GetParentDirectory(toplevel)
); );
std::string outputFileName( std::string outputFileName(
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) cmsys::SystemTools::LowerCase(
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")))
+ this->GetOutputExtension() + this->GetOutputExtension()
); );
// all GROUP in one vs all COMPONENT in one // all GROUP in one vs all COMPONENT in one
@ -204,11 +205,15 @@ int cmCPackDebGenerator::PackageComponentsAllInOne()
/* replace the TEMPORARY package file name */ /* replace the TEMPORARY package file name */
this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME", this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME",
packageFileName.c_str()); packageFileName.c_str());
if(!compInstDirName.empty())
{
// Tell CPackDeb.cmake the path where the component is. // Tell CPackDeb.cmake the path where the component is.
std::string component_path = "/"; std::string component_path = "/";
component_path += compInstDirName; component_path += compInstDirName;
this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH", this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH",
component_path.c_str()); component_path.c_str());
}
if (!this->ReadListFile("CPackDeb.cmake")) if (!this->ReadListFile("CPackDeb.cmake"))
{ {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
@ -246,8 +251,6 @@ int cmCPackDebGenerator::PackageComponentsAllInOne()
int cmCPackDebGenerator::PackageFiles() int cmCPackDebGenerator::PackageFiles()
{ {
int retval = -1;
/* Are we in the component packaging case */ /* Are we in the component packaging case */
if (WantsComponentInstallation()) { if (WantsComponentInstallation()) {
// CASE 1 : COMPONENT ALL-IN-ONE package // CASE 1 : COMPONENT ALL-IN-ONE package
@ -255,7 +258,7 @@ int cmCPackDebGenerator::PackageFiles()
// then the package file is unique and should be open here. // then the package file is unique and should be open here.
if (componentPackageMethod == ONE_PACKAGE) if (componentPackageMethod == ONE_PACKAGE)
{ {
return PackageComponentsAllInOne(); return PackageComponentsAllInOne("ALL_COMPONENTS_IN_ONE");
} }
// 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
@ -270,19 +273,8 @@ int cmCPackDebGenerator::PackageFiles()
// CASE 3 : NON COMPONENT package. // CASE 3 : NON COMPONENT package.
else else
{ {
if (!this->ReadListFile("CPackDeb.cmake")) return PackageComponentsAllInOne("");
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error while execution CPackDeb.cmake" << std::endl);
retval = 0;
} }
else
{
packageFiles = files;
return createDeb();
}
}
return retval;
} }
int cmCPackDebGenerator::createDeb() int cmCPackDebGenerator::createDeb()

View File

@ -60,7 +60,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(); int PackageComponentsAllInOne(const std::string& compInstDirName);
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;