Merge lp:~brian-murray/ubuntu-archive-tools/or-deps into lp:ubuntu-archive-tools

Proposed by Brian Murray
Status: Merged
Merged at revision: 1500
Proposed branch: lp:~brian-murray/ubuntu-archive-tools/or-deps
Merge into: lp:ubuntu-archive-tools
Diff against target: 175 lines (+37/-18)
2 files modified
checkrdepends (+20/-11)
nbs-report (+17/-7)
To merge this branch: bzr merge lp:~brian-murray/ubuntu-archive-tools/or-deps
Reviewer Review Type Date Requested Status
Steve Langasek Approve
Ubuntu Package Archive Administrators Pending
Review via email: mp+405498@code.launchpad.net

Description of the change

This is a resurrection of mterry's branch to OR deps in the NBS report which was originally registered here:

https://code.launchpad.net/~mterry/ubuntu-archive-tools/or-deps/+merge/115445

I had to make some changes to it due to the architecture and recommends changes, well and because it was almost 9 years old, but I think its good to go now.

I've tested nbs-report on snakefruit with the current NBS output for impish and I also ran checkrdepends on a few packages which aren't NBS and used that as input for nbs-report as a further test.

To post a comment you must log in.
Revision history for this message
Brian Murray (brian-murray) wrote :
Revision history for this message
Steve Langasek (vorlon) wrote :

Currently the NBS report on https://people.canonical.com/~ubuntu-archive/nbs.html is empty so we can't see whether the output differs. How can we test this before merging, to confirm that the output is what we expect with the new feature?

Revision history for this message
Brian Murray (brian-murray) wrote :

Looking at cron.NBS we can see that archive-cruft is used to generate a list of package for checkrdepends to run on and then nbs-report uses the output of checkrdepends to create its report. So one could just run checkrdepends for a selection of interesting packages, which are not cruft, and then run nbs-report to confirm the output.

Revision history for this message
Steve Langasek (vorlon) wrote :

