Merge lp:~cjwatson/launchpad-buildd/currentlybuilding-permissions into lp:launchpad-buildd

Proposed by Colin Watson on 2019-06-18
Status: Merged
Merged at revision: 386
Proposed branch: lp:~cjwatson/launchpad-buildd/currentlybuilding-permissions
Merge into: lp:launchpad-buildd
Diff against target: 108 lines (+27/-9)
3 files modified
debian/changelog (+6/-0)
lpbuildd/binarypackage.py (+4/-3)
lpbuildd/tests/test_binarypackage.py (+17/-6)
To merge this branch: bzr merge lp:~cjwatson/launchpad-buildd/currentlybuilding-permissions
Reviewer Review Type Date Requested Status
Tom Wardill 2019-06-18 Approve on 2019-06-18
Review via email: mp+368984@code.launchpad.net

Commit message

Don't rely on /CurrentlyBuilding existing in base images.

Description of the change

The newish Backend.copy_in interface doesn't rely on the file already existing in the base image with suitable permissions, which doesn't seem like a sensible thing for us to require of base images.

To post a comment you must log in.
Tom Wardill (twom) :
review: Approve

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 2019-06-10 13:03:11 +0000
3+++ debian/changelog 2019-06-18 15:34:08 +0000
4@@ -1,3 +1,9 @@
5+launchpad-buildd (176) UNRELEASED; urgency=medium
6+
7+ * Don't rely on /CurrentlyBuilding existing in base images.
8+
9+ -- Colin Watson <cjwatson@ubuntu.com> Tue, 18 Jun 2019 16:26:28 +0100
10+
11 launchpad-buildd (175) xenial; urgency=medium
12
13 * Allow configuring APT or snap store proxies via a new [proxy]
14
15=== modified file 'lpbuildd/binarypackage.py'
16--- lpbuildd/binarypackage.py 2019-02-12 10:35:12 +0000
17+++ lpbuildd/binarypackage.py 2019-06-18 15:34:08 +0000
18@@ -146,8 +146,6 @@
19 ['sudo', 'install', '-o', 'root', '-g', 'root', '-m', '0644',
20 schroot_file.name, self.schroot_config_path])
21
22- currently_building_path = os.path.join(
23- self.chroot_path, 'CurrentlyBuilding')
24 currently_building_contents = (
25 'Package: %s\n'
26 'Component: %s\n'
27@@ -157,8 +155,11 @@
28 self.archive_purpose))
29 if self.build_debug_symbols:
30 currently_building_contents += 'Build-Debug-Symbols: yes\n'
31- with open(currently_building_path, 'w') as currently_building:
32+ with tempfile.NamedTemporaryFile(mode='w+') as currently_building:
33 currently_building.write(currently_building_contents)
34+ currently_building.flush()
35+ os.fchmod(currently_building.fileno(), 0o644)
36+ self.backend.copy_in(currently_building.name, '/CurrentlyBuilding')
37
38 args = ["sbuild-package", self._buildid, self.arch_tag]
39 args.append(self.suite)
40
41=== modified file 'lpbuildd/tests/test_binarypackage.py'
42--- lpbuildd/tests/test_binarypackage.py 2019-02-12 10:41:20 +0000
43+++ lpbuildd/tests/test_binarypackage.py 2019-06-18 15:34:08 +0000
44@@ -6,6 +6,7 @@
45 from functools import partial
46 import os
47 import shutil
48+import stat
49 import subprocess
50 import tempfile
51 from textwrap import dedent
52@@ -199,6 +200,10 @@
53 def test_with_debug_symbols(self):
54 # A build with debug symbols sets up /CurrentlyBuilding
55 # appropriately, and does not pass DEB_BUILD_OPTIONS.
56+ self.addCleanup(
57+ setattr, self.buildmanager, 'backend_name',
58+ self.buildmanager.backend_name)
59+ self.buildmanager.backend_name = 'fake'
60 self.buildmanager.initiate(
61 {'foo_1.dsc': ''}, 'chroot.tar.gz',
62 {'distribution': 'ubuntu', 'series': 'warty', 'suite': 'warty',
63@@ -216,19 +221,24 @@
64 'foo_1.dsc'],
65 env_matcher=Not(Contains('DEB_BUILD_OPTIONS')), final=True)
66 self.assertFalse(self.builder.wasCalled('chrootFail'))
67- with open(os.path.join(self.chrootdir, 'CurrentlyBuilding')) as cb:
68- self.assertEqual(dedent("""\
69+ self.assertEqual(
70+ (dedent("""\
71 Package: foo
72 Component: main
73 Suite: warty
74 Purpose: PRIMARY
75 Build-Debug-Symbols: yes
76- """), cb.read())
77+ """).encode('UTF-8'), stat.S_IFREG | 0o644),
78+ self.buildmanager.backend.backend_fs['/CurrentlyBuilding'])
79
80 @defer.inlineCallbacks
81 def test_without_debug_symbols(self):
82 # A build with debug symbols sets up /CurrentlyBuilding
83 # appropriately, and passes DEB_BUILD_OPTIONS=noautodbgsym.
84+ self.addCleanup(
85+ setattr, self.buildmanager, 'backend_name',
86+ self.buildmanager.backend_name)
87+ self.buildmanager.backend_name = 'fake'
88 self.buildmanager.initiate(
89 {'foo_1.dsc': ''}, 'chroot.tar.gz',
90 {'distribution': 'ubuntu', 'series': 'warty', 'suite': 'warty',
91@@ -248,13 +258,14 @@
92 {'DEB_BUILD_OPTIONS': Equals('noautodbgsym')}),
93 final=True)
94 self.assertFalse(self.builder.wasCalled('chrootFail'))
95- with open(os.path.join(self.chrootdir, 'CurrentlyBuilding')) as cb:
96- self.assertEqual(dedent("""\
97+ self.assertEqual(
98+ (dedent("""\
99 Package: foo
100 Component: main
101 Suite: warty
102 Purpose: PRIMARY
103- """), cb.read())
104+ """).encode('UTF-8'), stat.S_IFREG | 0o644),
105+ self.buildmanager.backend.backend_fs['/CurrentlyBuilding'])
106
107 @defer.inlineCallbacks
108 def test_abort_sbuild(self):

Subscribers

People subscribed via source and target branches

to all changes: