diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/installer/component.cpp | 35 | ||||
-rw-r--r-- | src/libs/installer/component.h | 4 | ||||
-rw-r--r-- | src/libs/installer/constants.h | 1 | ||||
-rw-r--r-- | src/libs/installer/installercalculator.cpp | 4 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore.cpp | 2 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore_p.cpp | 10 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore_p.h | 2 | ||||
-rw-r--r-- | src/libs/installer/qinstallerglobal.h | 2 | ||||
-rw-r--r-- | src/libs/installer/uninstallercalculator.cpp | 8 | ||||
-rw-r--r-- | src/libs/installer/uninstallercalculator.h | 4 |
10 files changed, 55 insertions, 17 deletions
diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp index 702dd2763..c703bfdcd 100644 --- a/src/libs/installer/component.cpp +++ b/src/libs/installer/component.cpp @@ -308,6 +308,10 @@ void Component::loadDataFromPackage(const KDUpdater::LocalPackage &package) setValue(scTreeName, package.treeName.first); d->m_treeNameMoveChildren = package.treeName.second; + + // scDependencies might be updated from repository later, + // keep the local dependencies as well. + setValue(scLocalDependencies, value(scDependencies)); } /*! @@ -1354,12 +1358,23 @@ void Component::addDependency(const QString &newDependency) setValue(scDependencies, oldDependencies + QLatin1String(", ") + newDependency); } +/*! + Returns a list of dependencies defined in the the repository or in the package.xml. +*/ QStringList Component::dependencies() const { return d->m_vars.value(scDependencies).split(QInstaller::commaRegExp(), Qt::SkipEmptyParts); } /*! + Returns a list of installed components dependencies defined in the components.xml. +*/ +QStringList Component::localDependencies() const +{ + return d->m_vars.value(scLocalDependencies).split(QInstaller::commaRegExp(), Qt::SkipEmptyParts); +} + +/*! Adds the component specified by \a newDependOn to the automatic depend-on list. Alternatively, multiple components can be specified by separating each with a comma. @@ -1383,6 +1398,24 @@ QStringList Component::autoDependencies() const } /*! + Returns a list of dependencies that the component currently has. The + dependencies can vary when component is already installed with different + dependency list than what is introduced in the repository. If component is + not installed, or update is requested to an installed component, + current dependencies are read from repository so that correct dependencies + are calculated for the component when it is installed or updated. +*/ +QStringList Component::currentDependencies() const +{ + QStringList dependenciesList; + if (isInstalled() && !updateRequested()) + dependenciesList = localDependencies(); + else + dependenciesList = dependencies(); + return dependenciesList; +} + +/*! \sa {component::setInstalled}{component.setInstalled} */ void Component::setInstalled() @@ -1519,7 +1552,7 @@ bool Component::isUpdateAvailable() const \sa {component::updateRequested}{component.updateRequested} */ -bool Component::updateRequested() +bool Component::updateRequested() const { return d->m_updateIsAvailable && isSelected() && !isUnstable(); } diff --git a/src/libs/installer/component.h b/src/libs/installer/component.h index dbf604a56..e5f1b38da 100644 --- a/src/libs/installer/component.h +++ b/src/libs/installer/component.h @@ -170,8 +170,10 @@ public: Q_INVOKABLE void addDependency(const QString &newDependency); QStringList dependencies() const; + QStringList localDependencies() const; Q_INVOKABLE void addAutoDependOn(const QString &newDependOn); QStringList autoDependencies() const; + QStringList currentDependencies() const; void languageChanged(); QString localTempPath() const; @@ -195,7 +197,7 @@ public: Q_INVOKABLE void setUpdateAvailable(bool isUpdateAvailable); Q_INVOKABLE bool isUpdateAvailable() const; - Q_INVOKABLE bool updateRequested(); + Q_INVOKABLE bool updateRequested() const; Q_INVOKABLE bool componentChangeRequested(); Q_INVOKABLE bool isForcedUpdate(); diff --git a/src/libs/installer/constants.h b/src/libs/installer/constants.h index af518a0f6..7fa54c4ec 100644 --- a/src/libs/installer/constants.h +++ b/src/libs/installer/constants.h @@ -59,6 +59,7 @@ static const QLatin1String scDisplayName("DisplayName"); static const QLatin1String scTreeName("TreeName"); static const QLatin1String scAutoTreeName("AutoTreeName"); static const QLatin1String scDependencies("Dependencies"); +static const QLatin1String scLocalDependencies("LocalDependencies"); static const QLatin1String scAutoDependOn("AutoDependOn"); static const QLatin1String scNewComponent("NewComponent"); static const QLatin1String scRepositories("Repositories"); diff --git a/src/libs/installer/installercalculator.cpp b/src/libs/installer/installercalculator.cpp index 21e82fc9a..2ef5d3b74 100644 --- a/src/libs/installer/installercalculator.cpp +++ b/src/libs/installer/installercalculator.cpp @@ -109,7 +109,7 @@ bool InstallerCalculator::appendComponentsToInstall(const QList<Component *> &co } } - if (component->dependencies().isEmpty()) + if (component->currentDependencies().isEmpty()) realAppendToInstallComponents(component, QString(), revertFromInstall); else notAppendedComponents.append(component); @@ -177,7 +177,7 @@ void InstallerCalculator::realAppendToInstallComponents(Component *component, co bool InstallerCalculator::appendComponentToInstall(Component *component, const QString &version, bool revertFromInstall) { - const QStringList dependenciesList = component->dependencies(); + const QStringList dependenciesList = component->currentDependencies(); QSet<QString> allDependencies(dependenciesList.begin(), dependenciesList.end()); QString requiredDependencyVersion = version; foreach (const QString &dependencyComponentName, allDependencies) { diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index 8ebaefd62..543852e20 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -3922,6 +3922,8 @@ bool PackageManagerCore::updateComponentData(struct Data &data, Component *compo // a possible component to replace that might be installed (to mark the replacement as installed). component->setInstalled(); component->setValue(scInstalledVersion, data.installedPackages->value(name).version); + component->setValue(scLocalDependencies, data.installedPackages->value(name). + dependencies.join(QLatin1String(","))); return true; } diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index 85e902ac3..e279a8027 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -463,7 +463,7 @@ void PackageManagerCorePrivate::cleanUpComponentEnvironment() { m_componentReplaces.clear(); m_autoDependencyComponentHash.clear(); - m_dependencyComponentHash.clear(); + m_localDependencyComponentHash.clear(); m_localVirtualComponents.clear(); // clean up registered (downloaded) data if (m_core->isMaintainer()) @@ -596,7 +596,7 @@ UninstallerCalculator *PackageManagerCorePrivate::uninstallerCalculator() const } pmcp->m_uninstallerCalculator = new UninstallerCalculator(installedComponents, m_core, - pmcp->m_autoDependencyComponentHash, pmcp->m_dependencyComponentHash, pmcp->m_localVirtualComponents); + pmcp->m_autoDependencyComponentHash, pmcp->m_localDependencyComponentHash, pmcp->m_localVirtualComponents); } return m_uninstallerCalculator; } @@ -3164,11 +3164,11 @@ void PackageManagerCorePrivate::createDependencyHashes(const Component* componen m_autoDependencyComponentHash.insert(autodepend, value); } - for (const QString &depend : component->dependencies()) { - QStringList value = m_dependencyComponentHash.value(depend); + for (const QString &depend : component->localDependencies()) { + QStringList value = m_localDependencyComponentHash.value(depend); if (!value.contains(component->name())) value.append(component->name()); - m_dependencyComponentHash.insert(depend, value); + m_localDependencyComponentHash.insert(depend, value); } } diff --git a/src/libs/installer/packagemanagercore_p.h b/src/libs/installer/packagemanagercore_p.h index 3a859f63d..8a5b805d8 100644 --- a/src/libs/installer/packagemanagercore_p.h +++ b/src/libs/installer/packagemanagercore_p.h @@ -311,7 +311,7 @@ private: QHash<Component*, Qt::CheckState> m_coreCheckedHash; QList<Component*> m_deletedReplacedComponents; AutoDependencyHash m_autoDependencyComponentHash; - DependencyHash m_dependencyComponentHash; + LocalDependencyHash m_localDependencyComponentHash; QStringList m_localVirtualComponents; diff --git a/src/libs/installer/qinstallerglobal.h b/src/libs/installer/qinstallerglobal.h index 5bc87e21d..88f255af6 100644 --- a/src/libs/installer/qinstallerglobal.h +++ b/src/libs/installer/qinstallerglobal.h @@ -58,7 +58,7 @@ typedef QList<QInstaller::Package*> PackagesList; typedef QMap<QString, KDUpdater::LocalPackage> LocalPackagesMap; typedef QHash<QString, QStringList> AutoDependencyHash; -typedef QHash<QString, QStringList> DependencyHash; +typedef QHash<QString, QStringList> LocalDependencyHash; } // namespace QInstaller diff --git a/src/libs/installer/uninstallercalculator.cpp b/src/libs/installer/uninstallercalculator.cpp index c717f6550..af03df8c5 100644 --- a/src/libs/installer/uninstallercalculator.cpp +++ b/src/libs/installer/uninstallercalculator.cpp @@ -45,12 +45,12 @@ namespace QInstaller { UninstallerCalculator::UninstallerCalculator(const QList<Component *> &installedComponents , PackageManagerCore *core , const AutoDependencyHash &autoDependencyComponentHash - , const DependencyHash &dependencyComponentHash + , const LocalDependencyHash &localDependencyComponentHash , const QStringList &localVirtualComponents) : m_installedComponents(installedComponents) , m_core(core) , m_autoDependencyComponentHash(autoDependencyComponentHash) - , m_dependencyComponentHash(dependencyComponentHash) + , m_localDependencyComponentHash(localDependencyComponentHash) , m_localVirtualComponents(localVirtualComponents) { } @@ -68,8 +68,8 @@ void UninstallerCalculator::appendComponentToUninstall(Component *component, con if (!component->isInstalled()) return; - if (m_dependencyComponentHash.contains(component->name())) { - const QStringList &dependencies = PackageManagerCore::parseNames(m_dependencyComponentHash.value(component->name())); + if (m_localDependencyComponentHash.contains(component->name())) { + const QStringList &dependencies = PackageManagerCore::parseNames(m_localDependencyComponentHash.value(component->name())); for (const QString &dependencyComponent : dependencies) { Component *depComponent = m_core->componentByName(dependencyComponent); if (depComponent && depComponent->isInstalled() && !m_componentsToUninstall.contains(depComponent)) { diff --git a/src/libs/installer/uninstallercalculator.h b/src/libs/installer/uninstallercalculator.h index a458daa80..76e32c6a6 100644 --- a/src/libs/installer/uninstallercalculator.h +++ b/src/libs/installer/uninstallercalculator.h @@ -55,7 +55,7 @@ public: UninstallerCalculator(const QList<Component *> &installedComponents, PackageManagerCore *core, const AutoDependencyHash &autoDependencyComponentHash, - const DependencyHash &dependencyComponentHash, + const LocalDependencyHash &localDependencyComponentHash, const QStringList &localVirtualComponents); QSet<Component*> componentsToUninstall() const; @@ -78,7 +78,7 @@ private: PackageManagerCore *m_core; QHash<QString, QPair<UninstallReasonType, QString> > m_toUninstallComponentIdReasonHash; AutoDependencyHash m_autoDependencyComponentHash; - DependencyHash m_dependencyComponentHash; + LocalDependencyHash m_localDependencyComponentHash; QStringList m_localVirtualComponents; QList<Component *> m_virtualComponentsForReverse; }; |