summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2017-03-14 14:30:09 +0200
committerKatja Marttila <katja.marttila@qt.io>2017-03-23 08:04:42 +0000
commit7ee08852f38b1ff2ff3638af46fcfca64cd12df7 (patch)
tree120439f321f3a9480fcfc5185904989ccbd630fc /src/libs
parent9772474dd97e5543035b5fd0dde4b731745e5057 (diff)
Make installer to check the dependency version
Installer was able to install dependency correctly. However, it ignored the version dependency might have. Dependencies>componentA->=4.0</Dependencies> If there was already a dependency installed with lower version number, the newer version, which was required by the selected component, was not installed. Fixed so that maintenancetool will not only check if the dependency is installed but also the installed version. Change-Id: Ia26b5233cf8847bce73095d19a13c481318d27f2 Task-number: QTIFW-914 Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/installer/component.cpp8
-rw-r--r--src/libs/installer/component.h2
-rw-r--r--src/libs/installer/installercalculator.cpp66
-rw-r--r--src/libs/installer/installercalculator.h4
4 files changed, 52 insertions, 28 deletions
diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp
index db9f2689d..d74b7ce7e 100644
--- a/src/libs/installer/component.cpp
+++ b/src/libs/installer/component.cpp
@@ -1241,9 +1241,13 @@ bool Component::isDefault() const
return d->m_vars.value(scDefault).compare(scTrue, Qt::CaseInsensitive) == 0;
}
-bool Component::isInstalled() const
+bool Component::isInstalled(const QString version) const
{
- return scInstalled == d->m_vars.value(scCurrentState);
+ if (version.isEmpty()) {
+ return scInstalled == d->m_vars.value(scCurrentState);
+ } else {
+ return d->m_vars.value(scInstalledVersion) == version;
+ }
}
/*!
diff --git a/src/libs/installer/component.h b/src/libs/installer/component.h
index 7492eaf54..01622548f 100644
--- a/src/libs/installer/component.h
+++ b/src/libs/installer/component.h
@@ -166,7 +166,7 @@ public:
Q_INVOKABLE bool isAutoDependOn(const QSet<QString> &componentsToInstall) const;
Q_INVOKABLE void setInstalled();
- Q_INVOKABLE bool isInstalled() const;
+ Q_INVOKABLE bool isInstalled(const QString version = QString()) const;
Q_INVOKABLE bool installationRequested() const;
bool isSelectedForInstallation() const;
diff --git a/src/libs/installer/installercalculator.cpp b/src/libs/installer/installercalculator.cpp
index 03c62033e..064dbafa5 100644
--- a/src/libs/installer/installercalculator.cpp
+++ b/src/libs/installer/installercalculator.cpp
@@ -92,9 +92,9 @@ QString InstallerCalculator::componentsToInstallError() const
return m_componentsToInstallError;
}
-void InstallerCalculator::realAppendToInstallComponents(Component *component)
+void InstallerCalculator::realAppendToInstallComponents(Component *component, const QString &version)
{
- if (!component->isInstalled() || component->updateRequested()) {
+ if (!component->isInstalled(version) || component->updateRequested()) {
m_orderedComponentsToInstall.append(component);
m_toInstallComponentIds.insert(component->name());
}
@@ -154,10 +154,10 @@ bool InstallerCalculator::appendComponentsToInstall(const QList<Component *> &co
return true;
}
-bool InstallerCalculator::appendComponentToInstall(Component *component)
+bool InstallerCalculator::appendComponentToInstall(Component *component, const QString &version)
{
QSet<QString> allDependencies = component->dependencies().toSet();
-
+ QString requiredDependencyVersion = version;
foreach (const QString &dependencyComponentName, allDependencies) {
// PackageManagerCore::componentByName returns 0 if dependencyComponentName contains a
// version which is not available
@@ -171,30 +171,50 @@ bool InstallerCalculator::appendComponentToInstall(Component *component)
m_componentsToInstallError.append(errorMessage);
return false;
}
+ //Check if component requires higher version than what might be already installed
+ bool isUpdateRequired = false;
+ if (dependencyComponentName.contains(QChar::fromLatin1('-')) &&
+ !dependencyComponent->value(scInstalledVersion).isEmpty()) {
+ QRegExp compEx(QLatin1String("([<=>]+)(.*)"));
+ const QString installedVersion = compEx.exactMatch(dependencyComponent->value(scInstalledVersion)) ?
+ compEx.cap(2) : dependencyComponent->value(scInstalledVersion);
+
+ QString requiredVersion = dependencyComponentName.section(QLatin1Char('-'), 1);
+ requiredVersion = compEx.exactMatch(requiredVersion) ? compEx.cap(2) : requiredVersion;
+
+ if (KDUpdater::compareVersion(requiredVersion, installedVersion) >= 1 ) {
+ isUpdateRequired = true;
+ requiredDependencyVersion = requiredVersion;
+ }
+ }
+ //Check dependencies only if
+ //- Dependency is not installed or update requested, nor newer version of dependency component required
+ //- And dependency component is not already added for install
+ //- And component is not already added for install, then dependencies are already resolved
+ if (((!dependencyComponent->isInstalled() || dependencyComponent->updateRequested())
+ || isUpdateRequired) && (!m_toInstallComponentIds.contains(dependencyComponent->name())
+ && !m_toInstallComponentIds.contains(component->name()))) {
+ if (m_visitedComponents.value(component).contains(dependencyComponent)) {
+ const QString errorMessage = recursionError(component);
+ qWarning().noquote() << errorMessage;
+ m_componentsToInstallError = errorMessage;
+ Q_ASSERT_X(!m_visitedComponents.value(component).contains(dependencyComponent),
+ Q_FUNC_INFO, qPrintable(errorMessage));
+ return false;
+ }
+ m_visitedComponents[component].insert(dependencyComponent);
+
+ // add needed dependency components to the next run
+ insertInstallReason(dependencyComponent, InstallerCalculator::Dependent,
+ component->name());
- if ((!dependencyComponent->isInstalled() || dependencyComponent->updateRequested())
- && !m_toInstallComponentIds.contains(dependencyComponent->name())) {
- if (m_visitedComponents.value(component).contains(dependencyComponent)) {
- const QString errorMessage = recursionError(component);
- qWarning().noquote() << errorMessage;
- m_componentsToInstallError = errorMessage;
- Q_ASSERT_X(!m_visitedComponents.value(component).contains(dependencyComponent),
- Q_FUNC_INFO, qPrintable(errorMessage));
- return false;
- }
- m_visitedComponents[component].insert(dependencyComponent);
-
- // add needed dependency components to the next run
- insertInstallReason(dependencyComponent, InstallerCalculator::Dependent,
- component->name());
-
- if (!appendComponentToInstall(dependencyComponent))
- return false;
+ if (!appendComponentToInstall(dependencyComponent, requiredDependencyVersion))
+ return false;
}
}
if (!m_toInstallComponentIds.contains(component->name())) {
- realAppendToInstallComponents(component);
+ realAppendToInstallComponents(component, requiredDependencyVersion);
insertInstallReason(component, InstallerCalculator::Resolved);
}
return true;
diff --git a/src/libs/installer/installercalculator.h b/src/libs/installer/installercalculator.h
index 08dd47f78..b2d05bdbe 100644
--- a/src/libs/installer/installercalculator.h
+++ b/src/libs/installer/installercalculator.h
@@ -64,8 +64,8 @@ private:
void insertInstallReason(Component *component,
InstallReasonType installReasonType,
const QString &referencedComponentName = QString());
- void realAppendToInstallComponents(Component *component);
- bool appendComponentToInstall(Component *components);
+ void realAppendToInstallComponents(Component *component, const QString &version = QString());
+ bool appendComponentToInstall(Component *components, const QString &version = QString());
QString recursionError(Component *component);
QList<Component*> m_allComponents;