[pkgselectprocess] Do not include uninstallable virtual packages in the CPBE output

When we are creating the final list of packages to feed to "apt install,"
virtual packages which do not have a valid candidate are included in this
list, causing the installation to fail. When creating this list, use FindGrp
instead of FindPkg, and only add it to the list if there is a valid candidate.
Additionally, add these items to an unordered set, to eliminate deduplication
(LP: #2106773).

A reliable testcase for this is the libreoffice-help-is package, at least in
Plucky.
This commit is contained in:
Simon Quigley 2025-04-12 21:00:38 -05:00
parent dc3e8a738f
commit 197d24e295
2 changed files with 22 additions and 2 deletions

View File

@ -1,5 +1,6 @@
#include <iostream>
#include <string>
#include <unordered_set>
#include <apt-pkg/algorithms.h>
#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/init.h>
@ -28,9 +29,17 @@ int main(int argc, char* argv[]) {
std::vector<std::string> package_names(argv + 1, argv + argc);
if (package_names.empty()) return 0;
std::unordered_set<std::string> seen_packages;
for (std::string package_name : package_names) {
pkgCache::PkgIterator it = cache->GetPkgCache()->FindPkg(package_name);
if (!it.end()) std::cout << package_name << " ";
if (seen_packages.contains(package_name)) continue;
seen_packages.insert(package_name);
pkgCache::GrpIterator grp = cache->GetPkgCache()->FindGrp(package_name);
if (!grp.end()) {
pkgCache::PkgIterator it = grp.FindPreferredPkg(true);
if (!it.end() && !it.VersionList().end()) {
std::cout << package_name << " ";
}
}
}
std::cout << "\n";

11
debian/changelog vendored
View File

@ -1,3 +1,14 @@
calamares-settings-ubuntu (1:25.04.25) UNRELEASED; urgency=medium
* [pkgselectprocess] When we are creating the final list of packages to feed
to "apt install," virtual packages which do not have a valid candidate are
included in this list, causing the installation to fail. When creating
this list, use FindGrp instead of FindPkg, and only add it to the list if
there is a valid candidate. Additionally, add these items to an unordered
set, to eliminate deduplication (LP: #2106773).
-- Simon Quigley <tsimonq2@ubuntu.com> Sat, 12 Apr 2025 00:23:39 -0500
calamares-settings-ubuntu (1:25.04.24) plucky; urgency=medium
* Bump Standards-Version to 4.7.2, no changes needed.