Browse Source

CPack/Deb proper package file naming

Proper Debian packages file naming for single package
setup (breaks compatibility with previous versions)
Domen Vrankar 9 years ago
parent
commit
316dd61367
3 changed files with 29 additions and 38 deletions
  1. 8 9
      Modules/CPackDeb.cmake
  2. 20 28
      Source/CPack/cmCPackDebGenerator.cxx
  3. 1 1
      Source/CPack/cmCPackDebGenerator.h

+ 8 - 9
Modules/CPackDeb.cmake

@@ -835,15 +835,6 @@ function(cpack_deb_prepare_package_vars)
     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
   set(CPACK_ADD_LDCONFIG_CALL 0)
   foreach(_FILE ${CPACK_DEB_SHARED_OBJECT_FILES})
@@ -871,6 +862,14 @@ function(cpack_deb_prepare_package_vars)
     set(CPACK_DEBIAN_GENERATE_POSTRM 0)
   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
   if(CPACK_DEBIAN_PACKAGE_DEBUG)
      message("CPackDeb:Debug: CPACK_TOPLEVEL_DIRECTORY          = '${CPACK_TOPLEVEL_DIRECTORY}'")

+ 20 - 28
Source/CPack/cmCPackDebGenerator.cxx

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

+ 1 - 1
Source/CPack/cmCPackDebGenerator.h

@@ -60,7 +60,7 @@ protected:
    * Special case of component install where all
    * components will be put in a single installer.
    */
-  int PackageComponentsAllInOne();
+  int PackageComponentsAllInOne(const std::string& compInstDirName);
   virtual int PackageFiles();
   virtual const char* GetOutputExtension() { return ".deb"; }
   virtual bool SupportsComponentInstallation() const;