Merge lp:~cjwatson/launchpad-buildd/chroot-top-level-dir into lp:launchpad-buildd

Proposed by Colin Watson
Status: Merged
Merged at revision: 337
Proposed branch: lp:~cjwatson/launchpad-buildd/chroot-top-level-dir
Merge into: lp:launchpad-buildd
Diff against target: 81 lines (+15/-6)
4 files modified
debian/changelog (+2/-0)
lpbuildd/target/chroot.py (+3/-1)
lpbuildd/target/lxd.py (+9/-5)
lpbuildd/target/tests/test_chroot.py (+1/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpad-buildd/chroot-top-level-dir
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+342833@code.launchpad.net

Commit message

Tolerate chroot tarballs with a top-level directory other than chroot-autobuild/.

Description of the change

This makes things a little more flexible in the face of different ways of generating chroot tarballs.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2018-04-04 16:25:31 +0000
3+++ debian/changelog 2018-04-07 23:23:06 +0000
4@@ -1,6 +1,8 @@
5 launchpad-buildd (161) UNRELEASED; urgency=medium
6
7 * Pass build URL to snapcraft using SNAPCRAFT_IMAGE_INFO.
8+ * Tolerate chroot tarballs with a top-level directory other than
9+ chroot-autobuild/.
10
11 -- Colin Watson <cjwatson@ubuntu.com> Wed, 04 Apr 2018 17:03:14 +0100
12
13
14=== modified file 'lpbuildd/target/chroot.py'
15--- lpbuildd/target/chroot.py 2017-11-10 20:55:33 +0000
16+++ lpbuildd/target/chroot.py 2018-04-07 23:23:06 +0000
17@@ -31,7 +31,9 @@
18 def create(self, tarball_path):
19 """See `Backend`."""
20 subprocess.check_call(
21- ["sudo", "tar", "-C", self.build_path, "-xf", tarball_path])
22+ ["sudo", "tar", "-C", self.build_path,
23+ "--transform", "s,[^/]*,chroot-autobuild,",
24+ "-xf", tarball_path])
25
26 def start(self):
27 """See `Backend`."""
28
29=== modified file 'lpbuildd/target/lxd.py'
30--- lpbuildd/target/lxd.py 2018-02-04 00:15:39 +0000
31+++ lpbuildd/target/lxd.py 2018-04-07 23:23:06 +0000
32@@ -124,7 +124,8 @@
33 return False
34
35 def _convert(self, source_tarball, target_tarball):
36- creation_time = source_tarball.getmember("chroot-autobuild").mtime
37+ first_entry = next(iter(source_tarball))
38+ creation_time = first_entry.mtime
39 metadata = {
40 "architecture": self.lxc_arch,
41 "creation_date": creation_time,
42@@ -147,11 +148,15 @@
43
44 # Mangle the chroot tarball into the form needed by LXD: when using
45 # the combined metadata/rootfs form, the rootfs must be under
46- # rootfs/ rather than under chroot-autobuild/.
47+ # rootfs/ rather than under chroot-autobuild/ or anything else.
48 for entry in source_tarball:
49 fileptr = None
50 try:
51- orig_name = entry.name.split("chroot-autobuild", 1)[-1]
52+ orig_name_bits = entry.name.split("/", 1)
53+ if len(orig_name_bits) > 1:
54+ orig_name = "/" + orig_name_bits[1]
55+ else:
56+ orig_name = ""
57 entry.name = "rootfs" + orig_name
58
59 if entry.isfile():
60@@ -162,8 +167,7 @@
61 elif entry.islnk():
62 # Update hardlinks to point to the right target
63 entry.linkname = (
64- "rootfs" +
65- entry.linkname.split("chroot-autobuild", 1)[-1])
66+ "rootfs/" + entry.linkname.split("/", 1)[-1])
67
68 target_tarball.addfile(entry, fileobj=fileptr)
69 finally:
70
71=== modified file 'lpbuildd/target/tests/test_chroot.py'
72--- lpbuildd/target/tests/test_chroot.py 2017-11-01 23:04:53 +0000
73+++ lpbuildd/target/tests/test_chroot.py 2018-04-07 23:23:06 +0000
74@@ -39,6 +39,7 @@
75
76 expected_args = [
77 ["sudo", "tar", "-C", "/expected/home/build-1",
78+ "--transform", "s,[^/]*,chroot-autobuild,",
79 "-xf", "/path/to/tarball"],
80 ]
81 self.assertEqual(

Subscribers

People subscribed via source and target branches

to all changes: