From b06f5b541748afc30bff787858702ed575662382 Mon Sep 17 00:00:00 2001 From: Arttu Tarkiainen Date: Tue, 23 Mar 2021 12:31:31 +0200 Subject: 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 Reviewed-by: Katja Marttila --- src/libs/ifwtools/repositorygen.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src') 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"; + } } } } -- cgit v1.2.3