summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArttu Tarkiainen <arttu.tarkiainen@qt.io>2021-08-27 13:26:24 +0300
committerArttu Tarkiainen <arttu.tarkiainen@qt.io>2021-09-14 15:04:39 +0300
commitfce4d500a0394d4d46235f77a5cbb8fd2b5a5e68 (patch)
tree8ce174163b44585b6bc1b6caf0c4ee016aabca8d
parent14b4bdde43a6e400a2212b155c75b67c2913998a (diff)
binarycreator: support selecting compression level and archive format
Task-number: QTIFW-1587 Change-Id: I8855b1ce4bb8abf072ff235846428fc63729f0fb Reviewed-by: Katja Marttila <katja.marttila@qt.io>
-rw-r--r--doc/installerfw.qdoc19
-rw-r--r--src/libs/ifwtools/binarycreator.cpp3
-rw-r--r--src/libs/ifwtools/binarycreator.h6
-rw-r--r--tools/binarycreator/main.cpp26
4 files changed, 53 insertions, 1 deletions
diff --git a/doc/installerfw.qdoc b/doc/installerfw.qdoc
index 58a870eed..458f3b936 100644
--- a/doc/installerfw.qdoc
+++ b/doc/installerfw.qdoc
@@ -1157,6 +1157,25 @@
\li -s or --sign identity
\li Only available on macOS. Allows specifying a code signing identity to be
used for signing the generated app bundle.
+ \row
+ \li --af or --archive-format 7z|zip|tar.gz|tar.bz2|tar.xz
+ \li Set the format used when packaging new component data archives. If
+ you omit this option, the 7z format will be used as a default.
+ \note If the Installer Framework tools were built without libarchive
+ support, only \c{7z} format is supported.
+ \row
+ \li --ac or --compression <5>
+ \li Defaults to 5 (Normal compression). \note Some formats do not support
+ all the possible values, for example bzip2 compression only supports
+ values from 1 to 9.
+ \list
+ \li 0 (No compression)
+ \li 1 (Fastest compressing)
+ \li 3 (Fast compressing)
+ \li 5 (Normal compressing)
+ \li 7 (Maximum compressing)
+ \li 9 (Ultra compressing)
+ \endlist
\endtable
These parameters are followed by the name of the target binary and a list
diff --git a/src/libs/ifwtools/binarycreator.cpp b/src/libs/ifwtools/binarycreator.cpp
index a1261d55e..cf04355de 100644
--- a/src/libs/ifwtools/binarycreator.cpp
+++ b/src/libs/ifwtools/binarycreator.cpp
@@ -804,7 +804,8 @@ int QInstallerTools::createBinary(BinaryCreatorArgs args, QString &argumentError
// 2.2; copy the packages data and setup the packages vector with the files we copied,
// must happen before copying meta data because files will be compressed if
// needed and meta data generation relies on this
- copyComponentData(args.packagesDirectories, tmpRepoDir, &preparedPackages, QLatin1String("7z"));
+ copyComponentData(args.packagesDirectories, tmpRepoDir, &preparedPackages,
+ args.archiveSuffix, args.compression);
// 2.3; add to common vector
packages.append(preparedPackages);
}
diff --git a/src/libs/ifwtools/binarycreator.h b/src/libs/ifwtools/binarycreator.h
index 0c079b865..7c14ea039 100644
--- a/src/libs/ifwtools/binarycreator.h
+++ b/src/libs/ifwtools/binarycreator.h
@@ -35,6 +35,8 @@
#include "fileutils.h"
#include "binaryformat.h"
+#include <abstractarchive.h>
+
#include <QtCore/QString>
#include <QtCore/QFile>
@@ -48,6 +50,8 @@ struct Input
QInstaller::ResourceCollectionManager manager;
};
+typedef QInstaller::AbstractArchive::CompressionLevel Compression;
+
struct IFWTOOLS_EXPORT BinaryCreatorArgs
{
QString target;
@@ -55,6 +59,8 @@ struct IFWTOOLS_EXPORT BinaryCreatorArgs
QString templateBinary;
QStringList packagesDirectories;
QStringList repositoryDirectories;
+ QString archiveSuffix = QLatin1String("7z");
+ Compression compression = Compression::Normal;
bool onlineOnly = false;
bool offlineOnly = false;
QStringList resources;
diff --git a/tools/binarycreator/main.cpp b/tools/binarycreator/main.cpp
index c28a2ebb3..d74644670 100644
--- a/tools/binarycreator/main.cpp
+++ b/tools/binarycreator/main.cpp
@@ -30,8 +30,10 @@
#include <init.h>
#include <utils.h>
#include <loggingutils.h>
+#include <archivefactory.h>
#include <QtCore/QDebug>
+#include <QMetaEnum>
#include <iostream>
@@ -44,6 +46,7 @@ static void printUsage()
suffix = QLatin1String(".exe");
#endif
const QString appName = QFileInfo(QCoreApplication::applicationFilePath()).fileName();
+ const QString archiveFormats = ArchiveFactory::supportedTypes().join(QLatin1Char('|'));
std::cout << "Usage: " << appName << " [options] target" << std::endl;
std::cout << std::endl;
std::cout << "Options:" << std::endl;
@@ -72,6 +75,11 @@ static void printUsage()
std::cout << " -s|--sign identity Sign generated app bundle using the given code " << std::endl;
std::cout << " signing identity" << std::endl;
#endif
+ std::cout << " --af|--archive-format " << archiveFormats << std::endl;
+ std::cout << " Set the format used when packaging new component data archives. If" << std::endl;
+ std::cout << " you omit this option the 7z format will be used as a default." << std::endl;
+ std::cout << " --ac|--compression 0,1,3,5,7,9" << std::endl;
+ std::cout << " Sets the compression level used when packaging new data archives." << std::endl;
std::cout << std::endl;
std::cout << "Packages are to be found in the current working directory and get listed as "
"their names" << std::endl << std::endl;
@@ -179,6 +187,24 @@ int main(int argc, char **argv)
continue;
} else if (*it == QLatin1String("-rcc") || *it == QLatin1String("--compile-resource")) {
parsedArgs.compileResource = true;
+ } else if (*it == QLatin1String("--af") || *it == QLatin1String("--archive-format")) {
+ ++it;
+ if (it == args.end())
+ return printErrorAndUsageAndExit(QString::fromLatin1("Error: Archive format parameter missing argument."));
+ parsedArgs.archiveSuffix = *it;
+ } else if (*it == QLatin1String("--ac") || *it == QLatin1String("--compression")) {
+ ++it;
+ if (it == args.end())
+ return printErrorAndUsageAndExit(QString::fromLatin1("Error: Compression parameter missing argument"));
+
+ bool ok = false;
+ QMetaEnum levels = QMetaEnum::fromType<AbstractArchive::CompressionLevel>();
+ const int value = it->toInt(&ok);
+ if (!ok || !levels.valueToKey(value)) {
+ return printErrorAndUsageAndExit(QString::fromLatin1(
+ "Error: Unknown compression level \"%1\".").arg(value));
+ }
+ parsedArgs.compression = static_cast<AbstractArchive::CompressionLevel>(value);
#ifdef Q_OS_MACOS
} else if (*it == QLatin1String("-s") || *it == QLatin1String("--sign")) {
++it;