Merge ~nacc/git-ubuntu:fix-lxd-changelog-parsing into git-ubuntu:master

Proposed by Nish Aravamudan
Status: Merged
Approved by: Nish Aravamudan
Approved revision: ad202d524e55fcbf9e159125492f6c41bffd8681
Merged at revision: c87f9d4abcaf8ed20605fdbfc3642a0d088baec6
Proposed branch: ~nacc/git-ubuntu:fix-lxd-changelog-parsing
Merge into: git-ubuntu:master
Diff against target: 313 lines (+107/-18)
8 files modified
gitubuntu/build.py (+70/-13)
gitubuntu/buildsource.py (+7/-0)
gitubuntu/importlocal.py (+8/-5)
gitubuntu/source_information.py (+2/-0)
tests/changelogs/test_distribution_source_1 (+5/-0)
tests/changelogs/test_distribution_source_2 (+5/-0)
tests/changelogs/test_distribution_source_3 (+5/-0)
tests/changelogs/test_distribution_source_4 (+5/-0)
Reviewer Review Type Date Requested Status
Andreas Hasenack Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+332518@code.launchpad.net

Description of the change

Make jenkins happy.

To post a comment you must log in.
Revision history for this message
Nish Aravamudan (nacc) wrote :

This fixes issues with, e.g., building a srcpkg with zesty-security in the changelog.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

One needs-fixing inline. I tried to build a source package that had "devel" in d/changelog and I passed --lxd-image, but it still failed:

http://pastebin.ubuntu.com/25774817/

review: Needs Fixing
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:af31a4c05de9742478d994f6c51c24194f2303da
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/164/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Style Check
    SUCCESS: Unit Tests
    SUCCESS: Integration Tests
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/164/rebuild

review: Approve (continuous-integration)
ad202d5... by Nish Aravamudan

build: push derive_* calls into else (if not image)

This will be squashed up.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:ad202d524e55fcbf9e159125492f6c41bffd8681
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/167/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Style Check
    SUCCESS: Unit Tests
    SUCCESS: Integration Tests
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/167/rebuild

