From 2d5f0ffaf1278516bbd74e3b60f9849f4c51cffa Mon Sep 17 00:00:00 2001 From: Arttu Tarkiainen Date: Wed, 6 Apr 2022 10:18:01 +0300 Subject: 3rdparty: deprecate usage of LZMA SDK The 3rd-party sources haven't been updated in a long time, and is missing some features compared to libarchive (which the official IFW binaries use), like symbolic link support on Windows. Add deprecation warning when compiling with LZMA SDK, and make building the library and related client code conditional behind a separate config feature. Update docs to emphasize that libarchive is the recommended build option for archive handler. Change-Id: I70ed5f9b5d13e2243778f7c44b4ea833c8092ae0 Reviewed-by: Katja Marttila --- INSTALL | 8 +++-- doc/installerfw-getting-started.qdoc | 17 +++++----- features/lzmasdk.prf | 1 + installerfw.pri | 36 +++++++++++++++------- src/libs/installer/archivefactory.cpp | 4 +-- src/libs/installer/init.cpp | 5 ++- src/libs/installer/installer.pro | 30 ++++++++++-------- src/libs/libs.pro | 12 ++++++-- .../archivefactory/tst_archivefactory.cpp | 2 +- tests/auto/installer/installer.pro | 5 ++- tests/auto/tools/repotest/tst_repotest.cpp | 14 ++++++--- tools/archivegen/archive.cpp | 8 +++-- tools/archivegen/archivegen.pro | 5 +-- 13 files changed, 98 insertions(+), 49 deletions(-) create mode 100644 features/lzmasdk.prf diff --git a/INSTALL b/INSTALL index 9801ec492..e9e865262 100644 --- a/INSTALL +++ b/INSTALL @@ -56,7 +56,7 @@ The Qt Installer Framework sources contain a redistribution of parts of the libarchive compression and archive library, which requires you to link against additional libraries; liblzma, zlib, libbzip2, and on macOS, libiconv. -The usage of libarchive is optional and can be enabled by adding the libarchive +The usage of libarchive is recommended and can be enabled by adding the libarchive configuration feature to the list of values specified by the CONFIG variable. Installers created with this configuration support the (de)compression of 7zip, zip, and tar archive files, with gzip, bzip2, and xz as available compression methods. @@ -64,8 +64,10 @@ files, with gzip, bzip2, and xz as available compression methods. The IFW_ZLIB_LIBRARY, IFW_BZIP2_LIBRARY, IFW_LZMA_LIBRARY, and IFW_ICONV_LIBRARY variables can be used to specify the exact library files if required. -If you omit the feature, the installation of the additional dependencies can be skipped, -but created installers will only support the 7zip format. +If you omit the feature, the builtin LZMA SDK library will be used as a fallback and +installation of the additional dependencies can be skipped, but created installers will +only support the 7zip format. Note that building IFW with LZMA SDK is deprecated and may not +be available in future versions. ### Windows diff --git a/doc/installerfw-getting-started.qdoc b/doc/installerfw-getting-started.qdoc index f1adabbdc..6841ae91b 100644 --- a/doc/installerfw-getting-started.qdoc +++ b/doc/installerfw-getting-started.qdoc @@ -112,26 +112,29 @@ make module-qtbase module-qtdeclarative module-qttools module-qttranslations \endcode - \section2 Configuring Support for Archive File Formats + \section2 Third Party Dependencies The Qt Installer Framework sources contain a redistribution of parts of the libarchive compression and archive library, which requires you to link against additional libraries; \c liblzma, \c zlib, \c libbzip2, and on macOS, \c libiconv. - The usage of libarchive is optional and can be enabled by adding the libarchive + The usage of libarchive is recommended and can be enabled by adding the libarchive configuration feature to the list of values specified by the \c CONFIG variable. Installers created with this configuration support the (de)compression of 7zip, zip, and tar archive files, with gzip, bzip2, and xz as available compression methods. + \code + qmake CONFIG+=libarchive + \endcode + The \c IFW_ZLIB_LIBRARY, \c IFW_BZIP2_LIBRARY, \c IFW_LZMA_LIBRARY, and \c IFW_ICONV_LIBRARY variables can be used to specify the exact library files if required. - If you omit the feature, the installation of the additional dependencies can be skipped, - but created installers will only support the 7zip format. + If you omit the feature, the builtin LZMA SDK library will be used as a fallback and + installation of the additional dependencies can be skipped, but created installers will + only support the 7zip format. - \code - qmake CONFIG+=libarchive - \endcode + \note Building IFW with LZMA SDK is deprecated and may not be available in future versions. \section3 Installing Dependencies for Windows diff --git a/features/lzmasdk.prf b/features/lzmasdk.prf new file mode 100644 index 000000000..c5d048309 --- /dev/null +++ b/features/lzmasdk.prf @@ -0,0 +1 @@ +DEFINES += IFW_LIB7Z diff --git a/installerfw.pri b/installerfw.pri index ca5f00436..e03e72176 100644 --- a/installerfw.pri +++ b/installerfw.pri @@ -17,6 +17,17 @@ isEqual(IFW_DISABLE_TRANSLATIONS, 1) { DEFINES += IFW_DISABLE_TRANSLATIONS } +# Still default to LZMA SDK if nothing is defined by user +!contains(CONFIG, libarchive|lzmasdk): CONFIG += lzmasdk + +CONFIG(lzmasdk) { + LZMA_WARNING_MSG = "LZMA SDK as an archive handler in IFW is deprecated. Consider" \ + "switching to libarchive by appending 'libarchive' to your 'CONFIG' variable." \ + "This requires linking against additional external libraries, see the" \ + "'INSTALL' file for more details." + !build_pass:warning($$LZMA_WARNING_MSG) +} + defineTest(minQtVersion) { maj = $$1 min = $$2 @@ -90,14 +101,18 @@ win32-g++*:QMAKE_CXXFLAGS += -Wno-attributes macx:QMAKE_CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden INCLUDEPATH += \ - $$IFW_SOURCE_TREE/src/libs/7zip \ $$IFW_SOURCE_TREE/src/libs/kdtools \ $$IFW_SOURCE_TREE/src/libs/ifwtools \ $$IFW_SOURCE_TREE/src/libs/installer -win32:INCLUDEPATH += $$IFW_SOURCE_TREE/src/libs/7zip/win/CPP -unix:INCLUDEPATH += $$IFW_SOURCE_TREE/src/libs/7zip/unix/CPP + CONFIG(libarchive): INCLUDEPATH += $$IFW_SOURCE_TREE/src/libs/3rdparty/libarchive +CONFIG(lzmasdk) { + INCLUDEPATH += $$IFW_SOURCE_TREE/src/libs/7zip + win32:INCLUDEPATH += $$IFW_SOURCE_TREE/src/libs/7zip/win/CPP + unix:INCLUDEPATH += $$IFW_SOURCE_TREE/src/libs/7zip/unix/CPP +} + LIBS += -L$$IFW_LIB_PATH # The order is important. The linker needs to parse archives in reversed dependency order. equals(TEMPLATE, app):LIBS += -linstaller @@ -142,7 +157,6 @@ DEFINES += NOMINMAX QT_NO_CAST_FROM_ASCII QT_STRICT_ITERATORS QT_USE_QSTRINGBUIL IFW_VERSION_WIN32=$$IFW_VERSION_WIN32 DEFINES += IFW_REPOSITORY_FORMAT_VERSION=$$IFW_REPOSITORY_FORMAT_VERSION -LIBS += -l7z win32-g++*: LIBS += -lmpr -luuid CONFIG(libarchive):equals(TEMPLATE, app) { @@ -172,16 +186,16 @@ CONFIG(libarchive):equals(TEMPLATE, app) { LIBS += -liconv } } + + msvc:POST_TARGETDEPS += $$IFW_LIB_PATH/libarchive.lib + win32-g++*:POST_TARGETDEPS += $$IFW_LIB_PATH/liblibarchive.a + unix:POST_TARGETDEPS += $$IFW_LIB_PATH/liblibarchive.a } -equals(TEMPLATE, app) { +CONFIG(lzmasdk):equals(TEMPLATE, app) { + LIBS += -l7z + msvc:POST_TARGETDEPS += $$IFW_LIB_PATH/installer.lib $$IFW_LIB_PATH/7z.lib win32-g++*:POST_TARGETDEPS += $$IFW_LIB_PATH/libinstaller.a $$IFW_LIB_PATH/lib7z.a unix:POST_TARGETDEPS += $$IFW_LIB_PATH/libinstaller.a $$IFW_LIB_PATH/lib7z.a - - CONFIG(libarchive) { - msvc:POST_TARGETDEPS += $$IFW_LIB_PATH/libarchive.lib - win32-g++*:POST_TARGETDEPS += $$IFW_LIB_PATH/liblibarchive.a - unix:POST_TARGETDEPS += $$IFW_LIB_PATH/liblibarchive.a - } } diff --git a/src/libs/installer/archivefactory.cpp b/src/libs/installer/archivefactory.cpp index 5bfabe943..56811d8e3 100644 --- a/src/libs/installer/archivefactory.cpp +++ b/src/libs/installer/archivefactory.cpp @@ -29,7 +29,7 @@ #include "archivefactory.h" #ifdef IFW_LIBARCHIVE #include "libarchivewrapper.h" -#else +#elif defined(IFW_LIB7Z) #include "lib7zarchive.h" #endif @@ -144,7 +144,7 @@ ArchiveFactory::ArchiveFactory() << QLatin1String("tar") << QLatin1String("tar.gz") << QLatin1String("tar.bz2") << QLatin1String("tar.xz") << QLatin1String("zip") << QLatin1String("7z") << QLatin1String("qbsp")); -#else +#elif defined(IFW_LIB7Z) registerArchive(QLatin1String("Lib7z"), QStringList() << QLatin1String("7z") << QLatin1String("qbsp")); #endif diff --git a/src/libs/installer/init.cpp b/src/libs/installer/init.cpp index 4aa65296f..f47040d93 100644 --- a/src/libs/installer/init.cpp +++ b/src/libs/installer/init.cpp @@ -49,7 +49,9 @@ #include "consumeoutputoperation.h" #include "loggingutils.h" +#ifdef IFW_LIB7Z #include "lib7z_facade.h" +#endif #include "updateoperationfactory.h" #include "filedownloaderfactory.h" @@ -72,8 +74,9 @@ static void initResources() */ void QInstaller::init() { +#ifdef IFW_LIB7Z Lib7z::initSevenZ(); - +#endif #if defined(QT_STATIC) ::initResources(); #endif diff --git a/src/libs/installer/installer.pro b/src/libs/installer/installer.pro index ed7d739ed..7aedc6590 100644 --- a/src/libs/installer/installer.pro +++ b/src/libs/installer/installer.pro @@ -4,7 +4,6 @@ INCLUDEPATH += . .. CONFIG += staticlib -include(../7zip/7zip.pri) include(../kdtools/kdtools.pri) include(../ifwtools/ifwtools.pri) include(../../../installerfw.pri) @@ -91,7 +90,6 @@ HEADERS += packagemanagercore.h \ constants.h \ packagemanagerproxyfactory.h \ createlocalrepositoryoperation.h \ - lib7z_facade.h \ link.h \ createlinkoperation.h \ packagemanagercoredata.h \ @@ -105,7 +103,6 @@ HEADERS += packagemanagercore.h \ copyfiletask.h \ downloadfiletask.h \ downloadfiletask_p.h \ - unziptask.h \ observer.h \ runextensions.h \ metadatajob.h \ @@ -132,17 +129,12 @@ HEADERS += packagemanagercore.h \ keepaliveobject.h \ systeminfo.h \ packagesource.h \ - lib7z_guid.h \ - lib7z_create.h \ - lib7z_extract.h \ - lib7z_list.h \ repositorycategory.h \ componentselectionpage_p.h \ commandlineparser.h \ commandlineparser_p.h \ abstractarchive.h \ directoryguard.h \ - lib7zarchive.h \ archivefactory.h SOURCES += packagemanagercore.cpp \ @@ -150,7 +142,6 @@ SOURCES += packagemanagercore.cpp \ archivefactory.cpp \ aspectratiolabel.cpp \ directoryguard.cpp \ - lib7zarchive.cpp \ componentsortfilterproxymodel.cpp \ loggingutils.cpp \ packagemanagercore_p.cpp \ @@ -194,7 +185,6 @@ SOURCES += packagemanagercore.cpp \ permissionsettings.cpp \ packagemanagerproxyfactory.cpp \ createlocalrepositoryoperation.cpp \ - lib7z_facade.cpp \ link.cpp \ createlinkoperation.cpp \ packagemanagercoredata.cpp \ @@ -205,7 +195,6 @@ SOURCES += packagemanagercore.cpp \ abstractfiletask.cpp \ copyfiletask.cpp \ downloadfiletask.cpp \ - unziptask.cpp \ observer.cpp \ metadatajob.cpp \ protocol.cpp \ @@ -251,11 +240,26 @@ CONFIG(libarchive) { LIBS += -llibarchive } -LIBS += -l7z +CONFIG(lzmasdk) { + include(../7zip/7zip.pri) + + HEADERS += lib7z_facade.h \ + lib7z_guid.h \ + lib7z_create.h \ + lib7z_extract.h \ + lib7z_list.h \ + lib7zarchive.h + + SOURCES += lib7z_facade.cpp \ + lib7zarchive.cpp + + LIBS += -l7z + win32:LIBS += -loleaut32 -luser32 +} + win32 { SOURCES += adminauthorization_win.cpp sysinfo_win.cpp - LIBS += -loleaut32 -luser32 # 7zip LIBS += -ladvapi32 -lpsapi # kdtools LIBS += -lole32 -lshell32 # createshortcutoperation diff --git a/src/libs/libs.pro b/src/libs/libs.pro index 64bc41d51..8d849fd15 100644 --- a/src/libs/libs.pro +++ b/src/libs/libs.pro @@ -1,3 +1,11 @@ TEMPLATE = subdirs -SUBDIRS += 3rdparty 7zip installer -installer.depends = 3rdparty 7zip + +include(../../installerfw.pri) + +SUBDIRS += 3rdparty installer +installer.depends = 3rdparty + +CONFIG(lzmasdk) { + SUBDIRS += 7zip + installer.depends = 7zip +} diff --git a/tests/auto/installer/archivefactory/tst_archivefactory.cpp b/tests/auto/installer/archivefactory/tst_archivefactory.cpp index a00f8c815..0c1a7b6f6 100644 --- a/tests/auto/installer/archivefactory/tst_archivefactory.cpp +++ b/tests/auto/installer/archivefactory/tst_archivefactory.cpp @@ -91,7 +91,7 @@ private slots: QTest::newRow("LibArchive") << "LibArchive" << "myfile.zip" << (QStringList() << "tar" << "tar.gz" << "tar.bz2" << "tar.xz" << "zip" << "7z" << "qbsp"); -#else +#elif defined(IFW_LIB7Z) QTest::newRow("Lib7z") << "Lib7z" << "myfile.7z" << (QStringList() << "7z" << "qbsp"); #endif diff --git a/tests/auto/installer/installer.pro b/tests/auto/installer/installer.pro index 947dc92a2..eb5fa6d2e 100644 --- a/tests/auto/installer/installer.pro +++ b/tests/auto/installer/installer.pro @@ -10,7 +10,6 @@ SUBDIRS += \ fakestopprocessforupdateoperation \ messageboxhandler \ extractarchiveoperationtest \ - lib7zarchive \ fileutils \ unicodeexecutable \ scriptengine \ @@ -48,6 +47,10 @@ CONFIG(libarchive) { SUBDIRS += libarchivearchive } +CONFIG(lzmasdk) { + SUBDIRS += lib7zarchive +} + win32 { SUBDIRS += registerfiletypeoperation \ createshortcutoperation diff --git a/tests/auto/tools/repotest/tst_repotest.cpp b/tests/auto/tools/repotest/tst_repotest.cpp index f27acfe89..af48ba3fc 100644 --- a/tests/auto/tools/repotest/tst_repotest.cpp +++ b/tests/auto/tools/repotest/tst_repotest.cpp @@ -30,8 +30,11 @@ #include #include #include +#include + +#ifdef IFW_LIB7Z #include -#include +#endif #include #include @@ -94,12 +97,13 @@ private: QString existingUniteMeta7z = QInstallerTools::existingUniteMeta7z(m_repoInfo.repositoryDir); QCOMPARE(2, matches.count()); QCOMPARE(existingUniteMeta7z, matches.at(1)); - Lib7zArchive file(m_repoInfo.repositoryDir + QDir::separator() + matches.at(1)); - QVERIFY(file.open(QIODevice::ReadOnly)); + QScopedPointer file(ArchiveFactory::instance() + .create(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 = file.list(); + const QVector files = file->list(); for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) { if (fileIt->isDirectory) continue; @@ -288,7 +292,9 @@ private slots: void initTestCase() { +#ifdef IFW_LIB7Z Lib7z::initSevenZ(); +#endif } void testWithComponentMeta() diff --git a/tools/archivegen/archive.cpp b/tools/archivegen/archive.cpp index 56aae1b21..132c1bcc6 100644 --- a/tools/archivegen/archive.cpp +++ b/tools/archivegen/archive.cpp @@ -28,9 +28,12 @@ #include #include -#include #include +#ifdef IFW_LIB7Z +#include +#endif + #include #include #include @@ -105,8 +108,9 @@ int main(int argc, char *argv[]) throw QInstaller::Error(QCoreApplication::translate("archivegen", "Unknown compression level \"%1\". See 'archivgen --help'.").arg(value)); } - +#ifdef IFW_LIB7Z Lib7z::initSevenZ(); +#endif QString archiveFilename = args[0]; // Check if filename already has a supported suffix if (!ArchiveFactory::isSupportedType(archiveFilename)) diff --git a/tools/archivegen/archivegen.pro b/tools/archivegen/archivegen.pro index 9e1147d42..fef39ae6f 100644 --- a/tools/archivegen/archivegen.pro +++ b/tools/archivegen/archivegen.pro @@ -8,8 +8,9 @@ QT -= gui QT += qml xml CONFIG -= import_plugins - -LIBS += -l7z +CONFIG(lzmasdk) { + LIBS += -l7z +} CONFIG += console DESTDIR = $$IFW_APP_PATH -- cgit v1.2.3