Merge lp:~sil2100/ubuntu-archive-tools/kernel-sru-review-esm into lp:ubuntu-archive-tools

Proposed by Łukasz Zemczak
Status: Merged
Merged at revision: 1124
Proposed branch: lp:~sil2100/ubuntu-archive-tools/kernel-sru-review-esm
Merge into: lp:ubuntu-archive-tools
Diff against target: 184 lines (+79/-26)
1 file modified
kernel-sru-review (+79/-26)
To merge this branch: bzr merge lp:~sil2100/ubuntu-archive-tools/kernel-sru-review-esm
Reviewer Review Type Date Requested Status
Ubuntu Package Archive Administrators Pending
Review via email: mp+330212@code.launchpad.net

Commit message

Add support for ESM into the kernel-sru-review tool.

Description of the change

Add support for ESM into the kernel-sru-review tool.

This branch adds the --esm option to the kernel review tool. The way it's done is by using the subscription URL and dget for all downloads from the security PPAs. For this to work, lazr.restfulclient version 0.13.5 or higher is required due to LP: #1714960. But this branch has been tested 'in production' and works with the required library version.

To post a comment you must log in.
1116. By Łukasz Zemczak

Some additional fixes to the ESM support in kernel-sru-review - handle the case of looking for ESM packages in the ESM release PPA.

1117. By Łukasz Zemczak

