Browse Source

CPackIFW: add support for archive format and compression level options

Adds the following CPackIFW variables:

- CPACK_IFW_ARCHIVE_FORMAT
- CPACK_IFW_ARCHIVE_COMPRESSION

These variables control mirror the --archive-format and --compression
options of the QtIFW binarycreator and repogen tools.

Fixes: #22803

Co-authored-by: Erlend E. Aasland <[email protected]>
Co-authored-by: Awen Autret
Erlend E. Aasland 4 years ago
parent
commit
62ef2729ee

+ 40 - 0
Help/cpack_gen/ifw.rst

@@ -292,6 +292,46 @@ Package
 
  This feature is available for QtIFW 4.0.0 and newer.
 
+.. variable:: CPACK_IFW_ARCHIVE_FORMAT
+
+ .. versionadded:: 3.23
+
+ Set the format used when packaging new component data archives. If you omit
+ this option, the ``7z`` format will be used as a default. Supported formats:
+
+ * 7z
+ * zip
+ * tar.gz
+ * tar.bz2
+ * tar.xz
+
+ .. note::
+
+  If the Qt Installer Framework tools were built without libarchive support,
+  only ``7z`` format is supported.
+
+ This feature is available for QtIFW 4.2.0 and newer.
+
+.. variable:: CPACK_IFW_ARCHIVE_COMPRESSION
+
+ .. versionadded:: 3.23
+
+ Archive compression level. Defaults to 5 (*Normal compression*).
+
+  * 0 (*No compression*)
+  * 1 (*Fastest compressing*)
+  * 3 (*Fast compressing*)
+  * 5 (*Normal compressing*)
+  * 7 (*Maximum compressing*)
+  * 9 (*Ultra compressing*)
+
+ .. note::
+
+  Some formats do not support all the possible values. For example ``zip``
+  compression only supports values from 1 to 7.
+
+ This feature is available for QtIFW 4.2.0 and newer.
+
 Components
 """"""""""
 

+ 9 - 0
Help/release/dev/cpackifw-archive-format.rst

@@ -0,0 +1,9 @@
+
+cpackifw-archive-format
+-----------------------
+
+* The :cpack_gen:`CPack IFW Generator` gained the new
+  :variable:`CPACK_IFW_ARCHIVE_FORMAT` and
+  :variable:`CPACK_IFW_ARCHIVE_COMPRESSION` variables for setting the format
+  used when packaging new component data archives, and choosing the compression
+  level used. These features are available for QtIFW 4.2 and newer.

+ 30 - 0
Source/CPack/IFW/cmCPackIFWGenerator.cxx

@@ -58,6 +58,17 @@ std::vector<std::string> cmCPackIFWGenerator::BuildRepogenCommand()
 
   ifwCmd.emplace_back(this->RepoGen);
 
+  if (!this->IsVersionLess("4.2")) {
+    if (!this->ArchiveFormat.empty()) {
+      ifwCmd.emplace_back("--archive-format");
+      ifwCmd.emplace_back(this->ArchiveFormat);
+    }
+    if (!this->ArchiveCompression.empty()) {
+      ifwCmd.emplace_back("--compression");
+      ifwCmd.emplace_back(this->ArchiveCompression);
+    }
+  }
+
   if (this->IsVersionLess("2.0.0")) {
     ifwCmd.emplace_back("-c");
     ifwCmd.emplace_back(this->toplevel + "/config/config.xml");
@@ -157,6 +168,17 @@ std::vector<std::string> cmCPackIFWGenerator::BuildBinaryCreatorCommmand()
 
   ifwCmd.emplace_back(this->BinCreator);
 
+  if (!this->IsVersionLess("4.2")) {
+    if (!this->ArchiveFormat.empty()) {
+      ifwCmd.emplace_back("--archive-format");
+      ifwCmd.emplace_back(this->ArchiveFormat);
+    }
+    if (!this->ArchiveCompression.empty()) {
+      ifwCmd.emplace_back("--compression");
+      ifwCmd.emplace_back(this->ArchiveCompression);
+    }
+  }
+
   ifwCmd.emplace_back("-c");
   ifwCmd.emplace_back(this->toplevel + "/config/config.xml");
 
@@ -354,6 +376,14 @@ int cmCPackIFWGenerator::InitializeInternal()
     cmExpandList(dirs, this->RepoDirsVector);
   }
 
+  // Archive format and compression level
+  if (cmValue af = this->GetOption("CPACK_IFW_ARCHIVE_FORMAT")) {
+    this->ArchiveFormat = *af;
+  }
+  if (cmValue ac = this->GetOption("CPACK_IFW_ARCHIVE_COMPRESSION")) {
+    this->ArchiveCompression = *ac;
+  }
+
   // Installer
   this->Installer.Generator = this;
   this->Installer.ConfigureFromOptions();

+ 2 - 0
Source/CPack/IFW/cmCPackIFWGenerator.h

@@ -151,6 +151,8 @@ private:
   std::string FrameworkVersion;
   std::string ExecutableSuffix;
   std::string OutputExtension;
+  std::string ArchiveFormat;
+  std::string ArchiveCompression;
 
   bool OnlineOnly;
   bool ResolveDuplicateNames;