summaryrefslogtreecommitdiffstats
path: root/tools/repogen/repogen.cpp
diff options
context:
space:
mode:
authorArttu Tarkiainen <arttu.tarkiainen@qt.io>2021-03-02 12:21:18 +0200
committerArttu Tarkiainen <arttu.tarkiainen@qt.io>2021-09-14 14:25:18 +0300
commit50292e14683727e6da81799cedd4ee352c3e0497 (patch)
treeaa4bce967dee16e69aafef653f3c3f9ba1849d6c /tools/repogen/repogen.cpp
parent2076b1384754301ba409b6fe65551eaf55cce401 (diff)
Add support for handling archive files with libarchive
libarchive is a multi-format archive and compression library written in C and licensed under the new BSD license. Usage of libarchive brings in support for additional archive formats (in addition to 7z) with the installer framework, like zip and tar, with several available compression methods like gzip, bzip2 and xz. libarchive will coexist as a supported archive format handler with the LZMA SDK currently used in the framework, which will continue to be used for handling the 7-Zip file format. This change introduces classes for handling archive operations using both libraries, removes most calls to the old Lib7z facade and migrates the code base to use the new handling methods. Task-number: QTIFW-2255 Change-Id: I8d77110ded503060495a3d6fdfdbc26281df9453 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'tools/repogen/repogen.cpp')
-rw-r--r--tools/repogen/repogen.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/tools/repogen/repogen.cpp b/tools/repogen/repogen.cpp
index b630f8cd3..a709899c6 100644
--- a/tools/repogen/repogen.cpp
+++ b/tools/repogen/repogen.cpp
@@ -34,7 +34,7 @@
#include <settings.h>
#include <utils.h>
#include <loggingutils.h>
-#include <lib7z_facade.h>
+#include <archivefactory.h>
#include <QDomDocument>
#include <QtCore/QDir>
@@ -50,6 +50,8 @@ using namespace QInstaller;
static void printUsage()
{
const QString appName = QFileInfo(QCoreApplication::applicationFilePath()).fileName();
+ const QString archiveFormats = ArchiveFactory::supportedTypes().join(QLatin1Char('|'));
+
std::cout << "Usage: " << appName << " [options] repository-dir" << std::endl;
std::cout << std::endl;
std::cout << "Options:" << std::endl;
@@ -71,6 +73,9 @@ static void printUsage()
std::cout << " download phase." << std::endl;
std::cout << " --component-metadata Creates one metadata 7z per component. " << std::endl;
+ 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 << std::endl;
std::cout << "Example:" << std::endl;
@@ -105,6 +110,7 @@ int main(int argc, char** argv)
bool updateExistingRepositoryWithNewComponents = false;
bool createUnifiedMetadata = true;
bool createComponentMetadata = true;
+ QString archiveSuffix = QLatin1String("7z");
//TODO: use a for loop without removing values from args like it is in binarycreator.cpp
//for (QStringList::const_iterator it = args.begin(); it != args.end(); ++it) {
@@ -197,6 +203,15 @@ int main(int argc, char** argv)
args.removeFirst();
packagesUpdatedWithSha = args.first().split(QLatin1Char(','));
args.removeFirst();
+ } else if (args.first() == QLatin1String("--af") || args.first() == QLatin1String("--archive-format")) {
+ args.removeFirst();
+ if (args.isEmpty()) {
+ return printErrorAndUsageAndExit(QCoreApplication::translate("QInstaller",
+ "Error: Archive format parameter missing argument"));
+ }
+ // TODO: do we need early check for supported formats?
+ archiveSuffix = args.first();
+ args.removeFirst();
} else {
printUsage();
return 1;
@@ -248,11 +263,9 @@ int main(int argc, char** argv)
tmp.setAutoRemove(false);
tmpMetaDir = tmp.path();
QInstallerTools::createRepository(repoInfo, &packages, tmpMetaDir,
- createComponentMetadata, createUnifiedMetadata);
+ createComponentMetadata, createUnifiedMetadata, archiveSuffix);
exitCode = EXIT_SUCCESS;
- } catch (const Lib7z::SevenZipException &e) {
- std::cerr << "Caught 7zip exception: " << e.message() << std::endl;
} catch (const QInstaller::Error &e) {
std::cerr << "Caught exception: " << e.message() << std::endl;
} catch (...) {