1 |
On 3/6/20 10:11 PM, Matt Turner wrote: |
2 |
> Signed-off-by: Matt Turner <mattst88@g.o> |
3 |
> --- |
4 |
> pym/gentoolkit/eclean/cli.py | 7 ++++++- |
5 |
> pym/gentoolkit/eclean/search.py | 24 +++++++++++++++++++++++- |
6 |
> 2 files changed, 29 insertions(+), 2 deletions(-) |
7 |
> |
8 |
> diff --git a/pym/gentoolkit/eclean/cli.py b/pym/gentoolkit/eclean/cli.py |
9 |
> index 1a99b3e..39aafd3 100644 |
10 |
> --- a/pym/gentoolkit/eclean/cli.py |
11 |
> +++ b/pym/gentoolkit/eclean/cli.py |
12 |
> @@ -147,6 +147,8 @@ def printUsage(_error=None, help=None): |
13 |
> or help in ('all','packages'): |
14 |
> print( "Available", yellow("options"),"for the", |
15 |
> green("packages"),"action:", file=out) |
16 |
> + print( yellow(" --changed-deps")+ |
17 |
> + " - delete packages for which ebuild dependencies have changed", file=out) |
18 |
> print( yellow(" -i, --ignore-failure")+ |
19 |
> " - ignore failure to locate PKGDIR", file=out) |
20 |
> print( file=out) |
21 |
> @@ -263,6 +265,8 @@ def parseArgs(options={}): |
22 |
> options['size-limit'] = parseSize(a) |
23 |
> elif o in ("-v", "--verbose") and not options['quiet']: |
24 |
> options['verbose'] = True |
25 |
> + elif o in ("--changed-deps"): |
26 |
> + options['changed-deps'] = True |
27 |
> elif o in ("-i", "--ignore-failure"): |
28 |
> options['ignore-failure'] = True |
29 |
> else: |
30 |
> @@ -290,7 +294,7 @@ def parseArgs(options={}): |
31 |
> getopt_options['short']['distfiles'] = "fs:" |
32 |
> getopt_options['long']['distfiles'] = ["fetch-restricted", "size-limit="] |
33 |
> getopt_options['short']['packages'] = "i" |
34 |
> - getopt_options['long']['packages'] = ["ignore-failure"] |
35 |
> + getopt_options['long']['packages'] = ["ignore-failure", "changed-deps"] |
36 |
> # set default options, except 'nocolor', which is set in main() |
37 |
> options['interactive'] = False |
38 |
> options['pretend'] = False |
39 |
> @@ -303,6 +307,7 @@ def parseArgs(options={}): |
40 |
> options['fetch-restricted'] = False |
41 |
> options['size-limit'] = 0 |
42 |
> options['verbose'] = False |
43 |
> + options['changed-deps'] = False |
44 |
> options['ignore-failure'] = False |
45 |
> # if called by a well-named symlink, set the action accordingly: |
46 |
> action = None |
47 |
> diff --git a/pym/gentoolkit/eclean/search.py b/pym/gentoolkit/eclean/search.py |
48 |
> index 0efefdb..17655cb 100644 |
49 |
> --- a/pym/gentoolkit/eclean/search.py |
50 |
> +++ b/pym/gentoolkit/eclean/search.py |
51 |
> @@ -13,6 +13,8 @@ import sys |
52 |
> from functools import partial |
53 |
> |
54 |
> import portage |
55 |
> +from portage.dep import Atom, use_reduce |
56 |
> +from portage.dep._slot_operator import strip_slots |
57 |
> |
58 |
> import gentoolkit.pprinter as pp |
59 |
> from gentoolkit.eclean.exclude import (exclDictMatchCP, exclDictExpand, |
60 |
> @@ -488,6 +490,17 @@ class DistfilesSearch(object): |
61 |
> return clean_me, saved |
62 |
> |
63 |
> |
64 |
> +def _deps_equal(deps_a, deps_b, eapi, uselist=None): |
65 |
> + """Compare two dependency lists given a set of USE flags""" |
66 |
> + if deps_a == deps_b: return True |
67 |
> + |
68 |
> + deps_a = use_reduce(deps_a, uselist=uselist, eapi=eapi, token_class=Atom) |
69 |
> + deps_b = use_reduce(deps_b, uselist=uselist, eapi=eapi, token_class=Atom) |
70 |
> + strip_slots(deps_a) |
71 |
> + strip_slots(deps_b) |
72 |
> + return deps_a == deps_b |
73 |
> + |
74 |
> + |
75 |
> def findPackages( |
76 |
> options, |
77 |
> exclude=None, |
78 |
> @@ -562,7 +575,16 @@ def findPackages( |
79 |
> |
80 |
> # Exclude if binpkg exists in the porttree and not --deep |
81 |
> if not destructive and port_dbapi.cpv_exists(cpv): |
82 |
> - continue |
83 |
> + if not options['changed-deps']: |
84 |
> + continue |
85 |
|
86 |
We can't can't continue above, since that will skip all of the filters |
87 |
that occur later in the loop. So, we have to nest the below changed-deps |
88 |
code under if options['changed-deps']: |
89 |
|
90 |
> + |
91 |
> + keys = ('RDEPEND', 'PDEPEND') |
92 |
> + binpkg_deps = bin_dbapi.aux_get(cpv, keys) |
93 |
> + ebuild_deps = port_dbapi.aux_get(cpv, keys) |
94 |
> + uselist = bin_dbapi.aux_get(cpv, ['USE'])[0].split() |
95 |
> + |
96 |
> + if _deps_equal(binpkg_deps, ebuild_deps, cpv.eapi, uselist): |
97 |
> + continue |
98 |
> |
99 |
> if destructive and var_dbapi.cpv_exists(cpv): |
100 |
> # Exclude if an instance of the package is installed due to |
101 |
> |
102 |
|
103 |
|
104 |
-- |
105 |
Thanks, |
106 |
Zac |