diff options
author | Kai Koehne <kai.koehne@digia.com> | 2014-08-25 15:26:44 +0200 |
---|---|---|
committer | Kai Koehne <kai.koehne@digia.com> | 2014-08-27 08:42:35 +0200 |
commit | 6254a18e0ee47619c445a50542abb4d59409c506 (patch) | |
tree | 59bec9d8877b781e323188359e79e831e7e8e0d5 | |
parent | 83ba7dbfb42d9abd319d8c6ed4f0357973b808dc (diff) |
Sanity-check for Qt SDK installations with broken uninstall operations
Task-number: QTIFW-535
Change-Id: If4f0ceaf577387c7b98d5b35908a9312e640549c
Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com>
Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
-rw-r--r-- | src/sdk/installerbase.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
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 <settings.h> #include <utils.h> #include <updater.h> +#include <messageboxhandler.h> #include <kdselfrestarter.h> #include <kdrunoncechecker.h> @@ -66,7 +67,6 @@ #include <QDirIterator> #include <QtCore/QTranslator> -#include <QMessageBox> #include <QtNetwork/QNetworkProxyFactory> @@ -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<QString> installedPackages = core.localInstalledPackages().keys().toSet(); + QSet<QString> operationPackages; + foreach (QInstaller::Operation *operation, content.performedOperations()) { + if (operation->hasValue(QLatin1String("component"))) + operationPackages.insert(operation->value(QLatin1String("component")).toString()); + } + + QSet<QString> packagesWithoutOperation = installedPackages - operationPackages; + QSet<QString> 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; |