3
# Copyright (C) 2020 Canonical Ltd.
4
# Author: Steve Langasek <steve.langasek@canonical.com>
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; version 3 of the License.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
'''Synchronize the i386 source package whitelist in Launchpad with the output
22
update-i386-whitelist [--dry-run] https://people.canonical.com/~ubuntu-archive/germinate-output/i386.focal/i386+build-depends.sources
25
from launchpadlib.launchpad import Launchpad
27
from urllib.request import urlopen
30
def get_sources_from_url(url):
31
'''Download the germinate output and parse out the list of sources.
33
Returns list of source package names.
39
if i.startswith(b'Source') or i.startswith(b'---'):
41
sources.append(i.decode('utf-8').split(' ',maxsplit=1)[0])
45
'''Parse command line arguments.
47
Return (options, source_package) tuple.
49
parser = optparse.OptionParser(
50
usage='Usage: %prog [--dry-run] https://people.canonical.com/~ubuntu-archive/germinate-output/i386.focal/i386+build-depends.sources')
52
"--dry-run", help="don't change launchpad, just report the delta",
55
"-s", dest="release", default=default_release, metavar="RELEASE",
56
help="release (default: %s)" % default_release)
58
(opts, args) = parser.parse_args()
61
parser.error('Need to specify a URL to sync from')
63
return (opts, args[0])
66
if __name__ == '__main__':
68
default_release = 'focal'
70
(opts, url) = parse_options()
72
launchpad = Launchpad.login_with('update-i386-whitelist',
75
ubuntu = launchpad.distributions['ubuntu']
76
series = ubuntu.getSeries(name_or_version=opts.release)
77
archive = ubuntu.main_archive
79
sources = get_sources_from_url(url)
81
packageset = launchpad.packagesets.getByName(name='i386-whitelist',
83
currentSet = set(packageset.getSourcesIncluded())
85
# hard-coded list of ppa-only additions; can maybe go away when
86
# https://bugs.launchpad.net/launchpad/+bug/1855069 is fixed, but this is
87
# also potentially useful for bootstrapping any additional packages into
88
# the archive if needed.
89
newSet.add(('gcc-10',))
91
additions = list(newSet-currentSet)
96
removals = list(currentSet-newSet)
101
print("--dry-run is set, doing nothing.")
105
packageset.addSources(names=additions)
107
packageset.removeSources(names=removals)