~cjwatson/launchpad-buildd/snap-default-branch

« back to all changes in this revision

Viewing changes to buildlivefs

  • Committer: Colin Watson
  • Date: 2015-07-31 11:54:07 UTC
  • mto: This revision was merged to the branch mainline in revision 166.
  • Revision ID: cjwatson@canonical.com-20150731115407-n1261bb2bjzq9rvy
Add support for building snaps (LP: #1476405).

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 
9
9
from optparse import OptionParser
10
10
import os
11
 
import re
12
11
import subprocess
13
12
import sys
14
13
import traceback
15
14
 
 
15
from lpbuildd.util import (
 
16
    set_personality,
 
17
    shell_escape,
 
18
    )
 
19
 
16
20
 
17
21
RETCODE_SUCCESS = 0
18
22
RETCODE_FAILURE_INSTALL = 200
29
33
    return os.path.join(os.environ["HOME"], "build-" + build_id, *extra)
30
34
 
31
35
 
32
 
non_meta_re = re.compile(r'^[a-zA-Z0-9+,./:=@_-]+$')
33
 
 
34
 
def shell_escape(arg):
35
 
    if non_meta_re.match(arg):
36
 
        return arg
37
 
    else:
38
 
        return "'%s'" % arg.replace("'", "'\\''")
39
 
 
40
 
 
41
 
linux32_arches = [
42
 
    "armel",
43
 
    "armhf",
44
 
    "hppa",
45
 
    "i386",
46
 
    "lpia",
47
 
    "mips",
48
 
    "mipsel",
49
 
    "powerpc",
50
 
    "s390",
51
 
    "sparc",
52
 
    ]
53
 
linux64_arches = [
54
 
    "alpha",
55
 
    "amd64",
56
 
    "arm64",
57
 
    "hppa64",
58
 
    "ia64",
59
 
    "ppc64",
60
 
    "ppc64el",
61
 
    "s390x",
62
 
    "sparc64",
63
 
    "x32",
64
 
    ]
65
 
 
66
 
 
67
36
class LiveFSBuilder:
68
37
    """Builds a live file system."""
69
38
 
77
46
 
78
47
        :param args: the command and arguments to run.
79
48
        """
80
 
        if self.options.arch in linux32_arches:
81
 
            args = ["linux32"] + args
82
 
        elif self.options.arch in linux64_arches:
83
 
            args = ["linux64"] + args
 
49
        args = set_personality(self.options.arch, args)
84
50
        if echo:
85
51
            print "Running in chroot: %s" % ' '.join(
86
52
                "'%s'" % arg for arg in args)