Tested, the output looks sane/correct on a test package.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'checkrdepends'
--- checkrdepends 2021-04-23 08:44:48 +0000
+++ checkrdepends 2021-07-10 01:03:37 +0000
@@ -36,10 +36,13 @@
36# Cheaper version of deb822.PkgRelation.parse_relations.36# Cheaper version of deb822.PkgRelation.parse_relations.
37def parse_relation_packages(raw):37def parse_relation_packages(raw):
38 for or_dep in raw.split(','):38 for or_dep in raw.split(','):
39 dep_list = []
39 for dep in or_dep.split('|'):40 for dep in or_dep.split('|'):
40 match = re_dep.match(dep.strip())41 match = re_dep.match(dep.strip())
41 if match:42 if match:
42 yield match.group(1)43 dep_list.append(match.group(1))
44 for dep in dep_list:
45 yield dep, dep_list
4346
4447
45def primary_arches(suite):48def primary_arches(suite):
@@ -81,8 +84,9 @@
81 for field in ('build-depends', 'build-depends-indep'):84 for field in ('build-depends', 'build-depends-indep'):
82 if field not in stanza:85 if field not in stanza:
83 continue86 continue
84 for depname in parse_relation_packages(stanza[field]):87 for depname, depwhy in parse_relation_packages(stanza[field]):
85 build_deps[depname].add(name)88 build_deps.setdefault(depname, set())
89 build_deps[depname].add((name, '|'.join(depwhy)))
86 return ret90 return ret
8791
8892
@@ -95,14 +99,15 @@
95 for field in ('pre-depends', 'depends', 'recommends'):99 for field in ('pre-depends', 'depends', 'recommends'):
96 if field not in stanza:100 if field not in stanza:
97 continue101 continue
98 for depname in parse_relation_packages(stanza[field]):102 for depname, depwhy in parse_relation_packages(stanza[field]):
99 if depname not in debs:103 if depname not in debs:
100 continue104 continue
101 # skip dependencies that are built from the same source,105 # skip dependencies that are built from the same source,
102 # when we're doing a sourceful removal.106 # when we're doing a sourceful removal.
103 if name in ignores:107 if name in ignores:
104 continue108 continue
105 deps[depname][name] = (field, stanza['architecture'])109 deps[depname][name] = (field, stanza['architecture'],
110 '|'.join(depwhy))
106 except IOError:111 except IOError:
107 if not missing_ok:112 if not missing_ok:
108 raise113 raise
@@ -134,12 +139,14 @@
134 return ('', '-updates', '-security', '-backports')139 return ('', '-updates', '-security', '-backports')
135140
136141
137def render_dep(name, field, arch):142def render_dep(name, field, arch, why):
138 ret = name143 ret = name
139 if field == "recommends":144 if field == "recommends":
140 ret += " (r)"145 ret += " (r)"
141 if arch == "all":146 if arch == "all":
142 ret += " [all]"147 ret += " [all]"
148 if why:
149 ret += " %s" % why
143 return ret150 return ret
144151
145152
@@ -188,8 +195,8 @@
188 if deb in build_deps:195 if deb in build_deps:
189 print("-- %s%s/%s build deps on %s:" %196 print("-- %s%s/%s build deps on %s:" %
190 (opts.suite, pocket, comp, deb), file=out)197 (opts.suite, pocket, comp, deb), file=out)
191 for pkg in sorted(build_deps[deb]):198 for pkg, why in sorted(build_deps[deb]):
192 print(pkg, file=out)199 print(pkg, why, file=out)
193200
194 # binary dependencies201 # binary dependencies
195 for arch in arches:202 for arch in arches:
@@ -221,15 +228,17 @@
221 if deb in deps:228 if deb in deps:
222 print("-- %s%s/%s %s deps on %s:" %229 print("-- %s%s/%s %s deps on %s:" %
223 (opts.suite, pocket, comp, arch, deb), file=out)230 (opts.suite, pocket, comp, arch, deb), file=out)
224 for pkg, (field, pkgarch) in sorted(deps[deb].items()):231 for pkg, (field, pkgarch, why) in sorted(deps[deb].items()):
225 print(render_dep(pkg, field, pkgarch), file=out)232 print(render_dep(pkg, field, pkgarch, why),
233 file=out)
226 if deb in di_deps:234 if deb in di_deps:
227 print("-- %s%s/%s %s deps on %s:" %235 print("-- %s%s/%s %s deps on %s:" %
228 (opts.suite, pocket, di_comp, arch, deb),236 (opts.suite, pocket, di_comp, arch, deb),
229 file=out)237 file=out)
230 for pkg, (field, pkgarch) in sorted(238 for pkg, (field, pkgarch) in sorted(
231 di_deps[deb].items()):239 di_deps[deb].items()):
232 print(render_dep(pkg, field, pkgarch), file=out)240 print(render_dep(pkg, field, pkgarch, why),
241 file=out)
233242
234 if opts.directory is not None:243 if opts.directory is not None:
235 out.close()244 out.close()
236245
=== modified file 'nbs-report'
--- nbs-report 2021-04-23 08:44:48 +0000
+++ nbs-report 2021-07-10 01:03:37 +0000
@@ -39,6 +39,7 @@
3939
40 cur_component = None40 cur_component = None
41 cur_arch = None41 cur_arch = None
42 why = None
4243
43 with open(path) as f:44 with open(path) as f:
44 for line in f:45 for line in f:
@@ -47,9 +48,13 @@
47 continue48 continue
48 assert cur_component49 assert cur_component
49 assert cur_arch50 assert cur_arch
5051 # line can contain " (r)" or " [all]" in the middle
51 rdep = line.strip().split()[0]52 rdep = line.strip().split()[0]
52 pkgmap.setdefault(rdep, (cur_component, []))[1].append(cur_arch)53 pkgmap.setdefault(rdep, (cur_component, [], []))[1].append(cur_arch)
54 if len(line.strip().split()) >= 2:
55 why = line.strip().split()[-1]
56 if why not in pkgmap[rdep][2]:
57 pkgmap[rdep][2].append(why)
5358
5459
55def _pkg_removable(options, pkg, nbs, checked_v):60def _pkg_removable(options, pkg, nbs, checked_v):
@@ -115,7 +120,7 @@
115 except KeyError:120 except KeyError:
116 pass121 pass
117 return False122 return False
118 if not _pkg_removable(options, rdep, nbs, checked_v):123 elif not _pkg_removable(options, rdep, nbs, checked_v):
119 try:124 try:
120 checked_v.remove(rdep)125 checked_v.remove(rdep)
121 except KeyError:126 except KeyError:
@@ -198,12 +203,12 @@
198 cls = 'removable'203 cls = 'removable'
199 else:204 else:
200 cls = 'normal'205 cls = 'normal'
201 print('<tr><th colspan="4"><span class="%s">%s</span></th></tr>\n' %206 print('<tr><td colspan="5"><span class="%s">%s</span></td></tr>\n' %
202 (cls, pkg), end="")207 (cls, pkg), end="")
203 for rdep in sorted(nbsmap):208 for rdep in sorted(nbsmap):
204 if rdep in rdeps_with_alternates:209 if rdep in rdeps_with_alternates:
205 continue210 continue
206 (component, arches) = nbsmap[rdep]211 (component, arches, why) = nbsmap[rdep]
207212
208 if component in ('main', 'restricted'):213 if component in ('main', 'restricted'):
209 component_cls = 'sup'214 component_cls = 'sup'
@@ -220,11 +225,16 @@
220 reverse_nbs[rdep].append(pkg)225 reverse_nbs[rdep].append(pkg)
221 pkg_component[rdep] = (component, component_cls)226 pkg_component[rdep] = (component, component_cls)
222227
228 whyhtml = ''
229 if why != pkg:
230 whyhtml = ' | '.join(why)
231
223 print('<tr><td>&nbsp; &nbsp; </td>', end='')232 print('<tr><td>&nbsp; &nbsp; </td>', end='')
224 print('<td><span class="%s">%s</span></td> ' % (cls, rdep), end='')233 print('<td><span class="%s">%s</span></td> ' % (cls, rdep), end='')
225 print('<td><span class="component%s">%s</span></td>' %234 print('<td><span class="component%s">%s</span></td>' %
226 (component_cls, component), end='')235 (component_cls, component), end='')
227 print('<td>%s</td></tr>' % ' '.join(arches))236 print('<td>%s</td>' % ' '.join(arches), end='')
237 print('<td>%s</td></tr>' % whyhtml)
228238
229 print('''</table>239 print('''</table>
230<h2>Packages which depend on NBS packages</h2>240<h2>Packages which depend on NBS packages</h2>
@@ -276,7 +286,7 @@
276286
277 options.time = time.time()287 options.time = time.time()
278288
279 # pkg -> rdep_pkg -> (component, [arch1, arch2, ...])289 # pkg -> rdep_pkg -> (component, [arch1, arch2, ...], [why])
280 nbs = defaultdict(dict)290 nbs = defaultdict(dict)
281291
282 for f in os.listdir(args[0]):292 for f in os.listdir(args[0]):

Subscribers

People subscribed via source and target branches