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