From 716b30b1cdb3fdc7eb75ccffbada0e223a2e7086 Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Thu, 17 Nov 2022 14:04:52 +0200 Subject: Fix errors occurring in full uninstall on macOS Maintenance Tool can be retrieved from online repositories like any other component. The component contains files which are listed to remove correct files in uninstall. As Maintenance Tool differs a bit from other components in the matter that it should not be deleted in full uninstall as it is running, we need to exclude the Maintenance Tool (which we call also installerbasebinary), from the file list. Maintenance Tool itself is removed in PackageManagerCorePrivate::deleteMaintenanceTool() Task-number: QTIFW-2875 Change-Id: I33a16e632e3b354099b749d8dde7b65f5cef8f43 Reviewed-by: Qt CI Bot Reviewed-by: Arttu Tarkiainen --- .../installer/extractarchiveoperationtest/data.qrc | 3 ++ .../data/installerbaserepository/A/1.0.0content.7z | Bin 0 -> 98 bytes .../A/1.0.0installerbase.7z | Bin 0 -> 114 bytes .../data/installerbaserepository/Updates.xml | 13 ++++++++ .../tst_extractarchiveoperationtest.cpp | 33 +++++++++++++++++++++ 5 files changed, 49 insertions(+) create mode 100644 tests/auto/installer/extractarchiveoperationtest/data/installerbaserepository/A/1.0.0content.7z create mode 100644 tests/auto/installer/extractarchiveoperationtest/data/installerbaserepository/A/1.0.0installerbase.7z create mode 100644 tests/auto/installer/extractarchiveoperationtest/data/installerbaserepository/Updates.xml (limited to 'tests/auto') diff --git a/tests/auto/installer/extractarchiveoperationtest/data.qrc b/tests/auto/installer/extractarchiveoperationtest/data.qrc index a8cc1a892..87f648568 100644 --- a/tests/auto/installer/extractarchiveoperationtest/data.qrc +++ b/tests/auto/installer/extractarchiveoperationtest/data.qrc @@ -11,5 +11,8 @@ data/xmloperationrepository/A/1.0.0content4.zip data/xmloperationrepository/A/1.0.0anothercontent.7z data/xmloperationrepository/A/1.0.0default.7z + data/installerbaserepository/Updates.xml + data/installerbaserepository/A/1.0.0content.7z + data/installerbaserepository/A/1.0.0installerbase.7z diff --git a/tests/auto/installer/extractarchiveoperationtest/data/installerbaserepository/A/1.0.0content.7z b/tests/auto/installer/extractarchiveoperationtest/data/installerbaserepository/A/1.0.0content.7z new file mode 100644 index 000000000..585f58296 Binary files /dev/null and b/tests/auto/installer/extractarchiveoperationtest/data/installerbaserepository/A/1.0.0content.7z differ diff --git a/tests/auto/installer/extractarchiveoperationtest/data/installerbaserepository/A/1.0.0installerbase.7z b/tests/auto/installer/extractarchiveoperationtest/data/installerbaserepository/A/1.0.0installerbase.7z new file mode 100644 index 000000000..c3b6aec9c Binary files /dev/null and b/tests/auto/installer/extractarchiveoperationtest/data/installerbaserepository/A/1.0.0installerbase.7z differ diff --git a/tests/auto/installer/extractarchiveoperationtest/data/installerbaserepository/Updates.xml b/tests/auto/installer/extractarchiveoperationtest/data/installerbaserepository/Updates.xml new file mode 100644 index 000000000..887300c97 --- /dev/null +++ b/tests/auto/installer/extractarchiveoperationtest/data/installerbaserepository/Updates.xml @@ -0,0 +1,13 @@ + + {AnyApplication} + 1.0.0 + + A + InstallerBase + Example component InstallerBase + 1.0.0 + 2015-01-01 + true + installerbase.7z,content.7z + + diff --git a/tests/auto/installer/extractarchiveoperationtest/tst_extractarchiveoperationtest.cpp b/tests/auto/installer/extractarchiveoperationtest/tst_extractarchiveoperationtest.cpp index 89492bd94..a8a65e983 100644 --- a/tests/auto/installer/extractarchiveoperationtest/tst_extractarchiveoperationtest.cpp +++ b/tests/auto/installer/extractarchiveoperationtest/tst_extractarchiveoperationtest.cpp @@ -177,6 +177,39 @@ private slots: QVERIFY(dir.removeRecursively()); } + void testInstallerBaseBinaryExtraction() + { + m_testDirectory = QInstaller::generateTemporaryFileName(); + QVERIFY(QDir().mkpath(m_testDirectory)); + QVERIFY(QDir(m_testDirectory).exists()); + + QScopedPointer core(PackageManager::getPackageManagerWithInit + (m_testDirectory, ":///data/installerbaserepository")); + core->setInstallerBaseBinary(m_testDirectory + QDir::separator() + "testInstallerBase.txt"); + core->installDefaultComponentsSilently(); + + QFile contentResourceFile(m_testDirectory + QDir::separator() + "installerResources" + QDir::separator() + "A" + QDir::separator() + "1.0.0content.txt"); + QVERIFY2(contentResourceFile.open(QIODevice::ReadOnly | QIODevice::Text), "Could not open content resource file for reading."); + QTextStream fileStream(&contentResourceFile); + QString line = fileStream.readLine(); + QVERIFY2(!line.isEmpty(), "Content not written to resource file."); + contentResourceFile.close(); + + QFile installerBaseResourceFile(m_testDirectory + QDir::separator() + "installerResources" + QDir::separator() + "A" + QDir::separator() + "1.0.0installerbase.txt"); + QVERIFY2(installerBaseResourceFile.open(QIODevice::ReadOnly | QIODevice::Text), "Could not open installerbase resource file for reading."); + QTextStream fileStream2(&installerBaseResourceFile); + line = installerBaseResourceFile.readLine(); + QVERIFY2(line.isEmpty(), "Installerbase falsly written to resource file."); + installerBaseResourceFile.close(); + + core->setPackageManager(); + core->commitSessionOperations(); + + QCOMPARE(PackageManagerCore::Success, core->uninstallComponentsSilently(QStringList() << "A")); + QDir dir(m_testDirectory); + QVERIFY(dir.removeRecursively()); + } + private: QString m_testDirectory; }; -- cgit v1.2.3