From 50292e14683727e6da81799cedd4ee352c3e0497 Mon Sep 17 00:00:00 2001 From: Arttu Tarkiainen Date: Tue, 2 Mar 2021 12:21:18 +0200 Subject: 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 Reviewed-by: Katja Marttila --- .../tst_extractarchiveoperationtest.cpp | 3 +-- tests/auto/installer/lib7zfacade/tst_lib7zfacade.cpp | 4 ++-- tests/auto/tools/repotest/tst_repotest.cpp | 10 ++++++---- 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/auto/installer/extractarchiveoperationtest/tst_extractarchiveoperationtest.cpp b/tests/auto/installer/extractarchiveoperationtest/tst_extractarchiveoperationtest.cpp index baaf58da2..cbbc1a1c7 100644 --- a/tests/auto/installer/extractarchiveoperationtest/tst_extractarchiveoperationtest.cpp +++ b/tests/auto/installer/extractarchiveoperationtest/tst_extractarchiveoperationtest.cpp @@ -84,8 +84,7 @@ private slots: QVERIFY(op.undoOperation()); QCOMPARE(UpdateOperation::Error(op.error()), UpdateOperation::UserDefinedError); - QCOMPARE(op.errorString(), QString("Error while extracting archive \":///data/invalid.7z\": " - "Cannot open archive \":///data/invalid.7z\".")); + QCOMPARE(op.errorString(), QString("Cannot open archive \":///data/invalid.7z\" for reading: ")); } void testExtractArchiveFromXML() diff --git a/tests/auto/installer/lib7zfacade/tst_lib7zfacade.cpp b/tests/auto/installer/lib7zfacade/tst_lib7zfacade.cpp index ffc5b330a..4175bdf40 100644 --- a/tests/auto/installer/lib7zfacade/tst_lib7zfacade.cpp +++ b/tests/auto/installer/lib7zfacade/tst_lib7zfacade.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -46,7 +46,7 @@ private slots: Lib7z::initSevenZ(); m_file.path = "valid"; - m_file.permissions = 0; + m_file.permissions_enum = 0; m_file.compressedSize = 836; m_file.uncompressedSize = 5242880; m_file.isDirectory = false; diff --git a/tests/auto/tools/repotest/tst_repotest.cpp b/tests/auto/tools/repotest/tst_repotest.cpp index 02594f400..9b8df947a 100644 --- a/tests/auto/tools/repotest/tst_repotest.cpp +++ b/tests/auto/tools/repotest/tst_repotest.cpp @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include @@ -63,7 +65,7 @@ private: tmp.setAutoRemove(false); const QString tmpMetaDir = tmp.path(); QInstallerTools::createRepository(m_repoInfo, &m_packages, tmpMetaDir, createSplitMetadata, - createUnifiedMetadata); + createUnifiedMetadata, QLatin1String("7z")); QInstaller::removeDirectory(tmpMetaDir, true); } @@ -95,12 +97,12 @@ private: QString existingUniteMeta7z = QInstallerTools::existingUniteMeta7z(m_repoInfo.repositoryDir); QCOMPARE(2, matches.count()); QCOMPARE(existingUniteMeta7z, matches.at(1)); - QFile file(m_repoInfo.repositoryDir + QDir::separator() + matches.at(1)); + Lib7zArchive file(m_repoInfo.repositoryDir + QDir::separator() + matches.at(1)); QVERIFY(file.open(QIODevice::ReadOnly)); //We have script.qs for package A in the unite metadata - QVector::const_iterator fileIt; - const QVector files = Lib7z::listArchive(&file); + QVector::const_iterator fileIt; + const QVector files = file.list(); for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) { if (fileIt->isDirectory) continue; -- cgit v1.2.3