Gentoo Archives: gentoo-portage-dev

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

Replies