review: Approve (continuous-integration)
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Thanks, +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/gitubuntu/build.py b/gitubuntu/build.py
2index a8972f4..db0973f 100644
3--- a/gitubuntu/build.py
4+++ b/gitubuntu/build.py
5@@ -417,6 +417,7 @@ def main(
6 use_lxd=True,
7 keep_build_env=False,
8 lxd_profile=None,
9+ lxd_image=None,
10 retries=top_level_defaults.retries,
11 retry_backoffs=top_level_defaults.retry_backoffs,
12 ):
13@@ -431,6 +432,8 @@ def main(
14 after building
15 @param lxd_profile: string LXD profile to use, if @use_lxd is True.
16 If None, the default profile is used.
17+ @param lxd_image: string LXD image to use, if @use_lxd is True.
18+ If None, the image will be derived from HEAD:debian/changelog
19 @param retries: integer number of download retries to attempt
20 @param retry_backoffs: list of backoff durations to use between retries
21
22@@ -465,6 +468,7 @@ def main(
23 use_lxd,
24 keep_build_env,
25 lxd_profile,
26+ lxd_image,
27 retries,
28 retry_backoffs,
29 )
30@@ -546,6 +550,12 @@ def parse_args(subparsers=None, base_subparsers=None):
31 help="LXD profile to use. If not specified, the default profile "
32 "is used.",
33 )
34+ parser.add_argument(
35+ '--lxd-image',
36+ type=str,
37+ help="LXD image to use. If not specified, the image will be "
38+ "derived from distribution value of HEAD:debian/changelog.",
39+ )
40 parser.add_argument('rem_args', help=argparse.SUPPRESS,
41 nargs=argparse.REMAINDER)
42 if not subparsers:
43@@ -635,6 +645,7 @@ def cli_main(args):
44 use_lxd=not args.no_lxd,
45 keep_build_env=args.keep_build_env,
46 lxd_profile=args.lxd_profile,
47+ lxd_image=args.lxd_image,
48 retries=args.retries,
49 retry_backoffs=args.retry_backoffs,
50 )
51@@ -645,10 +656,39 @@ def cli_main(args):
52
53
54 def derive_source_from_changelog(changelog):
55- return derive_source_from_series(changelog.distribution)
56+ series = changelog.distribution.split('-')[0]
57+ return derive_source_from_series(series)
58+
59+@pytest.mark.parametrize('changelog_path, expected', [
60+ ('tests/changelogs/test_distribution_source_1', 'ubuntu'),
61+ ('tests/changelogs/test_distribution_source_2', 'ubuntu'),
62+ ('tests/changelogs/test_distribution_source_3', 'debian'),
63+ ('tests/changelogs/test_distribution_source_4', 'ubuntu'),
64+])
65+def test_derive_source_from_changelog(changelog_path, expected):
66+ assert derive_source_from_changelog(
67+ Changelog.from_path(changelog_path)
68+ ) == expected
69
70 def derive_codename_from_changelog(changelog):
71- return derive_codename_from_series(changelog.distribution)
72+ series = changelog.distribution.split('-')[0]
73+ return derive_codename_from_series(series)
74+
75+@pytest.mark.parametrize('changelog_path, expected', [
76+ ('tests/changelogs/test_distribution_source_1', 'xenial'),
77+ ('tests/changelogs/test_distribution_source_2', 'zesty'),
78+ ('tests/changelogs/test_distribution_source_3', 'sid'),
79+])
80+def test_derive_codename_from_changelog(changelog_path, expected):
81+ assert derive_codename_from_changelog(
82+ Changelog.from_path(changelog_path)
83+ ) == expected
84+ with pytest.raises(ValueError):
85+ derive_codename_from_changelog(
86+ Changelog.from_path(
87+ 'tests/changelogs/test_distribution_source_4',
88+ )
89+ )
90
91 def expand_changelog_source_aliases(orig_search_list, changelog):
92 """Replace 'changelog' sources by reading debian/changelog
93@@ -672,6 +712,7 @@ def do_build(
94 use_lxd,
95 keep_build_env,
96 lxd_profile,
97+ lxd_image,
98 retries,
99 retry_backoffs,
100 ):
101@@ -682,6 +723,7 @@ def do_build(
102 rem_args,
103 keep_build_env,
104 lxd_profile,
105+ lxd_image,
106 retries,
107 retry_backoffs,
108 )
109@@ -778,6 +820,7 @@ def do_build_lxd(
110 rem_args,
111 keep_build_env,
112 profile,
113+ image,
114 retries,
115 retry_backoffs,
116 ):
117@@ -788,6 +831,7 @@ def do_build_lxd(
118 rem_args,
119 keep_build_env,
120 profile,
121+ image,
122 retries,
123 retry_backoffs,
124 stack,
125@@ -821,6 +865,7 @@ def _do_build_lxd_exitstack(
126 rem_args,
127 keep_build_env,
128 profile,
129+ image,
130 retries,
131 retry_backoffs,
132 stack,
133@@ -852,21 +897,31 @@ def _do_build_lxd_exitstack(
134
135 container_name = 'gu-build-%s' % uuid.uuid4()
136
137- source = derive_source_from_changelog(changelog)
138- series = derive_codename_from_changelog(changelog)
139- devel_series = GitUbuntuSourceInformation(
140- dist_name=source
141- ).current_series_name
142 cmd = [lxc, 'launch', '-e']
143 if profile:
144 cmd.extend(['-p', profile])
145- if source == 'ubuntu':
146- if series == 'devel' or series == devel_series:
147- cmd.extend(['ubuntu-daily:%s' % devel_series,])
148- else:
149- cmd.extend(['ubuntu:%s' % series,])
150+ if image:
151+ cmd.extend([image,])
152 else:
153- cmd.extend(['images:debian/%s' % series,])
154+ try:
155+ source = derive_source_from_changelog(changelog)
156+ series = derive_codename_from_changelog(changelog)
157+ except ValueError:
158+ logging.error(
159+ "Unable to determine distribution and series from changelog, "
160+ "please pass --lxd-image to specify what image to use."
161+ )
162+ raise
163+ if source == 'ubuntu':
164+ devel_series = GitUbuntuSourceInformation(
165+ dist_name=source
166+ ).current_series_name
167+ if series == 'devel' or series == devel_series:
168+ cmd.extend(['ubuntu-daily:%s' % devel_series,])
169+ else:
170+ cmd.extend(['ubuntu:%s' % series,])
171+ else:
172+ cmd.extend(['images:debian/%s' % series,])
173 cmd.extend([container_name,])
174 try:
175 run(cmd)
176@@ -1032,6 +1087,7 @@ def fetch_orig_and_build(
177 use_lxd=True,
178 keep_build_env=False,
179 lxd_profile=None,
180+ lxd_image=None,
181 retries=top_level_defaults.retries,
182 retry_backoffs=top_level_defaults.retry_backoffs,
183 ):
184@@ -1061,6 +1117,7 @@ def fetch_orig_and_build(
185 use_lxd,
186 keep_build_env,
187 lxd_profile,
188+ lxd_image,
189 retries,
190 retry_backoffs,
191 )
192diff --git a/gitubuntu/buildsource.py b/gitubuntu/buildsource.py
193index 7c84768..02ba0ee 100644
194--- a/gitubuntu/buildsource.py
195+++ b/gitubuntu/buildsource.py
196@@ -68,6 +68,12 @@ def parse_args(subparsers=None, base_subparsers=None):
197 help="LXD profile to use. If not specified, the default profile "
198 "is used.",
199 )
200+ parser.add_argument(
201+ '--lxd-image',
202+ type=str,
203+ help="LXD image to use. If not specified, the image will be "
204+ "derived from distribution value of HEAD:debian/changelog.",
205+ )
206 parser.add_argument('rem_args', help=argparse.SUPPRESS,
207 nargs=argparse.REMAINDER
208 )
209@@ -121,6 +127,7 @@ def cli_main(args):
210 use_lxd=not args.no_lxd,
211 keep_build_env=args.keep_build_env,
212 lxd_profile=args.lxd_profile,
213+ lxd_image=args.lxd_image,
214 )
215 ) > 0:
216 return 0
217diff --git a/gitubuntu/importlocal.py b/gitubuntu/importlocal.py
218index 1f5b51d..16f3a6b 100644
219--- a/gitubuntu/importlocal.py
220+++ b/gitubuntu/importlocal.py
221@@ -4,8 +4,13 @@ import logging
222 import os
223 import sys
224 import tempfile
225+from gitubuntu.build import derive_source_from_changelog
226 from gitubuntu.dsc import GitUbuntuDsc
227-from gitubuntu.git_repository import GitUbuntuRepository, git_dep14_tag
228+from gitubuntu.git_repository import (
229+ Changelog,
230+ GitUbuntuRepository,
231+ git_dep14_tag,
232+)
233 from gitubuntu.run import run, runq
234 from gitubuntu.version import VERSION
235 from gitubuntu.importer import (
236@@ -17,7 +22,6 @@ from gitubuntu.importer import (
237 import_patches_unapplied_tree,
238 import_patches_applied_tree,
239 )
240-from gitubuntu.source_information import derive_source_from_series
241 from gitubuntu.versioning import version_compare
242 try:
243 pkg = 'python3-pygit2'
244@@ -156,10 +160,9 @@ def main(
245 )
246 break
247
248- distribution = repo.get_changelog_distribution_from_treeish(
249- unapplied_import_tree_hash
250+ dist = derive_source_from_changelog(
251+ Changelog.from_treeish(repo, unapplied_import_tree_hash),
252 )
253- dist = derive_source_from_series(distribution)
254 import_dsc(
255 repo=repo,
256 dsc=dsc,
257diff --git a/gitubuntu/source_information.py b/gitubuntu/source_information.py
258index 2c1c927..3fef4ec 100644
259--- a/gitubuntu/source_information.py
260+++ b/gitubuntu/source_information.py
261@@ -54,6 +54,8 @@ def launchpad_login_auth():
262
263
264 def derive_source_from_series(series):
265+ if series == 'devel':
266+ return 'ubuntu'
267 if _ddi.valid(codename=series):
268 return 'debian'
269 if _udi.valid(codename=series):
270diff --git a/tests/changelogs/test_distribution_source_1 b/tests/changelogs/test_distribution_source_1
271new file mode 100644
272index 0000000..b0e5e65
273--- /dev/null
274+++ b/tests/changelogs/test_distribution_source_1
275@@ -0,0 +1,5 @@
276+testpkg (1.0) xenial; urgency=medium
277+
278+ * Dummy entry.
279+
280+ -- Test Maintainer <test-maintainer@donotmail.com> Mon, 12 May 2016 08:14:34 -0700
281diff --git a/tests/changelogs/test_distribution_source_2 b/tests/changelogs/test_distribution_source_2
282new file mode 100644
283index 0000000..96faa4e
284--- /dev/null
285+++ b/tests/changelogs/test_distribution_source_2
286@@ -0,0 +1,5 @@
287+testpkg (1.0) zesty-security; urgency=medium
288+
289+ * Dummy entry.
290+
291+ -- Test Maintainer <test-maintainer@donotmail.com> Mon, 12 May 2016 08:14:34 -0700
292diff --git a/tests/changelogs/test_distribution_source_3 b/tests/changelogs/test_distribution_source_3
293new file mode 100644
294index 0000000..f3d7621
295--- /dev/null
296+++ b/tests/changelogs/test_distribution_source_3
297@@ -0,0 +1,5 @@
298+testpkg (1.0) unstable; urgency=medium
299+
300+ * Dummy entry.
301+
302+ -- Test Maintainer <test-maintainer@donotmail.com> Mon, 12 May 2016 08:14:34 -0700
303diff --git a/tests/changelogs/test_distribution_source_4 b/tests/changelogs/test_distribution_source_4
304new file mode 100644
305index 0000000..641a08e
306--- /dev/null
307+++ b/tests/changelogs/test_distribution_source_4
308@@ -0,0 +1,5 @@
309+testpkg (1.0) devel; urgency=medium
310+
311+ * Dummy entry.
312+
313+ -- Test Maintainer <test-maintainer@donotmail.com> Mon, 12 May 2016 08:14:34 -0700

Subscribers

People subscribed via source and target branches