Merge lp:~vorlon/ubuntu-archive-tools/update-i386-whitelist into lp:ubuntu-archive-tools

Proposed by Steve Langasek
Status: Merged
Merged at revision: 1252
Proposed branch: lp:~vorlon/ubuntu-archive-tools/update-i386-whitelist
Merge into: lp:ubuntu-archive-tools
Diff against target: 111 lines (+107/-0)
1 file modified
update-i386-whitelist (+107/-0)
To merge this branch: bzr merge lp:~vorlon/ubuntu-archive-tools/update-i386-whitelist
Reviewer Review Type Date Requested Status
Adam Conrad (community) Approve
Review via email: mp+376042@code.launchpad.net
To post a comment you must log in.
1253. By Steve Langasek

Add a manual whitelist of ppa-only packages

Revision history for this message
Adam Conrad (adconrad) wrote :

The PPA hack is icky, but given I filed the relevant LP bug, I understand why it's there. Might do with a comment referencing the bug and encouraging removal.

My only other comment (not a blocker, cause I'm not convinced we'll ever have another partial arch, but it seems more in the spirit of the feature?) is that it should probably be named update-arch-whitelist and take a '-a' argument that fills in all the bits in the source that currently hardcode i386.

Approved with or without those changes, though I think I'd strongly prefer the latter happen (it can default to i386 for now, given that's our only partial arch, if that makes it more palatable to you).

review: Approve
Revision history for this message
Adam Conrad (adconrad) wrote :

Hah, and when I said "all the places that hardcode i386", I guess the number of places is exactly one (the packageset), but my brain had somehow filled in that the URL argument had a default too, while it appears not to.

Other tooling in ubuntu-archive-tools is vaguely inconsistent on that front, to be fair, but either defaulting to a local file URL (assuming it'll run on snakefruit most often) or an https one (assuming it's more likely to be run remotely) might not be terribad. I dunno. The URL being in --help makes it a no-brained to copy-pasta, so whatevs.

1254. By Steve Langasek

fuller comment

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'update-i386-whitelist'
2--- update-i386-whitelist 1970-01-01 00:00:00 +0000
3+++ update-i386-whitelist 2019-12-05 18:29:44 +0000
4@@ -0,0 +1,107 @@
5+#!/usr/bin/python3
6+
7+# Copyright (C) 2020 Canonical Ltd.
8+# Author: Steve Langasek <steve.langasek@canonical.com>
9+
10+# This program is free software: you can redistribute it and/or modify
11+# it under the terms of the GNU General Public License as published by
12+# the Free Software Foundation; version 3 of the License.
13+#
14+# This program is distributed in the hope that it will be useful,
15+# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+# GNU General Public License for more details.
18+#
19+# You should have received a copy of the GNU General Public License
20+# along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
22+'''Synchronize the i386 source package whitelist in Launchpad with the output
23+of germinate.
24+
25+USAGE:
26+ update-i386-whitelist [--dry-run] https://people.canonical.com/~ubuntu-archive/germinate-output/i386.focal/i386+build-depends.sources
27+'''
28+
29+from launchpadlib.launchpad import Launchpad
30+import optparse
31+from urllib.request import urlopen
32+import sys
33+
34+def get_sources_from_url(url):
35+ '''Download the germinate output and parse out the list of sources.
36+
37+ Returns list of source package names.
38+ '''
39+ sources = []
40+
41+ file = urlopen(url)
42+ for i in file:
43+ if i.startswith(b'Source') or i.startswith(b'---'):
44+ continue
45+ sources.append(i.decode('utf-8').split(' ',maxsplit=1)[0])
46+ return sources
47+
48+def parse_options():
49+ '''Parse command line arguments.
50+
51+ Return (options, source_package) tuple.
52+ '''
53+ parser = optparse.OptionParser(
54+ usage='Usage: %prog [--dry-run] https://people.canonical.com/~ubuntu-archive/germinate-output/i386.focal/i386+build-depends.sources')
55+ parser.add_option(
56+ "--dry-run", help="don't change launchpad, just report the delta",
57+ action="store_true")
58+ parser.add_option(
59+ "-s", dest="release", default=default_release, metavar="RELEASE",
60+ help="release (default: %s)" % default_release)
61+
62+ (opts, args) = parser.parse_args()
63+
64+ if len(args) != 1:
65+ parser.error('Need to specify a URL to sync from')
66+
67+ return (opts, args[0])
68+
69+
70+if __name__ == '__main__':
71+
72+ default_release = 'focal'
73+
74+ (opts, url) = parse_options()
75+
76+ launchpad = Launchpad.login_with('update-i386-whitelist',
77+ 'production',
78+ version="devel")
79+ ubuntu = launchpad.distributions['ubuntu']
80+ series = ubuntu.getSeries(name_or_version=opts.release)
81+ archive = ubuntu.main_archive
82+
83+ sources = get_sources_from_url(url)
84+
85+ packageset = launchpad.packagesets.getByName(name='i386-whitelist',
86+ distroseries=series)
87+ currentSet = set(packageset.getSourcesIncluded())
88+ newSet = set(sources)
89+ # hard-coded list of ppa-only additions; can maybe go away when
90+ # https://bugs.launchpad.net/launchpad/+bug/1855069 is fixed, but this is
91+ # also potentially useful for bootstrapping any additional packages into
92+ # the archive if needed.
93+ newSet.add(('gcc-10',))
94+ print("Additions:" )
95+ additions = list(newSet-currentSet)
96+ additions.sort()
97+ for i in additions:
98+ print(" * %s" % i)
99+ print("Removals:" )
100+ removals = list(currentSet-newSet)
101+ removals.sort()
102+ for i in removals:
103+ print(" * %s" % i)
104+ if opts.dry_run:
105+ print("--dry-run is set, doing nothing.")
106+ sys.exit(0)
107+
108+ if additions:
109+ packageset.addSources(names=additions)
110+ if removals:
111+ packageset.removeSources(names=removals)

Subscribers

People subscribed via source and target branches