~cjwatson/launchpad-buildd/local-snap-proxy

« back to all changes in this revision

Viewing changes to lpbuildd/livefs.py

  • Committer: Colin Watson
  • Date: 2018-02-27 14:06:36 UTC
  • mfrom: (215.2.111 launchpad-buildd)
  • Revision ID: cjwatson@canonical.com-20180227140636-f80jb5t2o3hyywpg
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2013 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2013-2017 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
__metaclass__ = type
5
5
 
6
6
import os
7
 
import shutil
8
7
 
9
8
from lpbuildd.debian import (
10
9
    DebianBuildManager,
11
10
    DebianBuildState,
12
 
    get_build_path,
13
11
    )
14
12
 
15
13
 
25
23
class LiveFilesystemBuildManager(DebianBuildManager):
26
24
    """Build a live filesystem."""
27
25
 
 
26
    backend_name = "lxd"
28
27
    initial_build_state = LiveFilesystemBuildState.BUILD_LIVEFS
29
28
 
30
 
    def __init__(self, slave, buildid, **kwargs):
31
 
        DebianBuildManager.__init__(self, slave, buildid, **kwargs)
32
 
        self.build_livefs_path = os.path.join(self._slavebin, "buildlivefs")
33
 
 
34
29
    def initiate(self, files, chroot, extra_args):
35
30
        """Initiate a build with a given set of files and chroot."""
36
 
        self.build_path = get_build_path(
37
 
            self.home, self._buildid, "chroot-autobuild", "build")
38
 
        if os.path.isdir(self.build_path):
39
 
            shutil.rmtree(self.build_path)
40
 
 
41
31
        self.subarch = extra_args.get("subarch")
42
32
        self.project = extra_args["project"]
43
33
        self.subproject = extra_args.get("subproject")
44
 
        self.series = extra_args["series"]
45
34
        self.pocket = extra_args["pocket"]
46
35
        self.datestamp = extra_args.get("datestamp")
47
36
        self.image_format = extra_args.get("image_format")
48
37
        self.locale = extra_args.get("locale")
49
38
        self.extra_ppas = extra_args.get("extra_ppas", [])
 
39
        self.channel = extra_args.get("channel")
 
40
        self.debug = extra_args.get("debug", False)
50
41
 
51
42
        super(LiveFilesystemBuildManager, self).initiate(
52
43
            files, chroot, extra_args)
53
44
 
54
45
    def doRunBuild(self):
55
46
        """Run the process to build the live filesystem."""
56
 
        args = [
57
 
            "buildlivefs",
58
 
            "--build-id", self._buildid,
59
 
            "--arch", self.arch_tag,
60
 
            ]
 
47
        args = []
61
48
        if self.subarch:
62
49
            args.extend(["--subarch", self.subarch])
63
50
        args.extend(["--project", self.project])
64
51
        if self.subproject:
65
52
            args.extend(["--subproject", self.subproject])
66
 
        args.extend(["--series", self.series])
67
53
        if self.datestamp:
68
54
            args.extend(["--datestamp", self.datestamp])
69
55
        if self.image_format:
74
60
            args.extend(["--locale", self.locale])
75
61
        for ppa in self.extra_ppas:
76
62
            args.extend(["--extra-ppa", ppa])
77
 
        self.runSubProcess(self.build_livefs_path, args)
 
63
        if self.channel:
 
64
            args.extend(["--channel", self.channel])
 
65
        if self.debug:
 
66
            args.append("--debug")
 
67
        self.runTargetSubProcess("buildlivefs", *args)
78
68
 
79
69
    def iterate_BUILD_LIVEFS(self, retcode):
80
70
        """Finished building the live filesystem."""
101
91
 
102
92
    def gatherResults(self):
103
93
        """Gather the results of the build and add them to the file cache."""
104
 
        for entry in sorted(os.listdir(self.build_path)):
105
 
            path = os.path.join(self.build_path, entry)
106
 
            if entry.startswith("livecd.") and not os.path.islink(path):
107
 
                self._slave.addWaitingFile(path)
 
94
        for entry in sorted(self.backend.listdir("/build")):
 
95
            path = os.path.join("/build", entry)
 
96
            if (entry.startswith("livecd.") and
 
97
                    not self.backend.islink(path)):
 
98
                self.addWaitingFileFromBackend(path)