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
1=== modified file 'checkrdepends'
2--- checkrdepends 2021-04-23 08:44:48 +0000
3+++ checkrdepends 2021-07-10 01:03:37 +0000
4@@ -36,10 +36,13 @@
5 # Cheaper version of deb822.PkgRelation.parse_relations.
6 def parse_relation_packages(raw):
7 for or_dep in raw.split(','):
8+ dep_list = []
9 for dep in or_dep.split('|'):
10 match = re_dep.match(dep.strip())
11 if match:
12- yield match.group(1)
13+ dep_list.append(match.group(1))
14+ for dep in dep_list:
15+ yield dep, dep_list
16
17
18 def primary_arches(suite):
19@@ -81,8 +84,9 @@
20 for field in ('build-depends', 'build-depends-indep'):
21 if field not in stanza:
22 continue
23- for depname in parse_relation_packages(stanza[field]):
24- build_deps[depname].add(name)
25+ for depname, depwhy in parse_relation_packages(stanza[field]):
26+ build_deps.setdefault(depname, set())
27+ build_deps[depname].add((name, '|'.join(depwhy)))
28 return ret
29
30
31@@ -95,14 +99,15 @@
32 for field in ('pre-depends', 'depends', 'recommends'):
33 if field not in stanza:
34 continue
35- for depname in parse_relation_packages(stanza[field]):
36+ for depname, depwhy in parse_relation_packages(stanza[field]):
37 if depname not in debs:
38 continue
39 # skip dependencies that are built from the same source,
40 # when we're doing a sourceful removal.
41 if name in ignores:
42 continue
43- deps[depname][name] = (field, stanza['architecture'])
44+ deps[depname][name] = (field, stanza['architecture'],
45+ '|'.join(depwhy))
46 except IOError:
47 if not missing_ok:
48 raise
49@@ -134,12 +139,14 @@
50 return ('', '-updates', '-security', '-backports')
51
52
53-def render_dep(name, field, arch):
54+def render_dep(name, field, arch, why):
55 ret = name
56 if field == "recommends":
57 ret += " (r)"
58 if arch == "all":
59 ret += " [all]"
60+ if why:
61+ ret += " %s" % why
62 return ret
63
64
65@@ -188,8 +195,8 @@
66 if deb in build_deps:
67 print("-- %s%s/%s build deps on %s:" %
68 (opts.suite, pocket, comp, deb), file=out)
69- for pkg in sorted(build_deps[deb]):
70- print(pkg, file=out)
71+ for pkg, why in sorted(build_deps[deb]):
72+ print(pkg, why, file=out)
73
74 # binary dependencies
75 for arch in arches:
76@@ -221,15 +228,17 @@
77 if deb in deps:
78 print("-- %s%s/%s %s deps on %s:" %
79 (opts.suite, pocket, comp, arch, deb), file=out)
80- for pkg, (field, pkgarch) in sorted(deps[deb].items()):
81- print(render_dep(pkg, field, pkgarch), file=out)
82+ for pkg, (field, pkgarch, why) in sorted(deps[deb].items()):
83+ print(render_dep(pkg, field, pkgarch, why),
84+ file=out)
85 if deb in di_deps:
86 print("-- %s%s/%s %s deps on %s:" %
87 (opts.suite, pocket, di_comp, arch, deb),
88 file=out)
89 for pkg, (field, pkgarch) in sorted(
90 di_deps[deb].items()):
91- print(render_dep(pkg, field, pkgarch), file=out)
92+ print(render_dep(pkg, field, pkgarch, why),
93+ file=out)
94
95 if opts.directory is not None:
96 out.close()
97
98=== modified file 'nbs-report'
99--- nbs-report 2021-04-23 08:44:48 +0000
100+++ nbs-report 2021-07-10 01:03:37 +0000
101@@ -39,6 +39,7 @@
102
103 cur_component = None
104 cur_arch = None
105+ why = None
106
107 with open(path) as f:
108 for line in f:
109@@ -47,9 +48,13 @@
110 continue
111 assert cur_component
112 assert cur_arch
113-
114+ # line can contain " (r)" or " [all]" in the middle
115 rdep = line.strip().split()[0]
116- pkgmap.setdefault(rdep, (cur_component, []))[1].append(cur_arch)
117+ pkgmap.setdefault(rdep, (cur_component, [], []))[1].append(cur_arch)
118+ if len(line.strip().split()) >= 2:
119+ why = line.strip().split()[-1]
120+ if why not in pkgmap[rdep][2]:
121+ pkgmap[rdep][2].append(why)
122
123
124 def _pkg_removable(options, pkg, nbs, checked_v):
125@@ -115,7 +120,7 @@
126 except KeyError:
127 pass
128 return False
129- if not _pkg_removable(options, rdep, nbs, checked_v):
130+ elif not _pkg_removable(options, rdep, nbs, checked_v):
131 try:
132 checked_v.remove(rdep)
133 except KeyError:
134@@ -198,12 +203,12 @@
135 cls = 'removable'
136 else:
137 cls = 'normal'
138- print('<tr><th colspan="4"><span class="%s">%s</span></th></tr>\n' %
139+ print('<tr><td colspan="5"><span class="%s">%s</span></td></tr>\n' %
140 (cls, pkg), end="")
141 for rdep in sorted(nbsmap):
142 if rdep in rdeps_with_alternates:
143 continue
144- (component, arches) = nbsmap[rdep]
145+ (component, arches, why) = nbsmap[rdep]
146
147 if component in ('main', 'restricted'):
148 component_cls = 'sup'
149@@ -220,11 +225,16 @@
150 reverse_nbs[rdep].append(pkg)
151 pkg_component[rdep] = (component, component_cls)
152
153+ whyhtml = ''
154+ if why != pkg:
155+ whyhtml = ' | '.join(why)
156+
157 print('<tr><td>&nbsp; &nbsp; </td>', end='')
158 print('<td><span class="%s">%s</span></td> ' % (cls, rdep), end='')
159 print('<td><span class="component%s">%s</span></td>' %
160 (component_cls, component), end='')
161- print('<td>%s</td></tr>' % ' '.join(arches))
162+ print('<td>%s</td>' % ' '.join(arches), end='')
163+ print('<td>%s</td></tr>' % whyhtml)
164
165 print('''</table>
166 <h2>Packages which depend on NBS packages</h2>
167@@ -276,7 +286,7 @@
168
169 options.time = time.time()
170
171- # pkg -> rdep_pkg -> (component, [arch1, arch2, ...])
172+ # pkg -> rdep_pkg -> (component, [arch1, arch2, ...], [why])
173 nbs = defaultdict(dict)
174
175 for f in os.listdir(args[0]):

Subscribers

People subscribed via source and target branches