From 6969b19237c4dc763351723794e32e9da9aee246 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Thu, 4 Jun 2015 11:54:20 +0200 Subject: Store AutoDependOn inside components.xml Change-Id: Id304ca857ee1897c35171d6c293774f1d638bc02 Reviewed-by: Karsten Heimrich --- .../packages/componentG/meta/installscript.js | 39 ++++++++++++++++++ .../packages/componentG/meta/package.xml | 6 +-- src/libs/installer/component.cpp | 12 +----- src/libs/installer/constants.h | 1 + src/libs/installer/packagemanagercore_p.cpp | 15 ++++--- src/libs/kdtools/localpackagehub.cpp | 47 ++++++++++++++-------- src/libs/kdtools/localpackagehub.h | 21 +++++----- 7 files changed, 96 insertions(+), 45 deletions(-) create mode 100644 examples/dependencies/packages/componentG/meta/installscript.js diff --git a/examples/dependencies/packages/componentG/meta/installscript.js b/examples/dependencies/packages/componentG/meta/installscript.js new file mode 100644 index 000000000..ea89a4162 --- /dev/null +++ b/examples/dependencies/packages/componentG/meta/installscript.js @@ -0,0 +1,39 @@ +/************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Installer Framework. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** +** $QT_END_LICENSE$ +** +**************************************************************************/ + +function Component() +{ + component.addDependency("componentA"); +} + diff --git a/examples/dependencies/packages/componentG/meta/package.xml b/examples/dependencies/packages/componentG/meta/package.xml index 3e14256b4..1cff56d48 100644 --- a/examples/dependencies/packages/componentG/meta/package.xml +++ b/examples/dependencies/packages/componentG/meta/package.xml @@ -1,10 +1,10 @@ - Component G (default, depends on A) - By default, this component is selected for installation. It depends on component A. + Component G (default, depends on A, dependency added dynamically) + By default, this component is selected for installation. It depends on component A. Dependency is added from inside component script. true 1.0.0 2014-08-25 - componentA + 30 diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp index 1ba19ed2b..969ca6682 100644 --- a/src/libs/installer/component.cpp +++ b/src/libs/installer/component.cpp @@ -59,7 +59,6 @@ using namespace QInstaller; static const QLatin1String scScriptTag("Script"); -static const QLatin1String scAutoDependOn("AutoDependOn"); static const QLatin1String scVirtual("Virtual"); static const QLatin1String scInstalled("Installed"); static const QLatin1String scUpdateText("UpdateText"); @@ -243,7 +242,6 @@ Component::~Component() void Component::loadDataFromPackage(const KDUpdater::LocalPackage &package) { setValue(scName, package.name); - // pixmap ??? setValue(scDisplayName, package.title); setValue(scDescription, package.description); setValue(scVersion, package.version); @@ -252,14 +250,8 @@ void Component::loadDataFromPackage(const KDUpdater::LocalPackage &package) setValue(QLatin1String("LastUpdateDate"), package.lastUpdateDate.toString()); setValue(QLatin1String("InstallDate"), package.installDate.toString()); setValue(scUncompressedSize, QString::number(package.uncompressedSize)); - - QString dependstr; - foreach (const QString &val, package.dependencies) - dependstr += val + QLatin1String(","); - - if (package.dependencies.count() > 0) - dependstr.chop(1); - setValue(scDependencies, dependstr); + setValue(scDependencies, package.dependencies.join(QLatin1String(","))); + setValue(scAutoDependOn, package.autoDependencies.join(QLatin1String(","))); setValue(scForcedInstallation, package.forcedInstallation ? scTrue : scFalse); if (package.forcedInstallation & !PackageManagerCore::noForceInstallation()) { diff --git a/src/libs/installer/constants.h b/src/libs/installer/constants.h index f494f75fc..e7cc3fe98 100644 --- a/src/libs/installer/constants.h +++ b/src/libs/installer/constants.h @@ -58,6 +58,7 @@ static const QLatin1String scReleaseDate("ReleaseDate"); static const QLatin1String scDescription("Description"); static const QLatin1String scDisplayName("DisplayName"); static const QLatin1String scDependencies("Dependencies"); +static const QLatin1String scAutoDependOn("AutoDependOn"); static const QLatin1String scNewComponent("NewComponent"); static const QLatin1String scRepositories("Repositories"); static const QLatin1String scCompressedSize("CompressedSize"); diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index 8959634e5..4f8af73f0 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -1905,11 +1905,16 @@ void PackageManagerCorePrivate::installComponent(Component *component, double pr } // now mark the component as installed - m_localPackageHub->addPackage(component->name(), component->value(scVersion), - component->value(scDisplayName), - component->value(scDescription), component->dependencies(), component->forcedInstallation(), - component->isVirtual(), component->value(scUncompressedSize).toULongLong(), - component->value(scInheritVersion)); + m_localPackageHub->addPackage(component->name(), + component->value(scVersion), + component->value(scDisplayName), + component->value(scDescription), + component->dependencies(), + component->autoDependencies(), + component->forcedInstallation(), + component->isVirtual(), + component->value(scUncompressedSize).toULongLong(), + component->value(scInheritVersion)); m_localPackageHub->writeToDisk(); component->setInstalled(); diff --git a/src/libs/kdtools/localpackagehub.cpp b/src/libs/kdtools/localpackagehub.cpp index 9cadc6d5f..02bb8cb64 100644 --- a/src/libs/kdtools/localpackagehub.cpp +++ b/src/libs/kdtools/localpackagehub.cpp @@ -35,12 +35,14 @@ #include "localpackagehub.h" #include "globals.h" +#include "constants.h" #include #include #include using namespace KDUpdater; +using namespace QInstaller; /*! \inmodule kdupdater @@ -305,15 +307,26 @@ void LocalPackageHub::refresh() /*! Marks the package specified by \a name as installed. Sets the values of - \a version, \a title, \a description, \a dependencies, \a forcedInstallation, - \a virtualComp, \a uncompressedSize, and \a inheritVersionFrom for the - package. + \a version, + \a title, + \a description, + \a dependencies, + \a autoDependencies, + \a forcedInstallation, + \a virtualComp, + \a uncompressedSize, + and \a inheritVersionFrom for the package. */ -void LocalPackageHub::addPackage(const QString &name, const QString &version, - const QString &title, const QString &description, - const QStringList &dependencies, bool forcedInstallation, - bool virtualComp, quint64 uncompressedSize, - const QString &inheritVersionFrom) +void LocalPackageHub::addPackage(const QString &name, + const QString &version, + const QString &title, + const QString &description, + const QStringList &dependencies, + const QStringList &autoDependencies, + bool forcedInstallation, + bool virtualComp, + quint64 uncompressedSize, + const QString &inheritVersionFrom) { // TODO: This somewhat unexpected, remove? if (d->m_packageInfoMap.contains(name)) { @@ -329,6 +342,7 @@ void LocalPackageHub::addPackage(const QString &name, const QString &version, info.title = title; info.description = description; info.dependencies = dependencies; + info.autoDependencies = autoDependencies; info.forcedInstallation = forcedInstallation; info.virtualComp = virtualComp; info.uncompressedSize = uncompressedSize; @@ -381,7 +395,6 @@ void LocalPackageHub::writeToDisk() QDomElement package = doc.createElement(QLatin1String("Package")); addTextChildHelper(&package, QLatin1String("Name"), info.name); - addTextChildHelper(&package, QLatin1String("Pixmap"), info.pixmap); addTextChildHelper(&package, QLatin1String("Title"), info.title); addTextChildHelper(&package, QLatin1String("Description"), info.description); if (info.inheritVersionFrom.isEmpty()) @@ -395,12 +408,11 @@ void LocalPackageHub::writeToDisk() .toString(Qt::ISODate)); addTextChildHelper(&package, QLatin1String("Size"), QString::number(info.uncompressedSize)); - QString assembledDependencies = QLatin1String(""); - Q_FOREACH (const QString & val, info.dependencies) - assembledDependencies += val + QLatin1String(","); - if (info.dependencies.count() > 0) - assembledDependencies.chop(1); - addTextChildHelper(&package, QLatin1String("Dependencies"), assembledDependencies); + + if (info.dependencies.count()) + addTextChildHelper(&package, scDependencies, info.dependencies.join(QLatin1String(","))); + if (info.autoDependencies.count()) + addTextChildHelper(&package, scAutoDependOn, info.autoDependencies.join(QLatin1String(","))); if (info.forcedInstallation) addTextChildHelper(&package, QLatin1String("ForcedInstallation"), QLatin1String("true")); if (info.virtualComp) @@ -440,8 +452,6 @@ void LocalPackageHub::PackagesInfoData::addPackageFrom(const QDomElement &packag if (childNodeE.tagName() == QLatin1String("Name")) info.name = childNodeE.text(); - else if (childNodeE.tagName() == QLatin1String("Pixmap")) - info.pixmap = childNodeE.text(); else if (childNodeE.tagName() == QLatin1String("Title")) info.title = childNodeE.text(); else if (childNodeE.tagName() == QLatin1String("Description")) @@ -457,6 +467,9 @@ void LocalPackageHub::PackagesInfoData::addPackageFrom(const QDomElement &packag else if (childNodeE.tagName() == QLatin1String("Dependencies")) { info.dependencies = childNodeE.text().split(QInstaller::commaRegExp(), QString::SkipEmptyParts); + } else if (childNodeE.tagName() == QLatin1String("AutoDependOn")) { + info.autoDependencies = childNodeE.text().split(QInstaller::commaRegExp(), + QString::SkipEmptyParts); } else if (childNodeE.tagName() == QLatin1String("ForcedInstallation")) info.forcedInstallation = childNodeE.text().toLower() == QLatin1String( "true" ) ? true : false; else if (childNodeE.tagName() == QLatin1String("LastUpdateDate")) diff --git a/src/libs/kdtools/localpackagehub.h b/src/libs/kdtools/localpackagehub.h index c6e08d0d3..4e2f6634f 100644 --- a/src/libs/kdtools/localpackagehub.h +++ b/src/libs/kdtools/localpackagehub.h @@ -47,13 +47,12 @@ namespace KDUpdater { struct KDTOOLS_EXPORT LocalPackage { QString name; - QString pixmap; QString title; QString description; QString version; QString inheritVersionFrom; QStringList dependencies; - QStringList translations; + QStringList autoDependencies; QDate lastUpdateDate; QDate installDate; bool forcedInstallation; @@ -100,14 +99,16 @@ public: QList packageInfos() const; LocalPackage packageInfo(const QString &pkgName) const; - void addPackage(const QString &pkgName, const QString &version, // mandatory - const QString &title = QString(), - const QString &description = QString(), - const QStringList &dependencies = QStringList(), - bool forcedInstallation = false, - bool virtualComp = false, - quint64 uncompressedSize = 0, - const QString &inheritVersionFrom = QString()); + void addPackage(const QString &pkgName, + const QString &version, // mandatory + const QString &title, + const QString &description, + const QStringList &dependencies, + const QStringList &autoDependencies, + bool forcedInstallation, + bool virtualComp, + quint64 uncompressedSize, + const QString &inheritVersionFrom); bool removePackage(const QString &pkgName); void refresh(); -- cgit v1.2.3