Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Zac Medico <zmedico@g.o>
Subject: [gentoo-portage-dev] [PATCH v4] emerge: add --changed-deps-report option (bug 645780)
Date: Mon, 29 Jan 2018 06:58:09
Message-Id: 20180129065543.192861-1-zmedico@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] emerge: add --changed-deps-report option (bug 645780) by Zac Medico
1 The --dynamic-deps=n default causes confusion for users that are
2 accustomed to dynamic deps, therefore add a --changed-deps-report
3 option that is enabled by default (if --usepkgonly is not enabled).
4
5 The report is entirely suppressed in the following cases in which
6 the packages with changed dependencies are entirely harmless to the
7 user:
8
9 * --changed-deps or --dynamic-deps is enabled
10 * none of the packages with changed deps are in the graph
11
12 These cases suppress noise for the unaffected user, even though some
13 of the changed dependencies might be worthy of revision bumps.
14
15 The --quiet option suppresses the NOTE section of the report, but
16 the HINT section is still displayed since it might help users
17 resolve problems that are solved by --changed-deps.
18
19 Example output is as follows:
20
21 !!! Detected ebuild dependency change(s) without revision bump:
22
23 net-misc/openssh-7.5_p1-r3::gentoo
24 sys-fs/udisks-2.7.5::gentoo
25
26 NOTE: Refer to the following page for more information about dependency
27 change(s) without revision bump:
28
29 https://wiki.gentoo.org/wiki/Project:Portage/Changed_Deps
30
31 In order to suppress reports about dependency changes, add
32 --changed-deps-report=n to the EMERGE_DEFAULT_OPTS variable in
33 '/etc/portage/make.conf'.
34
35 HINT: In order to avoid problems involving changed dependencies, use the
36 --changed-deps option to automatically trigger rebuilds when changed
37 dependencies are detected. Refer to the emerge man page for more
38 information about this option.
39
40 Bug: https://bugs.gentoo.org/645780
41 ---
42 [PATCH v4] changes:
43
44 * Entirely suppress the report if --changed-deps or --dynamic-deps is enabled
45
46
47 man/emerge.1 | 10 ++++
48 pym/_emerge/create_depgraph_params.py | 5 ++
49 pym/_emerge/depgraph.py | 98 +++++++++++++++++++++++++++++++++--
50 pym/_emerge/main.py | 13 +++++
51 4 files changed, 123 insertions(+), 3 deletions(-)
52
53 diff --git a/man/emerge.1 b/man/emerge.1
54 index 3c81b9c9f..9de1b7f74 100644
55 --- a/man/emerge.1
56 +++ b/man/emerge.1
57 @@ -465,6 +465,16 @@ option also implies the \fB\-\-selective\fR option. Behavior with
58 respect to changed build\-time dependencies is controlled by the
59 \fB\-\-with\-bdeps\fR option.
60 .TP
61 +.BR "\-\-changed\-deps\-report [ y | n ]"
62 +Tells emerge to report ebuilds for which the ebuild dependencies have
63 +changed since the installed instance was built. Behavior with respect to
64 +changed build\-time dependencies is controlled by the
65 +\fB\-\-with\-bdeps\fR option. This option is enabled automatically for
66 +a dependency calculation if the cost of report generation is relatively
67 +insignificant (any calculation exclusively involving binary packages is
68 +exempt). The \fIEMERGE_DEFAULT_OPTS\fR variable may be used to disable
69 +this option by default.
70 +.TP
71 .BR \-\-changed\-use ", " \-U
72 Tells emerge to include installed packages where USE flags have
73 changed since installation. This option also implies the
74 diff --git a/pym/_emerge/create_depgraph_params.py b/pym/_emerge/create_depgraph_params.py
75 index cdea029ba..7d01610bb 100644
76 --- a/pym/_emerge/create_depgraph_params.py
77 +++ b/pym/_emerge/create_depgraph_params.py
78 @@ -126,6 +126,11 @@ def create_depgraph_params(myopts, myaction):
79 if changed_deps is not None:
80 myparams['changed_deps'] = changed_deps
81
82 + changed_deps_report = myopts.get('--changed-deps-report')
83 + if (changed_deps_report != 'n' and not
84 + (myaction == 'remove' or '--usepkgonly' in myopts)):
85 + myparams['changed_deps_report'] = True
86 +
87 if myopts.get("--selective") == "n":
88 # --selective=n can be used to remove selective
89 # behavior that may have been implied by some
90 diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
91 index 27bec3b32..d937264ab 100644
92 --- a/pym/_emerge/depgraph.py
93 +++ b/pym/_emerge/depgraph.py
94 @@ -462,6 +462,7 @@ class _dynamic_depgraph_config(object):
95 self._highest_pkg_cache = {}
96 self._highest_pkg_cache_cp_map = {}
97 self._flatten_atoms_cache = {}
98 + self._changed_deps_pkgs = {}
99
100 # Binary packages that have been rejected because their USE
101 # didn't match the user's config. It maps packages to a set
102 @@ -974,6 +975,85 @@ class depgraph(object):
103
104 return False
105
106 + def _changed_deps_report(self):
107 + """
108 + Report ebuilds for which the ebuild dependencies have
109 + changed since the installed instance was built. This is
110 + completely silent in the following cases:
111 +
112 + * --changed-deps or --dynamic-deps is enabled
113 + * none of the packages with changed deps are in the graph
114 + """
115 + if (self._dynamic_config.myparams.get("changed_deps", "n") == "y" or
116 + self._dynamic_config.myparams.get("dynamic_deps", "n") == "y"):
117 + return
118 +
119 + report_pkgs = []
120 + for pkg, ebuild in self._dynamic_config._changed_deps_pkgs.items():
121 + if pkg.repo != ebuild.repo:
122 + continue
123 + report_pkgs.append((pkg, ebuild))
124 +
125 + if not report_pkgs:
126 + return
127 +
128 + # TODO: Detect and report various issues:
129 + # - packages with unsatisfiable dependencies
130 + # - packages involved directly in slot or blocker conflicts
131 + # - direct parents of conflict packages
132 + # - packages that prevent upgrade of dependencies to latest versions
133 + graph = self._dynamic_config.digraph
134 + in_graph = False
135 + for pkg, ebuild in report_pkgs:
136 + if pkg in graph:
137 + in_graph = True
138 +
139 + # Packages with changed deps are harmless if they're not in the
140 + # graph, so it's safe to silently ignore them. This suppresses
141 + # noise for the unaffected user, even though some of the changed
142 + # dependencies might be worthy of revision bumps.
143 + if not in_graph:
144 + return
145 +
146 + writemsg("\n%s\n\n" % colorize("WARN",
147 + "!!! Detected ebuild dependency change(s) without revision bump:"),
148 + noiselevel=-1)
149 +
150 + for pkg, ebuild in report_pkgs:
151 + writemsg(" %s::%s" % (pkg.cpv, pkg.repo), noiselevel=-1)
152 + if pkg.root_config.settings["ROOT"] != "/":
153 + writemsg(" for %s" % (pkg.root,), noiselevel=-1)
154 + writemsg("\n", noiselevel=-1)
155 +
156 + msg = []
157 + if '--quiet' not in self._frozen_config.myopts:
158 + msg.extend([
159 + "",
160 + "NOTE: Refer to the following page for more information about dependency",
161 + " change(s) without revision bump:",
162 + "",
163 + " https://wiki.gentoo.org/wiki/Project:Portage/Changed_Deps",
164 + "",
165 + " In order to suppress reports about dependency changes, add",
166 + " --changed-deps-report=n to the EMERGE_DEFAULT_OPTS variable in",
167 + " '/etc/portage/make.conf'.",
168 + ])
169 +
170 + # Include this message for --quiet mode, since the user may be experiencing
171 + # problems that are solvable by using --changed-deps.
172 + msg.extend([
173 + "",
174 + "HINT: In order to avoid problems involving changed dependencies, use the",
175 + " --changed-deps option to automatically trigger rebuilds when changed",
176 + " dependencies are detected. Refer to the emerge man page for more",
177 + " information about this option.",
178 + ])
179 +
180 + for line in msg:
181 + if line:
182 + line = colorize("INFORM", line)
183 + writemsg(line + "\n", noiselevel=-1)
184 +
185 def _show_ignored_binaries(self):
186 """
187 Show binaries that have been ignored because their USE didn't
188 @@ -2569,6 +2649,10 @@ class depgraph(object):
189
190 changed = built_deps != unbuilt_deps
191
192 + if (changed and pkg.installed and
193 + self._dynamic_config.myparams.get("changed_deps_report")):
194 + self._dynamic_config._changed_deps_pkgs[pkg] = ebuild
195 +
196 return changed
197
198 def _create_graph(self, allow_unsatisfied=False):
199 @@ -6354,6 +6438,8 @@ class depgraph(object):
200 changed_deps = (
201 self._dynamic_config.myparams.get(
202 "changed_deps", "n") != "n")
203 + changed_deps_report = self._dynamic_config.myparams.get(
204 + "changed_deps_report")
205 binpkg_changed_deps = (
206 self._dynamic_config.myparams.get(
207 "binpkg_changed_deps", "n") != "n")
208 @@ -6395,9 +6481,13 @@ class depgraph(object):
209 continue
210 break
211
212 - if (((installed and changed_deps) or
213 - (not installed and binpkg_changed_deps)) and
214 - self._changed_deps(pkg)):
215 + installed_changed_deps = False
216 + if installed and (changed_deps or changed_deps_report):
217 + installed_changed_deps = self._changed_deps(pkg)
218 +
219 + if ((installed_changed_deps and changed_deps) or
220 + (not installed and binpkg_changed_deps and
221 + self._changed_deps(pkg))):
222 if not installed:
223 self._dynamic_config.\
224 ignored_binaries.setdefault(
225 @@ -8753,6 +8843,8 @@ class depgraph(object):
226
227 self._show_ignored_binaries()
228
229 + self._changed_deps_report()
230 +
231 self._display_autounmask()
232
233 for depgraph_sets in self._dynamic_config.sets.values():
234 diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
235 index 6a4bb87d0..fbc2ce01c 100644
236 --- a/pym/_emerge/main.py
237 +++ b/pym/_emerge/main.py
238 @@ -136,6 +136,7 @@ def insert_optional_args(args):
239 '--binpkg-changed-deps' : y_or_n,
240 '--buildpkg' : y_or_n,
241 '--changed-deps' : y_or_n,
242 + '--changed-deps-report' : y_or_n,
243 '--complete-graph' : y_or_n,
244 '--deep' : valid_integers,
245 '--depclean-lib-check' : y_or_n,
246 @@ -408,6 +409,12 @@ def parse_opts(tmpcmdline, silent=False):
247 "choices" : true_y_or_n
248 },
249
250 + "--changed-deps-report": {
251 + "help" : ("report installed packages with "
252 + "outdated dependencies"),
253 + "choices" : true_y_or_n
254 + },
255 +
256 "--config-root": {
257 "help":"specify the location for portage configuration files",
258 "action":"store"
259 @@ -833,6 +840,12 @@ def parse_opts(tmpcmdline, silent=False):
260 else:
261 myoptions.changed_deps = 'n'
262
263 + if myoptions.changed_deps_report is not None:
264 + if myoptions.changed_deps_report in true_y:
265 + myoptions.changed_deps_report = 'y'
266 + else:
267 + myoptions.changed_deps_report = 'n'
268 +
269 if myoptions.changed_use is not False:
270 myoptions.reinstall = "changed-use"
271 myoptions.changed_use = False
272 --
273 2.13.6