Merge lp:~cjwatson/launchpad-buildd/control-dbgsym-via-env into lp:launchpad-buildd

Proposed by Colin Watson
Status: Merged
Merged at revision: 208
Proposed branch: lp:~cjwatson/launchpad-buildd/control-dbgsym-via-env
Merge into: lp:launchpad-buildd
Diff against target: 223 lines (+82/-16)
4 files modified
debian/changelog (+2/-0)
lpbuildd/binarypackage.py (+5/-2)
lpbuildd/tests/test_binarypackage.py (+74/-13)
sbuild-package (+1/-1)
To merge this branch: bzr merge lp:~cjwatson/launchpad-buildd/control-dbgsym-via-env
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+312356@code.launchpad.net

Commit message

lpbuildd.binarypackage: Pass DEB_BUILD_OPTIONS=noautodbgsym if we have not been told to build debug symbols (LP: #1623256).

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 2016-11-30 10:20:32 +0000
3+++ debian/changelog 2016-12-02 14:30:11 +0000
4@@ -2,6 +2,8 @@
5
6 * buildsnap: Grant access to the proxy during the build phase as well as
7 during the pull phase (LP: #1642281).
8+ * lpbuildd.binarypackage: Pass DEB_BUILD_OPTIONS=noautodbgsym if we have
9+ not been told to build debug symbols (LP: #1623256).
10
11 -- Colin Watson <cjwatson@ubuntu.com> Fri, 04 Nov 2016 10:47:41 +0000
12
13
14=== modified file 'lpbuildd/binarypackage.py'
15--- lpbuildd/binarypackage.py 2016-02-18 14:44:09 +0000
16+++ lpbuildd/binarypackage.py 2016-12-02 14:30:11 +0000
17@@ -1,4 +1,4 @@
18-# Copyright 2009, 2010 Canonical Ltd. This software is licensed under the
19+# Copyright 2009-2016 Canonical Ltd. This software is licensed under the
20 # GNU Affero General Public License version 3 (see the file LICENSE).
21
22 from __future__ import absolute_import
23@@ -145,7 +145,10 @@
24 if self.arch_indep:
25 args.append("-A")
26 args.append(self._dscfile)
27- self.runSubProcess(self._sbuildpath, args)
28+ env = dict(os.environ)
29+ if not self.build_debug_symbols:
30+ env["DEB_BUILD_OPTIONS"] = "noautodbgsym"
31+ self.runSubProcess(self._sbuildpath, args, env=env)
32
33 def getAvailablePackages(self):
34 """Return the available binary packages in the chroot.
35
36=== modified file 'lpbuildd/tests/test_binarypackage.py'
37--- lpbuildd/tests/test_binarypackage.py 2015-08-04 20:57:12 +0000
38+++ lpbuildd/tests/test_binarypackage.py 2016-12-02 14:30:11 +0000
39@@ -1,4 +1,4 @@
40-# Copyright 2013 Canonical Ltd. This software is licensed under the
41+# Copyright 2013-2016 Canonical Ltd. This software is licensed under the
42 # GNU Affero General Public License version 3 (see the file LICENSE).
43
44 __metaclass__ = type
45@@ -11,10 +11,12 @@
46 from debian.deb822 import PkgRelation
47 from testtools import TestCase
48 from testtools.matchers import (
49+ Contains,
50 ContainsDict,
51 Equals,
52 Is,
53 MatchesListwise,
54+ Not,
55 )
56 from twisted.internet.task import Clock
57
58@@ -48,8 +50,8 @@
59 self.iterators = []
60 self.arch_indep = False
61
62- def runSubProcess(self, path, command, iterate=None):
63- self.commands.append([path]+command)
64+ def runSubProcess(self, path, command, iterate=None, env=None):
65+ self.commands.append(([path] + command, env))
66 if iterate is None:
67 iterate = self.iterate
68 self.iterators.append(iterate)
69@@ -111,12 +113,14 @@
70 self.buildid, 'i386', 'warty', '-c', 'chroot:autobuild',
71 '--arch=i386', '--dist=warty', '--purge=never', '--nolog',
72 'foo_1.dsc',
73- ], True)
74+ ], final=True)
75 self.assertFalse(self.slave.wasCalled('chrootFail'))
76
77- def assertState(self, state, command, final):
78+ def assertState(self, state, command, env_matcher=None, final=False):
79 self.assertEqual(state, self.getState())
80- self.assertEqual(command, self.buildmanager.commands[-1])
81+ self.assertEqual(command, self.buildmanager.commands[-1][0])
82+ if env_matcher is not None:
83+ self.assertThat(self.buildmanager.commands[-1][1], env_matcher)
84 if final:
85 self.assertEqual(
86 self.buildmanager.iterate, self.buildmanager.iterators[-1])
87@@ -130,14 +134,14 @@
88 self.assertState(
89 BinaryPackageBuildState.SBUILD,
90 ['sharepath/slavebin/scan-for-processes', 'scan-for-processes',
91- self.buildid], False)
92+ self.buildid], final=False)
93
94 def assertUnmountsSanely(self):
95 self.buildmanager.iterateReap(self.getState(), 0)
96 self.assertState(
97 BinaryPackageBuildState.UMOUNT,
98 ['sharepath/slavebin/umount-chroot', 'umount-chroot',
99- self.buildid], True)
100+ self.buildid], final=True)
101
102 def test_iterate(self):
103 # The build manager iterates a normal build from start to finish.
104@@ -161,6 +165,63 @@
105 self.assertUnmountsSanely()
106 self.assertFalse(self.slave.wasCalled('buildFail'))
107
108+ def test_with_debug_symbols(self):
109+ # A build with debug symbols sets up /CurrentlyBuilding
110+ # appropriately, and does not pass DEB_BUILD_OPTIONS.
111+ self.buildmanager.initiate(
112+ {'foo_1.dsc': ''}, 'chroot.tar.gz',
113+ {'distribution': 'ubuntu', 'suite': 'warty',
114+ 'ogrecomponent': 'main', 'archive_purpose': 'PRIMARY',
115+ 'build_debug_symbols': True})
116+ os.makedirs(self.chrootdir)
117+ self.buildmanager._state = BinaryPackageBuildState.UPDATE
118+ self.buildmanager.iterate(0)
119+ self.assertState(
120+ BinaryPackageBuildState.SBUILD,
121+ ['sharepath/slavebin/sbuild-package', 'sbuild-package',
122+ self.buildid, 'i386', 'warty', '-c', 'chroot:autobuild',
123+ '--arch=i386', '--dist=warty', '--purge=never', '--nolog',
124+ 'foo_1.dsc'],
125+ env_matcher=Not(Contains('DEB_BUILD_OPTIONS')), final=True)
126+ self.assertFalse(self.slave.wasCalled('chrootFail'))
127+ with open(os.path.join(self.chrootdir, 'CurrentlyBuilding')) as cb:
128+ self.assertEqual(dedent("""\
129+ Package: foo
130+ Component: main
131+ Suite: warty
132+ Purpose: PRIMARY
133+ Build-Debug-Symbols: yes
134+ """), cb.read())
135+
136+ def test_without_debug_symbols(self):
137+ # A build with debug symbols sets up /CurrentlyBuilding
138+ # appropriately, and passes DEB_BUILD_OPTIONS=noautodbgsym.
139+ self.buildmanager.initiate(
140+ {'foo_1.dsc': ''}, 'chroot.tar.gz',
141+ {'distribution': 'ubuntu', 'suite': 'warty',
142+ 'ogrecomponent': 'main', 'archive_purpose': 'PRIMARY',
143+ 'build_debug_symbols': False})
144+ os.makedirs(self.chrootdir)
145+ self.buildmanager._state = BinaryPackageBuildState.UPDATE
146+ self.buildmanager.iterate(0)
147+ self.assertState(
148+ BinaryPackageBuildState.SBUILD,
149+ ['sharepath/slavebin/sbuild-package', 'sbuild-package',
150+ self.buildid, 'i386', 'warty', '-c', 'chroot:autobuild',
151+ '--arch=i386', '--dist=warty', '--purge=never', '--nolog',
152+ 'foo_1.dsc'],
153+ env_matcher=ContainsDict(
154+ {'DEB_BUILD_OPTIONS': Equals('noautodbgsym')}),
155+ final=True)
156+ self.assertFalse(self.slave.wasCalled('chrootFail'))
157+ with open(os.path.join(self.chrootdir, 'CurrentlyBuilding')) as cb:
158+ self.assertEqual(dedent("""\
159+ Package: foo
160+ Component: main
161+ Suite: warty
162+ Purpose: PRIMARY
163+ """), cb.read())
164+
165 def test_abort_sbuild(self):
166 # Aborting sbuild kills processes in the chroot.
167 self.startBuild()
168@@ -170,7 +231,7 @@
169 self.assertState(
170 BinaryPackageBuildState.SBUILD,
171 ['sharepath/slavebin/scan-for-processes', 'scan-for-processes',
172- self.buildid], False)
173+ self.buildid], final=False)
174 self.assertFalse(self.slave.wasCalled('buildFail'))
175
176 # If reaping completes successfully, the build manager returns
177@@ -189,7 +250,7 @@
178 self.assertState(
179 BinaryPackageBuildState.SBUILD,
180 ['sharepath/slavebin/scan-for-processes', 'scan-for-processes',
181- self.buildid], False)
182+ self.buildid], final=False)
183 self.assertFalse(self.slave.wasCalled('builderFail'))
184 reap_subprocess = self.buildmanager._subprocess
185
186@@ -213,7 +274,7 @@
187 self.assertState(
188 BinaryPackageBuildState.UMOUNT,
189 ['sharepath/slavebin/umount-chroot', 'umount-chroot',
190- self.buildid], True)
191+ self.buildid], final=True)
192
193 def test_abort_between_subprocesses(self):
194 # If a build is aborted between subprocesses, the build manager
195@@ -227,13 +288,13 @@
196 self.assertState(
197 BinaryPackageBuildState.INIT,
198 ['sharepath/slavebin/scan-for-processes', 'scan-for-processes',
199- self.buildid], False)
200+ self.buildid], final=False)
201
202 self.buildmanager.iterate(0)
203 self.assertState(
204 BinaryPackageBuildState.CLEANUP,
205 ['sharepath/slavebin/remove-build', 'remove-build', self.buildid],
206- True)
207+ final=True)
208 self.assertFalse(self.slave.wasCalled('builderFail'))
209
210 def test_missing_changes(self):
211
212=== modified file 'sbuild-package'
213--- sbuild-package 2016-03-03 16:33:19 +0000
214+++ sbuild-package 2016-12-02 14:30:11 +0000
215@@ -67,7 +67,7 @@
216 echo "Initiating build $BUILDID with $NR_PROCESSORS jobs across $ACTUAL_NR_PROCESSORS processor cores."
217
218 if [ $NR_PROCESSORS -gt 1 ]; then
219- export DEB_BUILD_OPTIONS=parallel=$NR_PROCESSORS
220+ export DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS:+$DEB_BUILD_OPTIONS }parallel=$NR_PROCESSORS"
221 fi
222
223 cd "$HOME/build-$BUILDID"

Subscribers

People subscribed via source and target branches

to all changes: