diff options
author | Katja Marttila <katja.marttila@qt.io> | 2020-12-20 11:31:30 +0200 |
---|---|---|
committer | Katja Marttila <katja.marttila@qt.io> | 2020-12-22 08:38:36 +0200 |
commit | a606c9915b8ff1d6001a83aa350400d6286706ff (patch) | |
tree | 33fba20f96caf98be8d42382763d0f93f92a9366 /src/libs/installer | |
parent | b7df5571e0707f53716fa51d426d5ec31d36af43 (diff) |
Introduce ForcedUpdate element for component
Setting ForcedUpdate for component will cause a mandatory update for
component if it is installed. Component must be updated before any other
component can be updated/installed/removed. Essential components are updated
at the same time with ForcedUpdate.
Task-number: QTIFW-1565
Change-Id: I6af07fba222371e8cd161d1fec65301450077d86
Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
Diffstat (limited to 'src/libs/installer')
-rw-r--r-- | src/libs/installer/component.cpp | 16 | ||||
-rw-r--r-- | src/libs/installer/component.h | 1 | ||||
-rw-r--r-- | src/libs/installer/constants.h | 1 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore.cpp | 30 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore_p.cpp | 4 | ||||
-rw-r--r-- | src/libs/installer/printoutput.cpp | 1 |
6 files changed, 41 insertions, 12 deletions
diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp index cb028b940..4d614d242 100644 --- a/src/libs/installer/component.cpp +++ b/src/libs/installer/component.cpp @@ -314,6 +314,7 @@ void Component::loadDataFromPackage(const Package &package) setValue(scSortingPriority, package.data(scSortingPriority).toString()); setValue(scEssential, package.data(scEssential).toString()); + setValue(scForcedUpdate, package.data(scForcedUpdate).toString()); setValue(scUpdateText, package.data(scUpdateText).toString()); setValue(scNewComponent, package.data(scNewComponent).toString()); setValue(scRequiresAdminRights, package.data(scRequiresAdminRights).toString()); @@ -1341,8 +1342,10 @@ bool Component::isAutoDependOn(const QSet<QString> &componentsToInstall) const if (componentsToInstall.contains(autoDependOnSet)) { foreach (const QString &autoDep, autoDependOnSet) { Component *component = packageManagerCore()->componentByName(autoDep); - if (component->value(scEssential, scFalse).toLower() == scTrue) + if ((component->value(scEssential, scFalse).toLower() == scTrue) + || component->isForcedUpdate()) { return true; + } } } return false; @@ -1449,6 +1452,17 @@ bool Component::componentChangeRequested() return updateRequested() || isSelectedForInstallation() || uninstallationRequested(); } +/*! + Returns \c true if the component is installed and has a \c ForcedUpdate flag set. + ForcedUpdate components will be updated together with essential components before + any other component can be updated or installed. + + \sa {component::isForcedUpdate}{component.isForcedUpdate} +*/ +bool Component::isForcedUpdate() +{ + return isInstalled() && (value(scForcedUpdate, scFalse).toLower() == scTrue); +} /*! \sa {component::setUninstalled}{component.setUninstalled} diff --git a/src/libs/installer/component.h b/src/libs/installer/component.h index 494d79b13..f7f03391f 100644 --- a/src/libs/installer/component.h +++ b/src/libs/installer/component.h @@ -191,6 +191,7 @@ public: Q_INVOKABLE bool updateRequested(); Q_INVOKABLE bool componentChangeRequested(); + Q_INVOKABLE bool isForcedUpdate(); bool isUnstable() const; void setUnstable(Component::UnstableError error, const QString &errorMessage = QString()); diff --git a/src/libs/installer/constants.h b/src/libs/installer/constants.h index 711aaa66b..be42426fb 100644 --- a/src/libs/installer/constants.h +++ b/src/libs/installer/constants.h @@ -50,6 +50,7 @@ static const QLatin1String scInheritVersion("inheritVersionFrom"); static const QLatin1String scReplaces("Replaces"); static const QLatin1String scDownloadableArchives("DownloadableArchives"); static const QLatin1String scEssential("Essential"); +static const QLatin1String scForcedUpdate("ForcedUpdate"); static const QLatin1String scTargetDir("TargetDir"); static const QLatin1String scReleaseDate("ReleaseDate"); static const QLatin1String scDescription("Description"); diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index e4b0e1689..8e205b7d7 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -1551,12 +1551,18 @@ bool PackageManagerCore::fetchPackagesTree(const PackagesList &packages, const L return false; if (success && isPackageManager()) { foreach (Package *const update, packages) { - if (update->data(scEssential, scFalse).toString().toLower() == scTrue) { + bool essentialUpdate = (update->data(scEssential, scFalse).toString().toLower() == scTrue); + bool forcedUpdate = (update->data(scForcedUpdate, scFalse).toString().toLower() == scTrue); + if (essentialUpdate || forcedUpdate) { const QString name = update->data(scName).toString(); - if (!installedPackages.contains(name)) { + // 'Essential' package not installed, install. + if (essentialUpdate && !installedPackages.contains(name)) { success = false; - continue; // unusual, the maintenance tool should always be available + continue; } + // 'Forced update' package not installed, no update needed + if (forcedUpdate && !installedPackages.contains(name)) + continue; const LocalPackage localPackage = installedPackages.value(name); const QString updateVersion = update->data(scVersion).toString(); @@ -1568,7 +1574,7 @@ bool PackageManagerCore::fetchPackagesTree(const PackagesList &packages, const L continue; // remote release date equals or is less than the installed maintenance tool success = false; - break; // we found a newer version of the maintenance tool + break; // we found a newer version of the forced/essential update package } } @@ -2290,7 +2296,8 @@ PackageManagerCore::Status PackageManagerCore::updateComponentsSilently(const QS // restart installer and install rest of the updates. bool essentialUpdatesFound = false; foreach (Component *component, componentList) { - if (component->value(scEssential, scFalse).toLower() == scTrue) + if ((component->value(scEssential, scFalse).toLower() == scTrue) + || component->isForcedUpdate()) essentialUpdatesFound = true; } if (!essentialUpdatesFound) { @@ -3634,8 +3641,10 @@ bool PackageManagerCore::fetchUpdaterPackages(const PackagesList &remotes, const if (localPackage.lastUpdateDate > updateDate) continue; - if (update->data(scEssential, scFalse).toString().toLower() == scTrue) + if (update->data(scEssential, scFalse).toString().toLower() == scTrue || + update->data(scForcedUpdate, scFalse).toString().toLower() == scTrue) { setFoundEssentialUpdate(true); + } // this is not a dependency, it is a real update components.insert(name, d->m_updaterComponentsDeps.takeLast()); @@ -3693,13 +3702,14 @@ bool PackageManagerCore::fetchUpdaterPackages(const PackagesList &remotes, const component->setCheckable(false); component->setSelectable(false); - if (component->value(scEssential, scFalse).toLower() == scFalse) { + if ((component->value(scEssential, scFalse).toLower() == scTrue) + || (component->value(scForcedUpdate, scFalse).toLower() == scTrue)) { + // essential updates are enabled, still not checkable but checked + component->setEnabled(true); + } else { // non essential updates are disabled, not checkable and unchecked component->setEnabled(false); component->setCheckState(Qt::Unchecked); - } else { - // essential updates are enabled, still not checkable but checked - component->setEnabled(true); } } } diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index 79e07a9f9..b3c543758 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -1996,8 +1996,10 @@ void PackageManagerCorePrivate::installComponent(Component *component, double pr if (!ok && !ignoreError) throw Error(operation->errorString()); - if ((component->value(scEssential, scFalse) == scTrue) && !m_core->isCommandLineInstance()) + if (((component->value(scEssential, scFalse) == scTrue) || (component->value(scForcedUpdate, scFalse) == scTrue)) + && !m_core->isCommandLineInstance()) { m_needsHardRestart = true; + } } registerPathsForUninstallation(component->pathsForUninstallation(), component->name()); diff --git a/src/libs/installer/printoutput.cpp b/src/libs/installer/printoutput.cpp index 1759d6642..27281aaf0 100644 --- a/src/libs/installer/printoutput.cpp +++ b/src/libs/installer/printoutput.cpp @@ -104,6 +104,7 @@ void printPackageInformation(const PackagesList &matchedPackages, const LocalPac update.setAttribute(QLatin1String("checkable"), package->data(scCheckable).toString()); update.setAttribute(QLatin1String("default"), package->data(scDefault).toString()); update.setAttribute(QLatin1String("essential"), package->data(scEssential).toString()); + update.setAttribute(QLatin1String("forcedUpdate"), package->data(scForcedUpdate).toString()); update.setAttribute(QLatin1String("compressedsize"), package->data(QLatin1String("CompressedSize")).toString()); update.setAttribute(QLatin1String("uncompressedsize"), package->data(QLatin1String("UncompressedSize")).toString()); update.setAttribute(QLatin1String("releaseDate"), package->data(scReleaseDate).toString()); |