diff options
author | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2021-03-23 12:31:31 +0200 |
---|---|---|
committer | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2021-04-12 12:24:30 +0300 |
commit | b06f5b541748afc30bff787858702ed575662382 (patch) | |
tree | 302fbd39905ef74e44a97edcc8019358eeb410e0 /src/libs | |
parent | 6c70f89e8e8e312a4a738c180742c0ab41b3ab95 (diff) |
Offline-generator: Fix duplicate package entries in internal Updates.xml
In a somewhat rare case, it is possible that a same package exist in
multiple repositories. The latest available package from remotes is
used - however if we select that package for inclusion and also
implicitly get some other package from the another repository it exists
in with an older version (autodependency, etc.), that repository is then
also used to parse package information, and we store a duplicate entry
of the package to the Updates.xml to-be-written to the offline
installer binary.
Fix by appending only the package with the latest version to the
PackageInfoVector object used to temporarily hold the package
information.
Task-number: QTIFW-2190
Change-Id: Icdb3dc979153dfada37fdb0aabb3c718bc8aedff
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/ifwtools/repositorygen.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/libs/ifwtools/repositorygen.cpp b/src/libs/ifwtools/repositorygen.cpp index 863b5655b..d8339b063 100644 --- a/src/libs/ifwtools/repositorygen.cpp +++ b/src/libs/ifwtools/repositorygen.cpp @@ -672,8 +672,33 @@ PackageInfoVector QInstallerTools::createListOfRepositoryPackages(const QStringL el.save(metaStream, 0); } info.metaNode = metaString; - dict.push_back(info); - qDebug() << "- it provides the package" << info.name << " - " << info.version; + + bool pushToDict = true; + bool replacement = false; + // Check whether this package already exists in vector: + for (int i = 0; i < dict.size(); ++i) { + const QInstallerTools::PackageInfo oldInfo = dict.at(i); + if (oldInfo.name != info.name) + continue; + + if (KDUpdater::compareVersion(info.version, oldInfo.version) > 0) { + // A package with newer version, it will replace the existing one. + dict.remove(i); + replacement = true; + } else { + // A package with older or same version, do not add it again. + pushToDict = false; + } + break; + } + + if (pushToDict) { + replacement ? qDebug() << "- it provides a new version of the package" << info.name << " - " << info.version << "- replaced" + : qDebug() << "- it provides the package" << info.name << " - " << info.version; + dict.push_back(info); + } else { + qDebug() << "- it provides an old version of the package" << info.name << " - " << info.version << "- ignored"; + } } } } |