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