diff options
30 files changed, 503 insertions, 13 deletions
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index 81c0bea3a..5ebe44d6c 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -3787,8 +3787,8 @@ bool PackageManagerCore::updateComponentData(struct Data &data, Component *compo foreach (const QString &componentName, componentsToReplace) { if (data.installedPackages->contains(componentName)) { // We found a replacement that is installed. - if (isPackageManager()) { - // Mark the replacement component as installed as well. Only do this in package manager + if (isUpdater()) { + // Mark the replacement component as installed as well. Only do this in updater // mode, otherwise it would not show up in the updaters component list. component->setInstalled(); component->setValue(scInstalledVersion, data.installedPackages->value(componentName).version); @@ -3826,14 +3826,7 @@ void PackageManagerCore::storeReplacedComponents(QHash<QString, Component *> &co qCWarning(QInstaller::lcDeveloperBuild) << componentName << "- Does not exist in the repositories anymore."; continue; } - if (!d->componentsToReplace().contains(componentName)) { - componentToReplace = new Component(this); - componentToReplace->setValue(scName, componentName); - } else { - // This case can happen when in installer mode as well, a component - // is in the installer binary and its replacement component as well. - d->replacementDependencyComponents().append(componentToReplace); - } + d->replacementDependencyComponents().append(componentToReplace); d->componentsToReplace().insert(componentName, qMakePair(it.key(), componentToReplace)); } } @@ -4009,7 +4002,7 @@ bool PackageManagerCore::fetchUpdaterPackages(const PackagesList &remotes, const installedPackages.take(name); // remove from local installed packages bool isValidUpdate = locals.contains(name); - if (!isValidUpdate && !replaces.isEmpty()) { + if (!replaces.isEmpty()) { const QStringList possibleNames = replaces.split(QInstaller::commaRegExp(), Qt::SkipEmptyParts); foreach (const QString &possibleName, possibleNames) { @@ -4050,9 +4043,18 @@ bool PackageManagerCore::fetchUpdaterPackages(const PackagesList &remotes, const QInstaller::Component *component = new QInstaller::Component(this); component->loadDataFromPackage(installedPackages.value(key)); d->m_updaterComponentsDeps.append(component); + } + + foreach (const QString &key, locals.keys()) { // Keep a list of local components that should be replaced - if (replaceMes.contains(component->name())) + // Remove from components list - we don't want to update the component + // as it is replaced by other component + if (replaceMes.contains(key)) { + QInstaller::Component *component = new QInstaller::Component(this); + component->loadDataFromPackage(locals.value(key)); localReplaceMes.insert(component->name(), component); + delete components.take(component->name()); + } } // store all components that got a replacement, but do not modify the components list diff --git a/tests/auto/installer/componentreplace/componentreplace.pro b/tests/auto/installer/componentreplace/componentreplace.pro new file mode 100644 index 000000000..9df6f81ca --- /dev/null +++ b/tests/auto/installer/componentreplace/componentreplace.pro @@ -0,0 +1,9 @@ +include(../../qttest.pri) + +QT += qml + +SOURCES += tst_componentreplace.cpp + +RESOURCES += \ + settings.qrc \ + ../shared/config.qrc diff --git a/tests/auto/installer/componentreplace/data/installPackagesRepository/A.sub1/1.0.0content.7z b/tests/auto/installer/componentreplace/data/installPackagesRepository/A.sub1/1.0.0content.7z Binary files differnew file mode 100644 index 000000000..adcc21ad7 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/installPackagesRepository/A.sub1/1.0.0content.7z diff --git a/tests/auto/installer/componentreplace/data/installPackagesRepository/A/1.0.0content.7z b/tests/auto/installer/componentreplace/data/installPackagesRepository/A/1.0.0content.7z Binary files differnew file mode 100644 index 000000000..916fdd1d0 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/installPackagesRepository/A/1.0.0content.7z diff --git a/tests/auto/installer/componentreplace/data/installPackagesRepository/B.sub1/1.0.0content.7z b/tests/auto/installer/componentreplace/data/installPackagesRepository/B.sub1/1.0.0content.7z Binary files differnew file mode 100644 index 000000000..ab63152f8 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/installPackagesRepository/B.sub1/1.0.0content.7z diff --git a/tests/auto/installer/componentreplace/data/installPackagesRepository/B/1.0.0content.7z b/tests/auto/installer/componentreplace/data/installPackagesRepository/B/1.0.0content.7z Binary files differnew file mode 100644 index 000000000..7b957b077 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/installPackagesRepository/B/1.0.0content.7z diff --git a/tests/auto/installer/componentreplace/data/installPackagesRepository/Updates.xml b/tests/auto/installer/componentreplace/data/installPackagesRepository/Updates.xml new file mode 100644 index 000000000..6f02aad2b --- /dev/null +++ b/tests/auto/installer/componentreplace/data/installPackagesRepository/Updates.xml @@ -0,0 +1,45 @@ +<Updates> + <ApplicationName>{AnyApplication}</ApplicationName> + <ApplicationVersion>1.0.0</ApplicationVersion> + <Checksum>false</Checksum> + <PackageUpdate> + <Name>A</Name> + <DisplayName>A</DisplayName> + <Description>Example component A</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="74" CompressedSize="224" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>53892cfe4d5f5b978553d3aa172944117604ef9c</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>A.sub1</Name> + <DisplayName>A subcomponent 1</DisplayName> + <Description>Subcomponent of component A</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="89" CompressedSize="247" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>8bd5a1d2525cfdfb690a3c80165aeed44a17795f</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>B</Name> + <DisplayName>B</DisplayName> + <Description>Example component B</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="74" CompressedSize="224" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>b2d03273f01f45878c3f5081cc8502edc0826e08</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>B.sub1</Name> + <DisplayName>B subcomponent 1</DisplayName> + <Description>Subcomponent of component B</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="89" CompressedSize="247" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>a10463141e30ce3fede9ac84bc52a07b0c5e919e</SHA1> + </PackageUpdate> +</Updates> diff --git a/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/A.sub1/1.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/A.sub1/1.0.0content.7z Binary files differnew file mode 100644 index 000000000..adcc21ad7 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/A.sub1/1.0.0content.7z diff --git a/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/A/1.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/A/1.0.0content.7z Binary files differnew file mode 100644 index 000000000..916fdd1d0 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/A/1.0.0content.7z diff --git a/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/B.sub1/1.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/B.sub1/1.0.0content.7z Binary files differnew file mode 100644 index 000000000..ab63152f8 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/B.sub1/1.0.0content.7z diff --git a/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/B/1.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/B/1.0.0content.7z Binary files differnew file mode 100644 index 000000000..7b957b077 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/B/1.0.0content.7z diff --git a/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/Updates.xml b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/Updates.xml new file mode 100644 index 000000000..c6b85077b --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/Updates.xml @@ -0,0 +1,46 @@ +<Updates> + <ApplicationName>{AnyApplication}</ApplicationName> + <ApplicationVersion>1.0.0</ApplicationVersion> + <Checksum>false</Checksum> + <PackageUpdate> + <Name>A</Name> + <DisplayName>A</DisplayName> + <Description>Example component A</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="74" CompressedSize="224" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>dd48e40f2f86559b20288424a6a3e2a1a05a172d</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>A.sub1</Name> + <DisplayName>A subcomponent 1</DisplayName> + <Description>Subcomponent of component A</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="89" CompressedSize="247" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>f8ff5da138516b1f800e641ab4999301dcb3c78b</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>B</Name> + <DisplayName>B</DisplayName> + <Description>Example component B</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <Replaces>A, A.sub1</Replaces> + <UpdateFile UncompressedSize="74" CompressedSize="224" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>8e83334a4a3c9c9d2bb6b073858d980da2c8871f</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>B.sub1</Name> + <DisplayName>B subcomponent 1</DisplayName> + <Description>Subcomponent of component B</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="89" CompressedSize="247" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>36d374bbbfbe87a18f6b308e5398360e9cc54a84</SHA1> + </PackageUpdate> +</Updates> diff --git a/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/A.sub1/1.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/A.sub1/1.0.0content.7z Binary files differnew file mode 100644 index 000000000..adcc21ad7 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/A.sub1/1.0.0content.7z diff --git a/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/A/2.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/A/2.0.0content.7z Binary files differnew file mode 100644 index 000000000..916fdd1d0 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/A/2.0.0content.7z diff --git a/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/B.sub1/1.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/B.sub1/1.0.0content.7z Binary files differnew file mode 100644 index 000000000..ab63152f8 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/B.sub1/1.0.0content.7z diff --git a/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/B/2.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/B/2.0.0content.7z Binary files differnew file mode 100644 index 000000000..7b957b077 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/B/2.0.0content.7z diff --git a/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/Updates.xml b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/Updates.xml new file mode 100644 index 000000000..5276637ed --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/Updates.xml @@ -0,0 +1,46 @@ +<Updates> + <ApplicationName>{AnyApplication}</ApplicationName> + <ApplicationVersion>1.0.0</ApplicationVersion> + <Checksum>false</Checksum> + <PackageUpdate> + <Name>A</Name> + <DisplayName>A</DisplayName> + <Description>Example component A</Description> + <Version>2.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="74" OS="Any" CompressedSize="224"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>28cd1210a590a97a9c0507cc39519b55d8f0a08b</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>A.sub1</Name> + <DisplayName>A subcomponent 1</DisplayName> + <Description>Subcomponent of component A</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="89" OS="Any" CompressedSize="247"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>9295f5a7f58c5e27a1c9ecf580f54a9328085aa5</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>B</Name> + <DisplayName>B</DisplayName> + <Description>Example component B</Description> + <Version>2.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <Replaces>A, A.sub1</Replaces> + <UpdateFile UncompressedSize="74" OS="Any" CompressedSize="224"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>b55f66866b7b909021f517941e921fd183fac7b0</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>B.sub1</Name> + <DisplayName>B subcomponent 1</DisplayName> + <Description>Subcomponent of component B</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="89" OS="Any" CompressedSize="247"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>4331736562fc047a4f47263be75f816298cbda30</SHA1> + </PackageUpdate> +</Updates> diff --git a/tests/auto/installer/componentreplace/data/repositoryWithReplace/A.sub1/1.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithReplace/A.sub1/1.0.0content.7z Binary files differnew file mode 100644 index 000000000..adcc21ad7 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithReplace/A.sub1/1.0.0content.7z diff --git a/tests/auto/installer/componentreplace/data/repositoryWithReplace/A/1.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithReplace/A/1.0.0content.7z Binary files differnew file mode 100644 index 000000000..916fdd1d0 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithReplace/A/1.0.0content.7z diff --git a/tests/auto/installer/componentreplace/data/repositoryWithReplace/B.sub1/1.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithReplace/B.sub1/1.0.0content.7z Binary files differnew file mode 100644 index 000000000..ab63152f8 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithReplace/B.sub1/1.0.0content.7z diff --git a/tests/auto/installer/componentreplace/data/repositoryWithReplace/B/2.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithReplace/B/2.0.0content.7z Binary files differnew file mode 100644 index 000000000..7b957b077 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithReplace/B/2.0.0content.7z diff --git a/tests/auto/installer/componentreplace/data/repositoryWithReplace/Updates.xml b/tests/auto/installer/componentreplace/data/repositoryWithReplace/Updates.xml new file mode 100644 index 000000000..ec74ac3e5 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithReplace/Updates.xml @@ -0,0 +1,46 @@ +<Updates> + <ApplicationName>{AnyApplication}</ApplicationName> + <ApplicationVersion>1.0.0</ApplicationVersion> + <Checksum>false</Checksum> + <PackageUpdate> + <Name>A</Name> + <DisplayName>A</DisplayName> + <Description>Example component A</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="74" CompressedSize="224" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>dba535b00f3ee2bc8387a299940384af3af3489b</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>A.sub1</Name> + <DisplayName>A subcomponent 1</DisplayName> + <Description>Subcomponent of component A</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="89" CompressedSize="247" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>ca3e5cdf08361775f744a6d6ec1837aae03cdc28</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>B</Name> + <DisplayName>B</DisplayName> + <Description>Example component B</Description> + <Version>2.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <Replaces>A</Replaces> + <UpdateFile UncompressedSize="74" CompressedSize="224" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>c30d2146844195d27879e5360e864c4eae7b4cde</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>B.sub1</Name> + <DisplayName>B subcomponent 1</DisplayName> + <Description>Subcomponent of component B</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="89" CompressedSize="247" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>05124ea8feadb6a5d8d9222cc41898ef72d562bb</SHA1> + </PackageUpdate> +</Updates> diff --git a/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/A.sub1/1.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/A.sub1/1.0.0content.7z Binary files differnew file mode 100644 index 000000000..adcc21ad7 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/A.sub1/1.0.0content.7z diff --git a/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/A/2.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/A/2.0.0content.7z Binary files differnew file mode 100644 index 000000000..916fdd1d0 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/A/2.0.0content.7z diff --git a/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/B.sub1/1.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/B.sub1/1.0.0content.7z Binary files differnew file mode 100644 index 000000000..ab63152f8 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/B.sub1/1.0.0content.7z diff --git a/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/B/2.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/B/2.0.0content.7z Binary files differnew file mode 100644 index 000000000..7b957b077 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/B/2.0.0content.7z diff --git a/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/Updates.xml b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/Updates.xml new file mode 100644 index 000000000..b1846f7b1 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/Updates.xml @@ -0,0 +1,46 @@ +<Updates> + <ApplicationName>{AnyApplication}</ApplicationName> + <ApplicationVersion>1.0.0</ApplicationVersion> + <Checksum>false</Checksum> + <PackageUpdate> + <Name>A</Name> + <DisplayName>A</DisplayName> + <Description>Example component A</Description> + <Version>2.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile CompressedSize="224" OS="Any" UncompressedSize="74"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>a0dc47264727fd2e6a6cdd2fa879388eb732ac73</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>A.sub1</Name> + <DisplayName>A subcomponent 1</DisplayName> + <Description>Subcomponent of component A</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile CompressedSize="247" OS="Any" UncompressedSize="89"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>7b5fb2c36cb4a784816c34839d7ce4ac0114df50</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>B</Name> + <DisplayName>B</DisplayName> + <Description>Example component B</Description> + <Version>2.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <Replaces>A</Replaces> + <UpdateFile CompressedSize="224" OS="Any" UncompressedSize="74"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>9baaa7eaca7002ba10addc22306bb9383d2e5b46</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>B.sub1</Name> + <DisplayName>B subcomponent 1</DisplayName> + <Description>Subcomponent of component B</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile CompressedSize="247" OS="Any" UncompressedSize="89"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>f840d6cd369d9dc471f0a718ff5c8c000d07d72c</SHA1> + </PackageUpdate> +</Updates> diff --git a/tests/auto/installer/componentreplace/settings.qrc b/tests/auto/installer/componentreplace/settings.qrc new file mode 100644 index 000000000..706cf91c6 --- /dev/null +++ b/tests/auto/installer/componentreplace/settings.qrc @@ -0,0 +1,29 @@ +<RCC> + <qresource prefix="/"> + <file>data/installPackagesRepository/Updates.xml</file> + <file>data/installPackagesRepository/A/1.0.0content.7z</file> + <file>data/installPackagesRepository/B/1.0.0content.7z</file> + <file>data/installPackagesRepository/A.sub1/1.0.0content.7z</file> + <file>data/installPackagesRepository/B.sub1/1.0.0content.7z</file> + <file>data/repositoryWithReplace/Updates.xml</file> + <file>data/repositoryWithReplace/A/1.0.0content.7z</file> + <file>data/repositoryWithReplace/B/2.0.0content.7z</file> + <file>data/repositoryWithReplace/A.sub1/1.0.0content.7z</file> + <file>data/repositoryWithReplace/B.sub1/1.0.0content.7z</file> + <file>data/repositoryWithUpdateToReplaceble/Updates.xml</file> + <file>data/repositoryWithUpdateToReplaceble/A/2.0.0content.7z</file> + <file>data/repositoryWithUpdateToReplaceble/B/2.0.0content.7z</file> + <file>data/repositoryWithUpdateToReplaceble/A.sub1/1.0.0content.7z</file> + <file>data/repositoryWithUpdateToReplaceble/B.sub1/1.0.0content.7z</file> + <file>data/repositoryWithMultiReplace/Updates.xml</file> + <file>data/repositoryWithMultiReplace/A/1.0.0content.7z</file> + <file>data/repositoryWithMultiReplace/B/1.0.0content.7z</file> + <file>data/repositoryWithMultiReplace/A.sub1/1.0.0content.7z</file> + <file>data/repositoryWithMultiReplace/B.sub1/1.0.0content.7z</file> + <file>data/repositoryWithMultiReplaceInUpdate/Updates.xml</file> + <file>data/repositoryWithMultiReplaceInUpdate/A/2.0.0content.7z</file> + <file>data/repositoryWithMultiReplaceInUpdate/B/2.0.0content.7z</file> + <file>data/repositoryWithMultiReplaceInUpdate/A.sub1/1.0.0content.7z</file> + <file>data/repositoryWithMultiReplaceInUpdate/B.sub1/1.0.0content.7z</file> + </qresource> +</RCC> diff --git a/tests/auto/installer/componentreplace/tst_componentreplace.cpp b/tests/auto/installer/componentreplace/tst_componentreplace.cpp new file mode 100644 index 000000000..55121019b --- /dev/null +++ b/tests/auto/installer/componentreplace/tst_componentreplace.cpp @@ -0,0 +1,220 @@ +/************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Installer Framework. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +**************************************************************************/ + +#include "../shared/packagemanager.h" +#include "../shared/verifyinstaller.h" + +#include <component.h> +#include <packagemanagercore.h> + +#include <QLoggingCategory> +#include <QTest> + +using namespace QInstaller; + +class tst_ComponentReplace : public QObject +{ + Q_OBJECT + +private: + void setRepository(const QString &repository, PackageManagerCore *core) + { + core->cancelMetaInfoJob(); //Call cancel to reset metadata so that update repositories are fetched + + QSet<Repository> repoList; + Repository repo = Repository::fromUserInput(repository); + repoList.insert(repo); + core->settings().setDefaultRepositories(repoList); + } + +private slots: + void initTestCase() + { + m_installDir = QInstaller::generateTemporaryFileName(); + } + + void replaceNonInstalledItem() + { + QScopedPointer<PackageManagerCore> core(PackageManager::getPackageManagerWithInit + (m_installDir, ":///data/repositoryWithReplace")); + QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() << "A" << "B")); + QList<Component*> installedComponents = core->orderedComponentsToInstall(); + + VerifyInstaller::verifyInstallerResources(m_installDir, "B", "2.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "Bsub1.txt" << "B.txt"); + } + + void replaceInstalledItem() + { + PackageManagerCore *core = PackageManager::getPackageManagerWithInit + (m_installDir, ":///data/installPackagesRepository"); + QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() << "A")); + + QCOMPARE(core->orderedComponentsToInstall().count(), 2); + VerifyInstaller::verifyInstallerResources(m_installDir, "A", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "A.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "Asub1.txt" << "A.txt"); + + core->commitSessionOperations(); + core->setPackageManager(); + setRepository(":///data/repositoryWithReplace", core); + QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() << "B")); + + QVERIFY(core->componentByName("B.sub1") != 0); + QVERIFY(core->componentByName("B") != 0); + QVERIFY(core->componentByName("A.sub1") != 0); + QVERIFY(core->componentByName("A") == 0); // B has replaced A + VerifyInstaller::verifyInstallerResources(m_installDir, "B", "2.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "Bsub1.txt" << "B.txt" << "Asub1.txt"); + delete core; + } + + void replaceInstalledItemInUpdate() + { + PackageManagerCore *core = PackageManager::getPackageManagerWithInit + (m_installDir, ":///data/installPackagesRepository"); + QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() << "A" << "B")); + + QCOMPARE(core->orderedComponentsToInstall().count(), 4); + VerifyInstaller::verifyInstallerResources(m_installDir, "A", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "A.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "Asub1.txt" << "A.txt"<< "Bsub1.txt" << "B.txt"); + + core->commitSessionOperations(); + core->setUpdater(); + setRepository(":///data/repositoryWithReplace", core); + QCOMPARE(PackageManagerCore::Success, core->updateComponentsSilently(QStringList() << "B")); + VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "A", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "A.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B", "2.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "Bsub1.txt" << "B.txt" << "Asub1.txt"); + delete core; + } + + void replaceInstalledItemContainingUpdateInUpdate() + { + PackageManagerCore *core = PackageManager::getPackageManagerWithInit + (m_installDir, ":///data/installPackagesRepository"); + QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() << "A" << "B")); + + QCOMPARE(core->orderedComponentsToInstall().count(), 4); + VerifyInstaller::verifyInstallerResources(m_installDir, "A", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "A.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "Asub1.txt" << "A.txt"<< "Bsub1.txt" << "B.txt"); + + core->commitSessionOperations(); + core->setUpdater(); + setRepository(":///data/repositoryWithUpdateToReplaceble", core); + QCOMPARE(PackageManagerCore::Success, core->updateComponentsSilently(QStringList() << "B")); + VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "A", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "A", "2.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "A.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B", "2.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "Bsub1.txt" << "B.txt" << "Asub1.txt"); + delete core; + } + + void replaceMultipleInstalledItems() + { + PackageManagerCore *core = PackageManager::getPackageManagerWithInit + (m_installDir, ":///data/installPackagesRepository"); + QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() << "A")); + + VerifyInstaller::verifyInstallerResources(m_installDir, "A", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "A.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "Asub1.txt" << "A.txt"); + + core->commitSessionOperations(); + core->setPackageManager(); + setRepository(":///data/repositoryWithMultiReplace", core); + QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() << "B")); + VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "A", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "A.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "Bsub1.txt" << "B.txt"); + delete core; + } + + void replaceMultipleInstalledItemsInUpdate() + { + PackageManagerCore *core = PackageManager::getPackageManagerWithInit + (m_installDir, ":///data/installPackagesRepository"); + QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() << "A" << "B")); + + QCOMPARE(core->orderedComponentsToInstall().count(), 4); + VerifyInstaller::verifyInstallerResources(m_installDir, "A", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "A.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "Asub1.txt" << "A.txt"<< "Bsub1.txt" << "B.txt"); + + core->commitSessionOperations(); + core->setUpdater(); + setRepository(":///data/repositoryWithMultiReplaceInUpdate", core); + QCOMPARE(PackageManagerCore::Success, core->updateComponentsSilently(QStringList() << "B")); + VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "A", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "A.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B", "2.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "Bsub1.txt" << "B.txt"); + delete core; + } + + void cleanup() + { + QDir dir(m_installDir); + QVERIFY(dir.removeRecursively()); + } +private: + QString m_installDir; +}; + + +QTEST_MAIN(tst_ComponentReplace) + +#include "tst_componentreplace.moc" diff --git a/tests/auto/installer/installer.pro b/tests/auto/installer/installer.pro index b877e5d20..947dc92a2 100644 --- a/tests/auto/installer/installer.pro +++ b/tests/auto/installer/installer.pro @@ -41,7 +41,8 @@ SUBDIRS += \ elevatedexecuteoperation \ treename \ createoffline \ - contentshaupdate + contentshaupdate \ + componentreplace CONFIG(libarchive) { SUBDIRS += libarchivearchive |