diff options
author | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2023-09-26 16:29:13 +0300 |
---|---|---|
committer | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2023-09-29 06:33:57 +0000 |
commit | 7cf2c32cf0fb861ee02e12f2b0c578a3ddb69956 (patch) | |
tree | 5b9cf30f37883b8bba22db49eec97d13f8759676 /src/libs/installer/packagemanagercore_p.cpp | |
parent | 170d9b46b4f3ff3d1bdf9a1c2550c2c34ff9b591 (diff) |
Fix allowing selecting an alias depending on unstable alias for install
For the sanity check calculations, all component aliases are manually
selected to detect possible errors in packaging preventing installing
of an alias. As the order of install for selected aliases is undefined,
in some cases the installer did not detect that an alias requires an
unstable alias.
Consider an example scenario:
* aliasA -> requires aliasB
* aliasB -> requires aliasC
* aliasC -> missing from installer
The unstable status is set the first time we query for the required
aliases of an alias, so the case for "ReferenceToUnstable" could go
amiss if the required aliases list for "aliasA" was populated before
for "aliasB".
Fix by populating the required aliases and components in the order
of the alias dependency graph.
Change-Id: Id2fc9e3e1b315f5be98ca8915a0938abad1a2eb5
Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src/libs/installer/packagemanagercore_p.cpp')
-rw-r--r-- | src/libs/installer/packagemanagercore_p.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index 16e0b815a..2590564a7 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -452,8 +452,9 @@ bool PackageManagerCorePrivate::buildComponentAliases() m_componentAliases.insert(alias->name(), newAlias); } } + // After aliases are loaded, perform sanity checks: - // Component check state is changed by alias selection, so store the initial state + // 1. Component check state is changed by alias selection, so store the initial state storeCheckState(); Graph<QString> aliasGraph; @@ -473,8 +474,8 @@ bool PackageManagerCorePrivate::buildComponentAliases() } } - aliasGraph.sort(); - // Check for cyclic dependency errors + const QList<QString> sortedAliases = aliasGraph.sort(); + // 2. Check for cyclic dependency errors if (aliasGraph.hasCycle()) { setStatus(PackageManagerCore::Failure, installerCalculator()->error()); MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), QLatin1String("Error"), @@ -485,8 +486,19 @@ bool PackageManagerCorePrivate::buildComponentAliases() return false; } + // 3. Test for required aliases and components, this triggers setting the + // alias unstable in case of a broken reference. + for (const auto &aliasName : sortedAliases) { + ComponentAlias *alias = m_componentAliases.value(aliasName); + if (!alias) // sortedAliases may contain dependencies that don't exist, we don't know it yet + continue; + + alias->components(); + alias->aliases(); + } + clearInstallerCalculator(); - // Check for other errors preventing resolving components to install + // 4. Check for other errors preventing resolving components to install if (!installerCalculator()->solve(m_componentAliases.values())) { setStatus(PackageManagerCore::Failure, installerCalculator()->error()); MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), QLatin1String("Error"), @@ -498,7 +510,7 @@ bool PackageManagerCorePrivate::buildComponentAliases() for (auto *alias : qAsConst(m_componentAliases)) alias->setSelected(false); - // Restore original state + // 5. Restore original state restoreCheckState(); return true; |