Merge lp:~cjwatson/launchpad-buildd/reduce-arch-hardcoding into lp:launchpad-buildd

Proposed by Colin Watson
Status: Merged
Merged at revision: 242
Proposed branch: lp:~cjwatson/launchpad-buildd/reduce-arch-hardcoding
Merge into: lp:launchpad-buildd
Prerequisite: lp:~cjwatson/launchpad-buildd/remove-qemu
Diff against target: 230 lines (+102/-52)
6 files modified
Makefile (+3/-14)
bin/buildlivefs (+3/-2)
bin/buildsnap (+2/-2)
debian/changelog (+2/-0)
lpbuildd/tests/test_util.py (+59/-0)
lpbuildd/util.py (+33/-34)
To merge this branch: bzr merge lp:~cjwatson/launchpad-buildd/reduce-arch-hardcoding
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+328213@code.launchpad.net

Commit message

Remove most architecture hardcoding from lpbuildd.util, relying on
dpkg-architecture instead.

To post a comment you must log in.
236. By Colin Watson

Merge trunk.

237. By Colin Watson

Use test discovery rather than hardcoding a list of test modules.

238. By Colin Watson

Remove most architecture hardcoding from lpbuildd.util, relying on
dpkg-architecture instead.

239. By Colin Watson

Merge trunk.

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
=== modified file 'Makefile'
--- Makefile 2017-07-28 10:39:50 +0000
+++ Makefile 2017-07-28 14:08:19 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2017 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4all: deb4all: deb
@@ -22,16 +22,5 @@
2222
23PYTHON=python23PYTHON=python
24check:24check:
25 PYTHONPATH=$(CURDIR):$(PYTHONPATH) $(PYTHON) -m testtools.run -v \25 PYTHONPATH=$(CURDIR):$(PYTHONPATH) $(PYTHON) -m testtools.run \
26 lpbuildd.pottery.tests.test_generate_translation_templates \26 discover -v
27 lpbuildd.pottery.tests.test_intltool \
28 lpbuildd.tests.test_binarypackage \
29 lpbuildd.tests.test_buildd_slave \
30 lpbuildd.tests.test_buildrecipe \
31 lpbuildd.tests.test_check_implicit_pointer_functions \
32 lpbuildd.tests.test_debian \
33 lpbuildd.tests.test_harness \
34 lpbuildd.tests.test_livefs \
35 lpbuildd.tests.test_snap \
36 lpbuildd.tests.test_sourcepackagerecipe \
37 lpbuildd.tests.test_translationtemplatesbuildmanager
3827
=== modified file 'bin/buildlivefs'
--- bin/buildlivefs 2017-07-25 22:11:19 +0000
+++ bin/buildlivefs 2017-07-28 14:08:19 +0000
@@ -1,5 +1,5 @@
1#! /usr/bin/python -u1#! /usr/bin/python -u
2# Copyright 2013 Canonical Ltd. This software is licensed under the2# Copyright 2013-2017 Canonical Ltd. This software is licensed under the
3# GNU Affero General Public License version 3 (see the file LICENSE).3# GNU Affero General Public License version 3 (see the file LICENSE).
44
5"""A script that builds a live file system."""5"""A script that builds a live file system."""
@@ -48,7 +48,8 @@
4848
49 :param args: the command and arguments to run.49 :param args: the command and arguments to run.
50 """50 """
51 args = set_personality(self.options.arch, args)51 args = set_personality(
52 args, self.options.arch, series=self.options.series)
52 if echo:53 if echo:
53 print("Running in chroot: %s" %54 print("Running in chroot: %s" %
54 ' '.join("'%s'" % arg for arg in args))55 ' '.join("'%s'" % arg for arg in args))
5556
=== modified file 'bin/buildsnap'
--- bin/buildsnap 2017-07-25 22:11:19 +0000
+++ bin/buildsnap 2017-07-28 14:08:19 +0000
@@ -1,5 +1,5 @@
1#! /usr/bin/python -u1#! /usr/bin/python -u
2# Copyright 2015 Canonical Ltd. This software is licensed under the2# Copyright 2015-2017 Canonical Ltd. This software is licensed under the
3# GNU Affero General Public License version 3 (see the file LICENSE).3# GNU Affero General Public License version 3 (see the file LICENSE).
44
5"""A script that builds a snap."""5"""A script that builds a snap."""
@@ -58,7 +58,7 @@
58 :param echo: if True, print the command before executing it.58 :param echo: if True, print the command before executing it.
59 :param get_output: if True, return the output from the command.59 :param get_output: if True, return the output from the command.
60 """60 """
61 args = set_personality(self.options.arch, args)61 args = set_personality(args, self.options.arch)
62 if echo:62 if echo:
63 print(63 print(
64 "Running in chroot: %s" % ' '.join(64 "Running in chroot: %s" % ' '.join(
6565
=== modified file 'debian/changelog'
--- debian/changelog 2017-07-28 11:10:52 +0000
+++ debian/changelog 2017-07-28 14:08:19 +0000
@@ -6,6 +6,8 @@
6 ppa:launchpad/ubuntu/ppa (and >= zesty).6 ppa:launchpad/ubuntu/ppa (and >= zesty).
7 * Drop qemu emulation support. It was quite unreliable, and we've had7 * Drop qemu emulation support. It was quite unreliable, and we've had
8 real hardware for a while.8 real hardware for a while.
9 * Remove most architecture hardcoding from lpbuildd.util, relying on
10 dpkg-architecture instead.
911
10 -- Colin Watson <cjwatson@ubuntu.com> Tue, 25 Jul 2017 23:07:58 +010012 -- Colin Watson <cjwatson@ubuntu.com> Tue, 25 Jul 2017 23:07:58 +0100
1113
1214
=== added file 'lpbuildd/tests/test_util.py'
--- lpbuildd/tests/test_util.py 1970-01-01 00:00:00 +0000
+++ lpbuildd/tests/test_util.py 2017-07-28 14:08:19 +0000
@@ -0,0 +1,59 @@
1# Copyright 2017 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4__metaclass__ = type
5
6from testtools import TestCase
7
8from lpbuildd.util import (
9 get_arch_bits,
10 set_personality,
11 shell_escape,
12 )
13
14
15class TestShellEscape(TestCase):
16
17 def test_plain(self):
18 self.assertEqual("foo", shell_escape("foo"))
19
20 def test_whitespace(self):
21 self.assertEqual("' '", shell_escape(" "))
22
23 def test_single_quotes(self):
24 self.assertEqual("'shell'\\''s great'", shell_escape("shell's great"))
25
26
27class TestGetArchBits(TestCase):
28
29 def test_x32(self):
30 self.assertEqual(64, get_arch_bits("x32"))
31
32 def test_32bit(self):
33 self.assertEqual(32, get_arch_bits("armhf"))
34 self.assertEqual(32, get_arch_bits("i386"))
35
36 def test_64bit(self):
37 self.assertEqual(64, get_arch_bits("amd64"))
38 self.assertEqual(64, get_arch_bits("arm64"))
39
40
41class TestSetPersonality(TestCase):
42
43 def test_32bit(self):
44 self.assertEqual(
45 ["linux32", "sbuild"], set_personality(["sbuild"], "i386"))
46
47 def test_64bit(self):
48 self.assertEqual(
49 ["linux64", "sbuild"], set_personality(["sbuild"], "amd64"))
50
51 def test_uname_26(self):
52 self.assertEqual(
53 ["linux64", "--uname-2.6", "sbuild"],
54 set_personality(["sbuild"], "amd64", series="precise"))
55
56 def test_no_uname_26(self):
57 self.assertEqual(
58 ["linux64", "sbuild"],
59 set_personality(["sbuild"], "amd64", series="trusty"))
060
=== modified file 'lpbuildd/util.py'
--- lpbuildd/util.py 2015-07-31 11:54:07 +0000
+++ lpbuildd/util.py 2017-07-28 14:08:19 +0000
@@ -1,9 +1,10 @@
1# Copyright 2015 Canonical Ltd. This software is licensed under the1# Copyright 2015-2017 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4__metaclass__ = type4__metaclass__ = type
55
6import re6import re
7import subprocess
78
89
9non_meta_re = re.compile(r'^[a-zA-Z0-9+,./:=@_-]+$')10non_meta_re = re.compile(r'^[a-zA-Z0-9+,./:=@_-]+$')
@@ -15,36 +16,34 @@
15 return "'%s'" % arg.replace("'", "'\\''")16 return "'%s'" % arg.replace("'", "'\\''")
1617
1718
18linux32_arches = [19def get_arch_bits(arch):
19 "armel",20 if arch == "x32":
20 "armhf",21 # x32 is an exception: the userspace is 32-bit, but it expects to be
21 "hppa",22 # running on a 64-bit kernel.
22 "i386",23 return 64
23 "lpia",24 else:
24 "mips",25 bits = subprocess.check_output(
25 "mipsel",26 ["dpkg-architecture", "-a%s" % arch,
26 "powerpc",27 "-qDEB_HOST_ARCH_BITS"]).rstrip("\n")
27 "s390",28 if bits == "32":
28 "sparc",29 return 32
29 ]30 elif bits == "64":
30linux64_arches = [31 return 64
31 "alpha",32 else:
32 "amd64",33 raise RuntimeError(
33 "arm64",34 "Don't know how to deal with architecture %s "
34 "hppa64",35 "(DEB_HOST_ARCH_BITS=%s)" % (arch, bits))
35 "ia64",36
36 "ppc64",37
37 "ppc64el",38def set_personality(args, arch, series=None):
38 "s390x",39 bits = get_arch_bits(arch)
39 "sparc64",40 assert bits in (32, 64)
40 "x32",41 if bits == 32:
41 ]42 setarch_cmd = ["linux32"]
4243 else:
4344 setarch_cmd = ["linux64"]
44def set_personality(arch, args):45
45 if arch in linux32_arches:46 if series in ("hardy", "lucid", "maverick", "natty", "oneiric", "precise"):
46 return ["linux32"] + args47 setarch_cmd.append("--uname-2.6")
47 elif arch in linux64_arches:48
48 return ["linux64"] + args49 return setarch_cmd + args
49 else:
50 return args

Subscribers

People subscribed via source and target branches

to all changes: