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