Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: Matt Turner <mattst88@g.o>
Cc: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH gentoolkit 2/2] eclean: Add option to delete binpkgs with changed deps
Date: Tue, 03 Mar 2020 03:38:41
Message-Id: 9438a358-d6ac-155c-826e-93becfdc7aa8@gentoo.org
In Reply to: Re: [gentoo-portage-dev] [PATCH gentoolkit 2/2] eclean: Add option to delete binpkgs with changed deps by Matt Turner
1 On 3/2/20 1:02 PM, Matt Turner wrote:
2 > On Mon, Mar 2, 2020 at 12:40 PM Matt Turner <mattst88@g.o> wrote:
3 >>
4 >> On Sun, Mar 1, 2020 at 10:32 PM Zac Medico <zmedico@g.o> wrote:
5 >>>
6 >>> On 2/20/20 9:29 PM, Matt Turner wrote:
7 >>>> +
8 >>>> def findPackages(
9 >>>> options,
10 >>>> exclude=None,
11 >>>> @@ -564,7 +577,22 @@ def findPackages(
12 >>>>
13 >>>> # Exclude if binpkg exists in the porttree and not --deep
14 >>>> if not destructive and port_dbapi.cpv_exists(cpv):
15 >>>> - continue
16 >>>> + if not options['changed-deps']:
17 >>>> + continue
18 >>>> +
19 >>>> + uselist = bin_dbapi.aux_get(cpv, ['USE'])[0].split()
20 >>>> + all_equal = True
21 >>>> +
22 >>>> + for k in ('RDEPEND', 'PDEPEND'):
23 >>>> + binpkg_deps = bin_dbapi.aux_get(cpv, [k])
24 >>>> + ebuild_deps = port_dbapi.aux_get(cpv, [k])
25 >>>> +
26 >>>> + if not _deps_equal(binpkg_deps, ebuild_deps, cpv.eapi, uselist):
27 >>>> + all_equal = False
28 >>>> + break
29 >>>> +
30 >>>> + if all_equal:
31 >>>> + continue
32 >>>>
33 >>>> if destructive and var_dbapi.cpv_exists(cpv):
34 >>>> # Exclude if an instance of the package is installed due to
35 >>>>
36 >>>
37 >>> The aux_get calls are expensive, so it's more efficient to get multiple
38 >>> values with each call like:
39 >>> keys = ('RDEPEND', 'PDEPEND')
40 >>> binpkg_deps = dict(zip(keys, bin_dbapi.aux_get(cpv, keys))
41 >>> ebuild_deps = dict(zip(keys, port_dbapi.aux_get(cpv, keys))
42 >>>
43 >>> Otherwise, looks good.
44 >>
45 >> Thanks, that makes the code a lot nicer too.
46 >
47 > Actually, use_reduce wants a list (it calls .split). Wrapping those in
48 > list() looks like it works, but I suspect that's not as you intended.
49 > What does the zip add over just doing this?
50 >
51 > binpkg_deps = bin_dbapi.aux_get(cpv, keys)
52 > ebuild_deps = port_dbapi.aux_get(cpv, keys)
53
54 Using dict(zip(keys, port_dbapi.aux_get(cpv, keys)) is only useful if
55 you want to use a dictionary to access the values. However, if lists are
56 good enough then you might just use those instead. You could even join
57 the values together like this:
58
59 ebuild_deps = ' '.join(port_dbapi.aux_get(cpv, keys))
60 --
61 Thanks,
62 Zac

Attachments

File name MIME type
signature.asc application/pgp-signature