1 |
Allows binpkgs to be deleted if they are not usable due to IUSE changes. |
2 |
--- |
3 |
Just kind of spitballing. I'm not sure about what USE flags we should |
4 |
ignore or whether it should be configurable, etc. On one hand, deleting |
5 |
binpkgs that don't have a newly added PYTHON_TARGET option might make |
6 |
sense if your binhost is configured to rebuild the package. On the |
7 |
other, you probably don't want to throw out amd64 binpkgs because |
8 |
abi_riscv_* was added. |
9 |
|
10 |
pym/gentoolkit/eclean/cli.py | 8 ++++- |
11 |
pym/gentoolkit/eclean/search.py | 62 +++++++++++++++++++++++++-------- |
12 |
2 files changed, 54 insertions(+), 16 deletions(-) |
13 |
|
14 |
diff --git a/pym/gentoolkit/eclean/cli.py b/pym/gentoolkit/eclean/cli.py |
15 |
index e31fde9..910296b 100644 |
16 |
--- a/pym/gentoolkit/eclean/cli.py |
17 |
+++ b/pym/gentoolkit/eclean/cli.py |
18 |
@@ -146,6 +146,8 @@ def printUsage(_error=None, help=None): |
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(" --changed-iuse")+ |
23 |
+ " - delete packages for which IUSE have changed", file=out) |
24 |
print( yellow(" -i, --ignore-failure")+ |
25 |
" - ignore failure to locate PKGDIR", file=out) |
26 |
print( file=out) |
27 |
@@ -264,6 +266,8 @@ def parseArgs(options={}): |
28 |
options['verbose'] = True |
29 |
elif o in ("--changed-deps"): |
30 |
options['changed-deps'] = True |
31 |
+ elif o in ("--changed-iuse"): |
32 |
+ options['changed-iuse'] = True |
33 |
elif o in ("-i", "--ignore-failure"): |
34 |
options['ignore-failure'] = True |
35 |
else: |
36 |
@@ -291,7 +295,8 @@ def parseArgs(options={}): |
37 |
getopt_options['short']['distfiles'] = "fs:" |
38 |
getopt_options['long']['distfiles'] = ["fetch-restricted", "size-limit="] |
39 |
getopt_options['short']['packages'] = "i" |
40 |
- getopt_options['long']['packages'] = ["ignore-failure", "changed-deps"] |
41 |
+ getopt_options['long']['packages'] = ["ignore-failure", "changed-deps", |
42 |
+ "changed-iuse"] |
43 |
# set default options, except 'nocolor', which is set in main() |
44 |
options['interactive'] = False |
45 |
options['pretend'] = False |
46 |
@@ -305,6 +310,7 @@ def parseArgs(options={}): |
47 |
options['size-limit'] = 0 |
48 |
options['verbose'] = False |
49 |
options['changed-deps'] = False |
50 |
+ options['changed-iuse'] = False |
51 |
options['ignore-failure'] = False |
52 |
# if called by a well-named symlink, set the action accordingly: |
53 |
action = None |
54 |
diff --git a/pym/gentoolkit/eclean/search.py b/pym/gentoolkit/eclean/search.py |
55 |
index 8f6e52f..8344e15 100644 |
56 |
--- a/pym/gentoolkit/eclean/search.py |
57 |
+++ b/pym/gentoolkit/eclean/search.py |
58 |
@@ -498,6 +498,47 @@ def _deps_equal(deps_a, eapi_a, deps_b, eapi_b, uselist=None): |
59 |
return deps_a == deps_b |
60 |
|
61 |
|
62 |
+def _changed_deps(cpv, options, port_dbapi, bin_dbapi): |
63 |
+ if not options['changed-deps']: |
64 |
+ return False |
65 |
+ |
66 |
+ dep_keys = ('RDEPEND', 'PDEPEND') |
67 |
+ keys = ('EAPI', 'USE') + dep_keys |
68 |
+ binpkg_metadata = dict(zip(keys, bin_dbapi.aux_get(cpv, keys))) |
69 |
+ ebuild_metadata = dict(zip(keys, port_dbapi.aux_get(cpv, keys))) |
70 |
+ |
71 |
+ return _deps_equal(' '.join(binpkg_metadata[key] for key in dep_keys), |
72 |
+ binpkg_metadata['EAPI'], ' '.join(ebuild_metadata[key] for key in dep_keys), |
73 |
+ ebuild_metadata['EAPI'], |
74 |
+ frozenset(binpkg_metadata['USE'].split())) |
75 |
+ |
76 |
+ |
77 |
+# IUSE flags to be ignored for purposes of invalidating binpkgs |
78 |
+def ignore(iuse): |
79 |
+ return iuse.startswith('abi_') |
80 |
+ |
81 |
+ |
82 |
+# Prune the + characters from USE flags (e.g. '+cxx' -> 'cxx') |
83 |
+def prune_plus(iuse): |
84 |
+ if iuse.startswith('+'): |
85 |
+ return iuse[1:] |
86 |
+ return iuse |
87 |
+ |
88 |
+ |
89 |
+def _changed_iuse(cpv, options, port_dbapi, bin_dbapi): |
90 |
+ if not options['changed-iuse']: |
91 |
+ return False |
92 |
+ |
93 |
+ keys = ('IUSE',) |
94 |
+ binpkg_metadata = [prune_plus(x) for x in bin_dbapi.aux_get(cpv, keys)[0].split(' ') if not ignore(x)] |
95 |
+ ebuild_metadata = [prune_plus(x) for x in port_dbapi.aux_get(cpv, keys)[0].split(' ') if not ignore(x)] |
96 |
+ |
97 |
+ if binpkg_metadata == ['']: binpkg_metadata = [] |
98 |
+ if ebuild_metadata == ['']: ebuild_metadata = [] |
99 |
+ |
100 |
+ return binpkg_metadata != ebuild_metadata |
101 |
+ |
102 |
+ |
103 |
def findPackages( |
104 |
options, |
105 |
exclude=None, |
106 |
@@ -570,21 +611,6 @@ def findPackages( |
107 |
if mtime >= time_limit: |
108 |
continue |
109 |
|
110 |
- # Exclude if binpkg exists in the porttree and not --deep |
111 |
- if not destructive and port_dbapi.cpv_exists(cpv): |
112 |
- if not options['changed-deps']: |
113 |
- continue |
114 |
- |
115 |
- dep_keys = ('RDEPEND', 'PDEPEND') |
116 |
- keys = ('EAPI', 'USE') + dep_keys |
117 |
- binpkg_metadata = dict(zip(keys, bin_dbapi.aux_get(cpv, keys))) |
118 |
- ebuild_metadata = dict(zip(keys, port_dbapi.aux_get(cpv, keys))) |
119 |
- |
120 |
- if _deps_equal(' '.join(binpkg_metadata[key] for key in dep_keys), binpkg_metadata['EAPI'], |
121 |
- ' '.join(ebuild_metadata[key] for key in dep_keys), ebuild_metadata['EAPI'], |
122 |
- frozenset(binpkg_metadata['USE'].split())): |
123 |
- continue |
124 |
- |
125 |
if destructive and var_dbapi.cpv_exists(cpv): |
126 |
# Exclude if an instance of the package is installed due to |
127 |
# the --package-names option. |
128 |
@@ -596,6 +622,12 @@ def findPackages( |
129 |
if buildtime == bin_dbapi.aux_get(cpv, ['BUILD_TIME'])[0]: |
130 |
continue |
131 |
|
132 |
+ # Exclude if binpkg exists in the porttree and not --deep |
133 |
+ if not destructive and port_dbapi.cpv_exists(cpv): |
134 |
+ if not _changed_deps(cpv, options, port_dbapi, bin_dbapi) and \ |
135 |
+ not _changed_iuse(cpv, options, port_dbapi, bin_dbapi): |
136 |
+ continue |
137 |
+ |
138 |
binpkg_path = bin_dbapi.bintree.getname(cpv) |
139 |
dead_binpkgs.setdefault(cpv, []).append(binpkg_path) |
140 |
|
141 |
-- |
142 |
2.26.2 |