Forgot to commit a typo fix.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'kernel-sru-review'
2--- kernel-sru-review 2017-07-14 10:10:08 +0000
3+++ kernel-sru-review 2017-09-22 20:57:55 +0000
4@@ -25,7 +25,7 @@
5 ABI strings in debian/control et al.)
6
7 USAGE:
8- kernel-sru-review [-s precise] linux
9+ kernel-sru-review <bug number>
10 """
11
12 import glob
13@@ -68,13 +68,16 @@
14
15
16 def review_source_callback(lp, bugnum, tasks, full_packages, release, context):
17+ # as per LP: #1290543, we need to evaluate (load) lp.me for
18+ # getArchiveSubscritionURL to work
19+ me = lp.load(lp.me.self_link)
20 for source in full_packages:
21 process_source_package(
22- source, release, context['archive'], context['ppa'],
23+ source, release, me, context['archive'], context['ppa'],
24 context['ubuntu'], context['startdir'], context['workdir'],
25- context['tardir'], context['tarcache'])
26+ context['esm'], context['tardir'], context['tarcache'])
27 tasks['proposed'].status = 'Fix Committed'
28- tasks['proposed'].assignee = lp.me
29+ tasks['proposed'].assignee = me
30 tasks['proposed'].lp_save()
31
32
33@@ -121,8 +124,9 @@
34 shutil.copy(tarball, target)
35
36
37-def process_source_package(source, release, archive, ppa, ubuntu,
38- start_dir, work_dir, tardir=None, tar_cache=False):
39+def process_source_package(source, release, me, archive, ppa, ubuntu,
40+ start_dir, work_dir, esm=False,
41+ tardir=None, tar_cache=False):
42 series = ubuntu.getSeries(name_or_version=release)
43
44 ppa_src = ppa.getPublishedSources(order_by_date=True,
45@@ -132,25 +136,52 @@
46 ppa_ver = ppa_src.source_package_version
47 ppa_dsc = list(filter(
48 lambda x: x.endswith('.dsc'), ppa_src.sourceFileUrls()))[0]
49-
50- archive_uploads = series.getPackageUploads(version=ppa_ver,
51- name=source,
52- archive=archive,
53- exact_match=True)
54- for upload in archive_uploads:
55- if upload.status != 'Rejected':
56- print("%s_%s already copied to Ubuntu archive (%s), skipping" %
57- (source, ppa_ver, upload.status))
58- return
59-
60- srcpkg = archive.getPublishedSources(order_by_date=True,
61- status='Published', exact_match=True,
62+ if ppa.private:
63+ priv_url = me.getArchiveSubscriptionURL(archive=ppa)
64+ dsc_file = os.path.basename(ppa_dsc)
65+ ppa_dsc = os.path.join(priv_url, 'pool/main/l', source, dsc_file)
66+
67+ # since we can have one archive for more than one 'pocket', no need to do
68+ # API calls more than once
69+ scanned = set()
70+ for pocket in archive.values():
71+ if pocket.self_link in scanned:
72+ continue
73+ archive_uploads = series.getPackageUploads(version=ppa_ver,
74+ name=source,
75+ archive=pocket,
76+ exact_match=True)
77+ for upload in archive_uploads:
78+ if upload.status != 'Rejected':
79+ print("%s_%s already copied to Ubuntu archive (%s), skipping" %
80+ (source, ppa_ver, upload.status))
81+ return
82+ scanned.add(pocket.self_link)
83+
84+ # in cases where we have a separate archive for proposed and release,
85+ # we need to check both places in the order proposed -> release
86+ target = archive['proposed']
87+ srcpkgs = target.getPublishedSources(order_by_date=True,
88+ status='Published',
89+ exact_match=True,
90 distro_series=series,
91- source_name=source)[0]
92+ source_name=source)
93+ if len(srcpkgs) == 0:
94+ target = archive['release']
95+ srcpkgs = target.getPublishedSources(order_by_date=True,
96+ status='Published',
97+ exact_match=True,
98+ distro_series=series,
99+ source_name=source)
100+ srcpkg = srcpkgs[0]
101 source_ver = srcpkg.source_package_version
102 source_dsc = list(filter(
103 lambda x: x.endswith('.dsc'),
104 srcpkg.sourceFileUrls()))[0]
105+ if target.private:
106+ priv_url = me.getArchiveSubscriptionURL(archive=target)
107+ dsc_file = os.path.basename(source_dsc)
108+ source_dsc = os.path.join(priv_url, 'pool/main/l', source, dsc_file)
109
110 new_fullabi = ppa_ver.split('~')[0]
111 new_majorabi = re.sub(r"\.[^.]+$", '', new_fullabi)
112@@ -164,7 +195,12 @@
113 work_dir, tardir, source, old_upstream, start_dir)
114
115 # grab the old source first
116- pull_cmd = ['pull-lp-source', source, source_ver]
117+ if esm:
118+ pull_cmd = ['dget', '-u', source_dsc]
119+ else:
120+ # for non-ESM cases, it's just more reliable to use pull-lp-source
121+ pull_cmd = ['pull-lp-source', source, source_ver]
122+
123 try:
124 subprocess.check_call(pull_cmd)
125 except subprocess.CalledProcessError as e:
126@@ -217,6 +253,8 @@
127 response = sys.stdin.readline()
128 if response.strip().lower().startswith('y'):
129 copy_cmd = ['copy-proposed-kernel', release, source]
130+ if esm:
131+ copy_cmd.append('--esm')
132 copy_time = datetime.datetime.now(tz=pytz.utc)
133 try:
134 subprocess.check_call(copy_cmd)
135@@ -238,7 +276,7 @@
136 # only include uefi binaries that have appeared since we started the
137 # copy to avoid accepting something that might have been improperly
138 # copied into the queue by an "attacker" with upload rights.
139- uefis = series.getPackageUploads(archive=archive,
140+ uefis = series.getPackageUploads(archive=target,
141 pocket='Proposed',
142 status='Unapproved',
143 custom_type='uefi',
144@@ -266,6 +304,8 @@
145 "-C", "--cache-tarballs", dest="caching", action="store_true")
146 parser.add_option(
147 "-t", "--tarball-directory", dest="tardir", default=cachedir)
148+ parser.add_option(
149+ "-e", "--esm", dest="esm", action="store_true")
150
151 opts, bugs = parser.parse_args()
152
153@@ -290,14 +330,27 @@
154 'ubuntu-archive-tools', opts.launchpad_instance, version='devel')
155
156 ubuntu = launchpad.distributions['ubuntu']
157- archive = ubuntu.main_archive
158- ppa = launchpad.people['canonical-kernel-team'].getPPAByName(
159- distribution=ubuntu, name='ppa')
160+ # for ESM (precise) we use special PPAs for CKT testing, -proposed and
161+ # release
162+ archive = {}
163+ if opts.esm:
164+ team = 'canonical-kernel-esm'
165+ archive['proposed'] = launchpad.people[team].getPPAByName(
166+ distribution=ubuntu, name='proposed')
167+ archive['release'] = launchpad.people['ubuntu-esm'].getPPAByName(
168+ distribution=ubuntu, name='esm')
169+ else:
170+ team = 'canonical-kernel-team'
171+ archive['proposed'] = archive['release'] = ubuntu.main_archive
172+ ppa = launchpad.people[team].getPPAByName(
173+ distribution=ubuntu, name='ppa')
174
175 start_dir = os.getcwd()
176 context = {
177 'archive': archive, 'ppa': ppa, 'ubuntu': ubuntu,
178- 'tardir': tardir, 'tarcache': opts.caching, 'startdir': start_dir }
179+ 'tardir': tardir, 'tarcache': opts.caching, 'startdir': start_dir,
180+ 'esm': opts.esm
181+ }
182 for bugnum in bugs:
183 with ExitStack() as resources:
184 cwd = mkdtemp(prefix='kernel-sru-%s-' % bugnum, dir=start_dir)

Subscribers

People subscribed via source and target branches