From 6254a18e0ee47619c445a50542abb4d59409c506 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 25 Aug 2014 15:26:44 +0200 Subject: Sanity-check for Qt SDK installations with broken uninstall operations Task-number: QTIFW-535 Change-Id: If4f0ceaf577387c7b98d5b35908a9312e640549c Reviewed-by: Karsten Heimrich Reviewed-by: Tim Jenssen --- src/sdk/installerbase.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/sdk/installerbase.cpp b/src/sdk/installerbase.cpp index a3141def9..8c9fdad51 100644 --- a/src/sdk/installerbase.cpp +++ b/src/sdk/installerbase.cpp @@ -57,6 +57,7 @@ #include #include #include +#include #include #include @@ -66,7 +67,6 @@ #include #include -#include #include @@ -437,6 +437,34 @@ int main(int argc, char *argv[]) controller.setGui(new MaintenanceGui(&core)); } + // + // Sanity check to detect a broken installations with missing operations. + // Every installed package should have at least one MinimalProgress operation. + // + QSet installedPackages = core.localInstalledPackages().keys().toSet(); + QSet operationPackages; + foreach (QInstaller::Operation *operation, content.performedOperations()) { + if (operation->hasValue(QLatin1String("component"))) + operationPackages.insert(operation->value(QLatin1String("component")).toString()); + } + + QSet packagesWithoutOperation = installedPackages - operationPackages; + QSet orphanedOperations = operationPackages - installedPackages; + if (!packagesWithoutOperation.isEmpty() || !orphanedOperations.isEmpty()) { + qCritical() << "Operations missing for installed packages" << packagesWithoutOperation.toList(); + qCritical() << "Orphaned operations" << orphanedOperations.toList(); + MessageBoxHandler::critical( + MessageBoxHandler::currentBestSuitParent(), + QLatin1String("Corrupt_Installation_Error"), + QCoreApplication::translate("QInstaller", "Corrupt installation"), + QCoreApplication::translate("QInstaller", + "Your installation seems to be corrupted. " + "Please consider re-installing from scratch." + )); + } else { + qDebug() << "Operations sanity check succeeded."; + } + PackageManagerCore::Status status = PackageManagerCore::Status(controller.init()); if (status != PackageManagerCore::Success) return status; -- cgit v1.2.3