From 13bbcdda36522ff10a650092fb5682a79edd27e6 Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Mon, 29 May 2017 11:12:53 +0300 Subject: Fix maintenance tool update with silentUpdate Maintenance tool is an essential update. Essential updates should be installed before non-essential updates. This change forces essential updates to be installed first. The behavior is same as when updating with visible UI. Task-number: QTIFW-976 Change-Id: I360145821c4e2d1f3384efca641208acb9338d5e Reviewed-by: Antti Kokko Reviewed-by: Iikka Eklund --- src/libs/installer/packagemanagercore.cpp | 28 +++++++++++++++++++++++----- src/libs/installer/packagemanagercore_p.cpp | 12 ++++++++++-- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index c4ba5ae4a..7b6842720 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -1816,21 +1816,39 @@ void PackageManagerCore::updateComponentsSilently() setMessageBoxAutomaticAnswer(QLatin1String("installationErrorWithRetry"), QMessageBox::Cancel); fetchRemotePackagesTree(); - //Mark all components to be installed + const QList componentList = components( ComponentType::Root | ComponentType::Descendants); if (componentList.count() == 0) { qDebug() << "No updates available."; } else { - foreach (Component *comp, componentList) { - comp->setCheckState(Qt::Checked); + // Check if essential components are available (essential components are disabled). + // If essential components are found, update first essential updates, + // restart installer and install rest of the updates. + bool essentialUpdatesFound = false; + foreach (Component *component, componentList) { + if (component->value(scEssential, scFalse).toLower() == scTrue) + essentialUpdatesFound = true; + } + if (!essentialUpdatesFound) { + //Mark all components to be updated + foreach (Component *comp, componentList) { + comp->setCheckState(Qt::Checked); + } } QString htmlOutput; bool componentsOk = calculateComponents(&htmlOutput); if (componentsOk) { - if (runPackageUpdater()) - qDebug() << "Components updated successfully."; + if (runPackageUpdater()) { + writeMaintenanceTool(); + if (essentialUpdatesFound) { + qDebug() << "Essential components updated successfully."; + } + else { + qDebug() << "Components updated successfully."; + } + } } else { qDebug() << htmlOutput; diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index 28d64d09c..fb802ef8b 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -162,8 +162,16 @@ static void deferredRename(const QString &oldName, const QString &newName, bool batch << " WScript.Sleep(1000)\n"; batch << "wend\n"; batch << QString::fromLatin1("fso.MoveFile \"%1\", file\n").arg(arguments[1]); - if (restart) - batch << QString::fromLatin1("tmp.exec \"%1 --updater\"\n").arg(arguments[2]); + if (restart) { + //Restart with same command line arguments as first executable + QStringList commandLineArguments = QCoreApplication::arguments(); + batch << QString::fromLatin1("tmp.exec \"%1 --updater").arg(arguments[2]); + //Skip the first argument as that is executable itself + for (int i = 1; i < commandLineArguments.count(); i++) { + batch << QString::fromLatin1(" %1").arg(commandLineArguments.at(i)); + } + batch << QString::fromLatin1("\"\n"); + } batch << "fso.DeleteFile(WScript.ScriptFullName)\n"; } -- cgit v1.2.3