Skip to content

Commit 89f068e

Browse files
moexiamithesamesam
authored andcommitted
eclean: limit keep_binpkgs lifetime to the current binrepo
This makes eclean-pkg operate on a per-binrepo basis in --unique-use mode and fixes a KeyError caused by cross-binrepo queries. Currently, keep_binpkgs persists across binrepos and may retain binary packages that do not belong to the current binrepo. When --unique-use is enabled, bin_dbapi.aux_get may then attempt to query BUILD_TIME for a package from a different binrepo. Since bin_dbapi only contains data for the current binrepo, it results in a KeyError. For example, while processing libevdev-1.13.6-7 it may try to query libevdev-1.13.6-6 from a different binrepo: ``` $ ls /var/cache/binpkgs/dev-libs/libevdev/ libevdev-1.13.6-6.gpkg.tar $ ls /var/cache/binhost/gentoo/dev-libs/libevdev/ libevdev-1.13.6-7.gpkg.tar $ sudo eclean-pkg --unique-use --changed-deps ... KeyError: ('dev-libs/libevdev-1.13.6', 6, ...) ``` All users of keep_binpkgs lie in `for cpv in bin_dbapi.cpv_all()`-loop so move its initializer right before the loop starts. Signed-off-by: moexiami <taopyxxm@gmail.com> Part-of: https://codeberg.org/gentoo/gentoolkit/pulls/8 Merges: https://codeberg.org/gentoo/gentoolkit/pulls/8 Signed-off-by: Sam James <sam@gentoo.org>
1 parent 7406b81 commit 89f068e

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

pym/gentoolkit/eclean/search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,6 @@ def findPackages(
734734
# Dictionary of binary packages to clean. Organized as
735735
# { location -> { cpv~build-id -> (binpkg, debugpack) } }
736736
dead_binpkgs: dict[str, dict[str, tuple[str, str | None]]] = {}
737-
keep_binpkgs = {}
738737

739738
def mk_binpkg_key(cpv):
740739
if cpv.build_id is None:
@@ -766,6 +765,7 @@ def mk_binpkg_key(cpv):
766765
populate_kwargs["invalid_errors"] = False
767766
if "force_reindex" in signature(bin_dbapi.bintree.populate).parameters:
768767
bin_dbapi.bintree.populate(force_reindex=True, **populate_kwargs)
768+
keep_binpkgs = {}
769769
for cpv in bin_dbapi.cpv_all():
770770
cp = portage.cpv_getkey(cpv)
771771
binpkg_key = mk_binpkg_key(cpv)

0 commit comments

Comments
 (0)