diff options
author | Alexander Lenhardt <alexander.lenhardt@nokia.com> | 2011-10-13 13:28:59 +0200 |
---|---|---|
committer | Maurice Kalinowski <maurice.kalinowski@nokia.com> | 2011-10-13 15:07:05 +0200 |
commit | ef5cd8a882c19dac92cd936cb6faf21715fb5acc (patch) | |
tree | 405dba033dc2443cf2709d9b5c2256c534c168d6 | |
parent | ce8b61b3d1175a7a7cb82ff1319730f67f1fbaf1 (diff) |
Fixed QTSDK-961
- added support for version inheritance attributes to repogen
- added version inheritance for components
- 'inheritVersionFrom' attribute can be set for Version tags
added support for version inheritance attributes to repogen
Change-Id: I7e9a3a71620de2d8ffed0e0296b68f307304d9f6
Reviewed-by: Karsten Heimrich <karsten.heimrich@nokia.com>
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@nokia.com>
13 files changed, 108 insertions, 27 deletions
diff --git a/examples/testapp/packages/com.nokia.testapp.subcomponent.alwaysvisible/meta/package.xml b/examples/testapp/packages/com.nokia.testapp.subcomponent.alwaysvisible/meta/package.xml index 8e0fac180..5ab9c9fc9 100644 --- a/examples/testapp/packages/com.nokia.testapp.subcomponent.alwaysvisible/meta/package.xml +++ b/examples/testapp/packages/com.nokia.testapp.subcomponent.alwaysvisible/meta/package.xml @@ -1,7 +1,7 @@ <?xml version="1.0"?> <Package> <DisplayName>visible subcomponent</DisplayName> - <Version>1</Version> + <Version>1337</Version> <ReleaseDate>2009-12-03</ReleaseDate> <Name>com.nokia.testapp.subcomponent.alwaysvisible</Name> <Default>true</Default> diff --git a/examples/testapp/packages/com.nokia.testapp/meta/package.xml b/examples/testapp/packages/com.nokia.testapp/meta/package.xml index 071a2c807..2755d33f2 100644 --- a/examples/testapp/packages/com.nokia.testapp/meta/package.xml +++ b/examples/testapp/packages/com.nokia.testapp/meta/package.xml @@ -2,7 +2,7 @@ <Package> <DisplayName>Test App</DisplayName> <Description>Installs the complete Nokia SDK.</Description> - <Version>1</Version> + <Version inheritVersionFrom="com.nokia.testapp.subcomponent.alwaysvisible">1</Version> <ReleaseDate>2009-12-03</ReleaseDate> <Name>com.nokia.testapp</Name> <Script>installscript.js</Script> diff --git a/installerbuilder/common/repositorygen.cpp b/installerbuilder/common/repositorygen.cpp index 6186f0389..651badf41 100644 --- a/installerbuilder/common/repositorygen.cpp +++ b/installerbuilder/common/repositorygen.cpp @@ -398,7 +398,12 @@ void QInstaller::generateMetaDataDirectory(const QString& metapath_, const QStri if (key == QString::fromLatin1("Licenses")) continue; const QString value = node.toElement().text(); - update.appendChild(doc.createElement(key)).appendChild(doc.createTextNode(value)); + QDomElement element = doc.createElement(key); + for (int i = 0; i < node.attributes().size(); i++) { + element.setAttribute(node.attributes().item(i).toAttr().name(), + node.attributes().item(i).toAttr().value()); + } + update.appendChild(element).appendChild(doc.createTextNode(value)); } // get the size of the data diff --git a/installerbuilder/common/repositorygen.h b/installerbuilder/common/repositorygen.h index 4c0b95f66..0e149a9ca 100644 --- a/installerbuilder/common/repositorygen.h +++ b/installerbuilder/common/repositorygen.h @@ -40,13 +40,20 @@ namespace QInstaller { QMap<QString, QString> buildPathToVersionMap( const QVector<PackageInfo>& info ); - void compressMetaDirectories( const QString& configDir, const QString& repoDir, const QString& baseDir, const QMap<QString, QString>& versionMapping ); + void compressMetaDirectories( const QString &configDir, const QString &repoDir, const QString &baseDir, + const QMap<QString, QString> &versionMapping ); void compressMetaDirectories( const QString& configDir, const QString& repoDir ); - void compressDirectory( const QStringList& paths, const QString& archivePath ); - void copyComponentData( const QString& packageDir, const QString& configDir, const QString& repoDir, const QVector<PackageInfo>& infos ); - void generateMetaDataDirectory( const QString& outDir, const QString& dataDir, const QVector<PackageInfo>& packages, const QString& appName, const QString& appVersion ); - QVector<PackageInfo> createListOfPackages( const QStringList& components, const QString& packagesDirectory, bool addDependencies = true ); - void generateMetaDataDirectory( const QString& outDir, const QString& dataDir, const QVector<PackageInfo>& packages, const QString& appName, const QString& appVersion ); + void compressDirectory( const QStringList &paths, const QString &archivePath ); + void copyComponentData( const QString &packageDir, const QString &configDir, const QString &repoDir, + const QVector<PackageInfo> &infos ); + void generateMetaDataDirectory( const QString &outDir, const QString &dataDir, + const QVector<PackageInfo> &packages, const QString &appName, + const QString& appVersion ); + QVector<PackageInfo> createListOfPackages( const QStringList &components, const QString &packagesDirectory, + bool addDependencies = true ); + void generateMetaDataDirectory( const QString &outDir, const QString &dataDir, + const QVector<PackageInfo> &packages, const QString &appName, + const QString &appVersion ); } #endif // QINSTALLER_REPOSITORYGEN_H diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterpackagesinfo.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterpackagesinfo.cpp index 706e2d343..8a079ec9b 100644 --- a/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterpackagesinfo.cpp +++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterpackagesinfo.cpp @@ -361,8 +361,9 @@ void PackagesInfo::setCompatLevel(int level) /*! Marks the package with \a name as installed in \a version. */ -bool PackagesInfo::installPackage( const QString& name, const QString& version, const QString& title, const QString& description - , const QStringList& dependencies, bool forcedInstallation, bool virtualComp, quint64 uncompressedSize ) +bool PackagesInfo::installPackage( const QString& name, const QString& version, const QString& title, const QString& description, + const QStringList& dependencies, bool forcedInstallation, bool virtualComp, quint64 uncompressedSize, + const QString &inheritVersionFrom) { if( findPackageInfo( name ) != -1 ) return updatePackage( name, version, QDate::currentDate() ); @@ -370,6 +371,7 @@ bool PackagesInfo::installPackage( const QString& name, const QString& version, PackageInfo info; info.name = name; info.version = version; + info.inheritVersionFrom = inheritVersionFrom; info.installDate = QDate::currentDate(); info.title = title; info.description = description; @@ -415,12 +417,16 @@ bool PackagesInfo::removePackage( const QString& name ) static void addTextChildHelper(QDomNode *node, const QString &tag, - const QString &text) + const QString &text, + const QString &attributeName=QString(), + const QString &attributeValue=QString()) { QDomElement domElement = node->ownerDocument().createElement(tag); QDomText domText = node->ownerDocument().createTextNode(text); domElement.appendChild(domText); + if(!attributeName.isEmpty()) + domElement.setAttribute(attributeName, attributeValue); node->appendChild(domElement); } @@ -445,7 +451,11 @@ void PackagesInfo::writeToDisk() addTextChildHelper( &package, QLatin1String( "Pixmap" ), info.pixmap ); addTextChildHelper( &package, QLatin1String( "Title" ), info.title ); addTextChildHelper( &package, QLatin1String( "Description" ), info.description ); - addTextChildHelper( &package, QLatin1String( "Version" ), info.version ); + if (info.inheritVersionFrom.isEmpty()) + addTextChildHelper( &package, QLatin1String( "Version" ), info.version ); + else + addTextChildHelper( &package, QLatin1String( "Version" ), info.version, + QLatin1String("inheritVersionFrom"), info.inheritVersionFrom); addTextChildHelper( &package, QLatin1String( "LastUpdateDate" ), info.lastUpdateDate.toString( Qt::ISODate ) ); addTextChildHelper( &package, QLatin1String( "InstallDate" ), info.installDate.toString( Qt::ISODate) ); addTextChildHelper( &package, QLatin1String( "Size" ), QString::number( info.uncompressedSize ) ); @@ -503,8 +513,10 @@ void PackagesInfo::PackagesInfoData::addPackageFrom(const QDomElement& packageE) info.title = childNodeE.text(); else if( childNodeE.tagName() == QLatin1String( "Description" ) ) info.description = childNodeE.text(); - else if( childNodeE.tagName() == QLatin1String( "Version" ) ) + else if( childNodeE.tagName() == QLatin1String( "Version" ) ) { info.version = childNodeE.text(); + info.inheritVersionFrom = childNodeE.attribute(QLatin1String("inheritVersionFrom")); + } else if( childNodeE.tagName() == QLatin1String( "Virtual" ) ) info.virtualComp = childNodeE.text().toLower() == QLatin1String( "true" ) ? true : false; else if( childNodeE.tagName() == QLatin1String( "Size" ) ) diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterpackagesinfo.h b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterpackagesinfo.h index 56cd77ec3..d0a7ae31c 100644 --- a/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterpackagesinfo.h +++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterpackagesinfo.h @@ -42,6 +42,7 @@ namespace KDUpdater QString title; QString description; QString version; + QString inheritVersionFrom; QStringList dependencies; QStringList translations; QDate lastUpdateDate; @@ -92,8 +93,9 @@ namespace KDUpdater int compatLevel() const; void setCompatLevel(int level); - bool installPackage( const QString& pkgName, const QString& version, const QString& title = QString(), const QString& description = QString() - , const QStringList& dependencies = QStringList(), bool forcedInstallation = false, bool virtualComp = false, quint64 uncompressedSize = 0 ); + bool installPackage( const QString& pkgName, const QString& version, 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()); bool updatePackage(const QString &pkgName, const QString &version, const QDate &date ); bool removePackage( const QString& pkgName ); diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesinfo.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesinfo.cpp index 4e9f60195..b707e7720 100644 --- a/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesinfo.cpp +++ b/installerbuilder/libinstaller/3rdparty/kdtools/KDUpdater/kdupdaterupdatesinfo.cpp @@ -152,11 +152,10 @@ bool KDUpdater::UpdatesInfo::UpdatesInfoData::parsePackageUpdateElement(const QD if( childE.isNull() ) continue; - if( childE.tagName() == QLatin1String( "ReleaseNotes" ) ) { + if (childE.tagName() == QLatin1String( "ReleaseNotes" )) { info.data[childE.tagName()] = QUrl(childE.text()); } - else if( childE.tagName() == QLatin1String( "UpdateFile" ) ) - { + else if (childE.tagName() == QLatin1String( "UpdateFile" )) { KDUpdater::UpdateFileInfo ufInfo; ufInfo.arch = childE.attribute(QLatin1String( "Arch" ), QLatin1String( "i386" )); ufInfo.os = childE.attribute(QLatin1String( "OS" )); @@ -180,6 +179,10 @@ bool KDUpdater::UpdatesInfo::UpdatesInfoData::parsePackageUpdateElement(const QD if (!licenseHash.isEmpty()) info.data.insert(QLatin1String("Licenses"), licenseHash); } + else if (childE.tagName() == QLatin1String( "Version" )) { + info.data.insert(QLatin1String("inheritVersionFrom"), childE.attribute(QLatin1String("inheritVersionFrom"))); + info.data[childE.tagName()] = childE.text(); + } else { info.data[childE.tagName()] = childE.text(); } diff --git a/installerbuilder/libinstaller/component.cpp b/installerbuilder/libinstaller/component.cpp index d115bf1b1..0477ff2f9 100644 --- a/installerbuilder/libinstaller/component.cpp +++ b/installerbuilder/libinstaller/component.cpp @@ -107,6 +107,7 @@ void Component::loadDataFromPackage(const LocalPackage &package) setValue(scDisplayName, package.title); setValue(scDescription, package.description); setValue(scVersion, package.version); + setValue(scInheritVersion, package.inheritVersionFrom); setValue(scInstalledVersion, package.version); setValue(QLatin1String("LastUpdateDate"), package.lastUpdateDate.toString()); setValue(QLatin1String("InstallDate"), package.installDate.toString()); @@ -143,6 +144,7 @@ void Component::loadDataFromPackage(const Package &package) setValue(scCompressedSize, QString::number(package.compressedSize())); setValue(scUncompressedSize, QString::number(package.uncompressedSize())); setValue(scVersion, package.data(scVersion).toString()); + setValue(scInheritVersion, package.data(scInheritVersion).toString()); setValue(scDependencies, package.data(scDependencies).toString()); setValue(scVirtual, package.data(scVirtual).toString()); setValue(scSortingPriority, package.data(scSortingPriority).toString()); @@ -1108,14 +1110,14 @@ void Component::updateModelData(const QString &key, const QString &data) setData(d->m_core->virtualComponentsFont(), Qt::FontRole); } - if (key == scVersion) - setData(data, NewVersion); + if (key == scRemoteDisplayVersion) + setData(data, RemoteDisplayVersion); if (key == scDisplayName) setData(data, Qt::DisplayRole); - if (key == scInstalledVersion) - setData(data, InstalledVersion); + if (key == scDisplayVersion) + setData(data, LocalDisplayVersion); if (key == scUncompressedSize) setData(uncompressedSize(), UncompressedSize); diff --git a/installerbuilder/libinstaller/component_p.h b/installerbuilder/libinstaller/component_p.h index 754ee9600..119d9a5b0 100644 --- a/installerbuilder/libinstaller/component_p.h +++ b/installerbuilder/libinstaller/component_p.h @@ -94,9 +94,9 @@ class ComponentModelHelper { public: enum Roles { - InstalledVersion = Qt::UserRole + 1, - NewVersion = InstalledVersion + 1, - UncompressedSize = NewVersion + 1 + LocalDisplayVersion = Qt::UserRole + 1, + RemoteDisplayVersion = LocalDisplayVersion + 1, + UncompressedSize = RemoteDisplayVersion + 1 }; enum Column { diff --git a/installerbuilder/libinstaller/constants.h b/installerbuilder/libinstaller/constants.h index 0a6897e43..26baa21c5 100644 --- a/installerbuilder/libinstaller/constants.h +++ b/installerbuilder/libinstaller/constants.h @@ -36,6 +36,9 @@ static const QLatin1String scFalse("false"); static const QLatin1String scName("Name"); static const QLatin1String scVersion("Version"); +static const QLatin1String scDisplayVersion("DisplayVersion"); +static const QLatin1String scRemoteDisplayVersion("RemoteDisplayVersion"); +static const QLatin1String scInheritVersion("inheritVersionFrom"); static const QLatin1String scReplaces("Replaces"); static const QLatin1String scEssential("Essential"); static const QLatin1String scTargetDir("TargetDir"); diff --git a/installerbuilder/libinstaller/packagemanagercore.cpp b/installerbuilder/libinstaller/packagemanagercore.cpp index 24e453660..32118d07a 100644 --- a/installerbuilder/libinstaller/packagemanagercore.cpp +++ b/installerbuilder/libinstaller/packagemanagercore.cpp @@ -613,6 +613,8 @@ bool PackageManagerCore::fetchLocalPackagesTree() } } + updateDisplayVersions(); + emit finishAllComponentsReset(); d->setStatus(Success); @@ -659,6 +661,8 @@ bool PackageManagerCore::fetchRemotePackagesTree() success = fetchUpdaterPackages(packages, installedPackages); } + updateDisplayVersions(); + if (success && !d->statusCanceledOrFailed()) d->setStatus(Success); return success; @@ -1742,3 +1746,42 @@ void PackageManagerCore::resetComponentsToUserCheckedState() { d->resetComponentsToUserCheckedState(); } + +void PackageManagerCore::updateDisplayVersions() +{ + QHash<QString, QInstaller::Component*> components; + const QList<QInstaller::Component*> componentList = availableComponents(); + foreach (QInstaller::Component* component, componentList) { + components[component->name()] = component; + qDebug() << component->value(scInheritVersion); + } + + // set display version for all components in list + const QStringList &keys = components.keys(); + foreach (const QString &key, keys) { + QHash<QString, bool> visited; + const QString displayVersion = findDisplayVersion(key, components, visited); + if (displayVersion.isEmpty()) + components.value(key)->setValue(scDisplayVersion, tr("invalid")); + else if (components.value(key)->isInstalled()) + components.value(key)->setValue(scDisplayVersion, displayVersion); + components.value(key)->setValue(scRemoteDisplayVersion, displayVersion); + } + +} + +QString PackageManagerCore::findDisplayVersion(const QString &componentName, + const QHash<QString, QInstaller::Component*> &components, + QHash<QString, bool> &visited) +{ + const QString replaceWith = components.value(componentName)->value(scInheritVersion); + visited[componentName] = true; + if (replaceWith.isEmpty()) { + if (components.value(componentName)->isInstalled()) + return components.value(componentName)->value(scInstalledVersion); + return components.value(componentName)->value(scVersion); + } + if (visited.contains(replaceWith)) // cycle + return QString(); + return findDisplayVersion(replaceWith, components, visited); +} diff --git a/installerbuilder/libinstaller/packagemanagercore.h b/installerbuilder/libinstaller/packagemanagercore.h index e769b47fc..e56a229b6 100644 --- a/installerbuilder/libinstaller/packagemanagercore.h +++ b/installerbuilder/libinstaller/packagemanagercore.h @@ -266,6 +266,9 @@ private: static Component *subComponentByName(const QInstaller::PackageManagerCore *installer, const QString &name, const QString &version = QString(), Component *check = 0); + void updateDisplayVersions(); + QString findDisplayVersion(const QString &componentName, const QHash<QString, QInstaller::Component*> &components, + QHash<QString, bool> &visited); private: PackageManagerCorePrivate *const d; friend class PackageManagerCorePrivate; diff --git a/installerbuilder/libinstaller/packagemanagercore_p.cpp b/installerbuilder/libinstaller/packagemanagercore_p.cpp index 2e5471241..3b4b21f67 100644 --- a/installerbuilder/libinstaller/packagemanagercore_p.cpp +++ b/installerbuilder/libinstaller/packagemanagercore_p.cpp @@ -1601,7 +1601,8 @@ void PackageManagerCorePrivate::installComponent(Component *component, double pr KDUpdater::PackagesInfo &packages = *m_updaterApplication.packagesInfo(); packages.installPackage(component->name(), component->value(scVersion), component->value(scDisplayName), component->value(scDescription), component->dependencies(), component->forcedInstallation(), - component->isVirtual(), component->value(scUncompressedSize).toULongLong()); + component->isVirtual(), component->value(scUncompressedSize).toULongLong(), + component->value(scInheritVersion)); packages.writeToDisk(); component->setInstalled(); |