From 9f94110b7de18870d690d8ad102d26deceb17e0e Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Mon, 28 Sep 2020 14:28:33 +0300 Subject: Fix essential update When updating essential, no other components should be installed nor updated unless there is autodepend on the essential component. Task-number: QTIFW-1970 Change-Id: If9edd6515e3e5ec51611ac07ac52b13f05983b9d Reviewed-by: Arttu Tarkiainen --- src/libs/installer/component.cpp | 9 ++++-- .../Updates.xml | 26 +++++++++++++++ .../componentA/3.0.0content.7z | Bin 0 -> 257 bytes .../componentAutoDependOnA/1.0content.7z | Bin 0 -> 265 bytes .../auto/installer/commandlineupdate/settings.qrc | 3 ++ .../commandlineupdate/tst_commandlineupdate.cpp | 35 +++++++++++++++------ 6 files changed, 61 insertions(+), 12 deletions(-) create mode 100644 tests/auto/installer/commandlineupdate/data/repositoryWithDependencyToEssential/Updates.xml create mode 100644 tests/auto/installer/commandlineupdate/data/repositoryWithDependencyToEssential/componentA/3.0.0content.7z create mode 100644 tests/auto/installer/commandlineupdate/data/repositoryWithDependencyToEssential/componentAutoDependOnA/1.0content.7z diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp index 061c4e110..16b417b02 100644 --- a/src/libs/installer/component.cpp +++ b/src/libs/installer/component.cpp @@ -1295,12 +1295,15 @@ bool Component::isAutoDependOn(const QSet &componentsToInstall) const // will be installed if (packageManagerCore()->foundEssentialUpdate()) { const QSet autoDependOnSet = autoDependOnList.toSet(); - if (autoDependOnSet.intersects(componentsToInstall)) { - return true; + if (componentsToInstall.contains(autoDependOnSet)) { + foreach (const QString &autoDep, autoDependOnSet) { + Component *component = packageManagerCore()->componentByName(autoDep); + if (component->value(scEssential, scFalse).toLower() == scTrue) + return true; + } } return false; } - QSet components = componentsToInstall; const QStringList installedPackages = d->m_core->localInstalledPackages().keys(); foreach (const QString &name, installedPackages) diff --git a/tests/auto/installer/commandlineupdate/data/repositoryWithDependencyToEssential/Updates.xml b/tests/auto/installer/commandlineupdate/data/repositoryWithDependencyToEssential/Updates.xml new file mode 100644 index 000000000..1729f5732 --- /dev/null +++ b/tests/auto/installer/commandlineupdate/data/repositoryWithDependencyToEssential/Updates.xml @@ -0,0 +1,26 @@ + + {AnyApplication} + 1.0.0 + false + + componentA + Component A + This component does not depend on any other component. + 3.0.0 + 2015-08-25 + 100 + true + + content.7z + + + componentAutoDependOnA + Component, autodepends on A + Component, autodepends on A + 1.0 + 2018-03-14 + componentA + + content.7z + + diff --git a/tests/auto/installer/commandlineupdate/data/repositoryWithDependencyToEssential/componentA/3.0.0content.7z b/tests/auto/installer/commandlineupdate/data/repositoryWithDependencyToEssential/componentA/3.0.0content.7z new file mode 100644 index 000000000..e8c35fdea Binary files /dev/null and b/tests/auto/installer/commandlineupdate/data/repositoryWithDependencyToEssential/componentA/3.0.0content.7z differ diff --git a/tests/auto/installer/commandlineupdate/data/repositoryWithDependencyToEssential/componentAutoDependOnA/1.0content.7z b/tests/auto/installer/commandlineupdate/data/repositoryWithDependencyToEssential/componentAutoDependOnA/1.0content.7z new file mode 100644 index 000000000..0f3b123e0 Binary files /dev/null and b/tests/auto/installer/commandlineupdate/data/repositoryWithDependencyToEssential/componentAutoDependOnA/1.0content.7z differ diff --git a/tests/auto/installer/commandlineupdate/settings.qrc b/tests/auto/installer/commandlineupdate/settings.qrc index 812727cd2..a0a04a9e3 100644 --- a/tests/auto/installer/commandlineupdate/settings.qrc +++ b/tests/auto/installer/commandlineupdate/settings.qrc @@ -31,5 +31,8 @@ data/installPackagesRepositoryUpdate/componentF.subcomponent1.subsubcomponent2/1.0.0content.7z data/installPackagesRepositoryUpdate/componentF.subcomponent2.subsubcomponent1/1.0.0content.7z data/installPackagesRepositoryUpdate/componentF.subcomponent2.subsubcomponent2/1.0.0content.7z + data/repositoryWithDependencyToEssential/Updates.xml + data/repositoryWithDependencyToEssential/componentAutoDependOnA/1.0content.7z + data/repositoryWithDependencyToEssential/componentA/3.0.0content.7z diff --git a/tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp b/tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp index 7a61e9608..e465f8a75 100644 --- a/tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp +++ b/tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp @@ -86,28 +86,43 @@ private slots: QCOMPARE(PackageManagerCore::EssentialUpdated, core->updateComponentsSilently(QStringList())); VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "2.0.0content.txt"); VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt"); - //Because of bug QTIFW-1970 componentD got installed too VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" - << "installcontentA_update.txt" << "installcontentE.txt" << "installcontentG.txt" - << "installcontentD_update.txt"); + << "installcontentA_update.txt" << "installcontentE.txt" << "installcontentG.txt"); VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "componentA", "1.0.0content.txt"); //As we are using the same core in tests, clean the essentalupdate value core->setFoundEssentialUpdate(false); } + void testUpdateEssentialWithAutodependOnSilently() + { + setRepository(":///data/repositoryWithDependencyToEssential"); + QCOMPARE(PackageManagerCore::EssentialUpdated, core->updateComponentsSilently(QStringList())); + + VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "3.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "componentAutoDependOnA", "1.0content.txt"); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "installcontentA_update.txt" << "installcontentE.txt" << "installcontentG.txt" + << "installContentAutoDependOnA.txt"); + + //As we are using the same core in tests, clean the essentalupdate value + core->setFoundEssentialUpdate(false); + } + void testUpdatePackageSilently() { setRepository(":///data/installPackagesRepository"); QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() << "componentB")); QCOMPARE(PackageManagerCore::Success, core->status()); - //Because of bug QTIFW-1970 componentD got uninstalled. It should be installed now - //as its dependencies are installed. - VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "2.0.0content.txt"); + + VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "3.0.0content.txt"); VerifyInstaller::verifyInstallerResources(m_installDir, "componentB", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "componentD", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "componentAutoDependOnA", "1.0content.txt"); VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontentA_update.txt" << "installcontentE.txt" << "installcontentG.txt" - << "installcontentB.txt"); + << "installcontentB.txt" << "installcontentD.txt" + << "installContentAutoDependOnA.txt"); core->commitSessionOperations(); setRepository(":///data/installPackagesRepositoryUpdate"); @@ -115,16 +130,18 @@ private slots: << "componentB")); // componentD is autodependent and cannot be deselected // componentE is a forced component and thus will be updated - VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "2.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "3.0.0content.txt"); VerifyInstaller::verifyInstallerResources(m_installDir, "componentB", "2.0.0content.txt"); VerifyInstaller::verifyInstallerResources(m_installDir, "componentD", "2.0.0content.txt"); VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "2.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "componentAutoDependOnA", "1.0content.txt"); VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "componentD", "1.0.0content.txt"); VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "componentE", "1.0.0content.txt"); VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontentA_update.txt" << "installcontentE_update.txt" << "installcontentG.txt" - << "installcontentB_update.txt" << "installcontentD_update.txt"); + << "installcontentB_update.txt" << "installcontentD_update.txt" + << "installContentAutoDependOnA.txt"); } void testUpdateNoUpdatesForSelectedPackage() -- cgit v1.2.3