Merge lp:~mvo/launchpad-buildd/mvo into lp:launchpad-buildd

Proposed by Michael Vogt
Status: Work in progress
Proposed branch: lp:~mvo/launchpad-buildd/mvo
Merge into: lp:launchpad-buildd
Diff against target: 106 lines (+40/-8)
1 file modified
buildlivefs (+40/-8)
To merge this branch: bzr merge lp:~mvo/launchpad-buildd/mvo
Reviewer Review Type Date Requested Status
Colin Watson (community) Needs Fixing
Review via email: mp+228046@code.launchpad.net

Description of the change

This branch takes the excellent buildlivefs and adds some tweaks to make it more useful outside the buildd environment.

If that branch lands, we can consider moving it outside of the launchpad-buildd branch and into somehthing more general like livecd-rootfs or ubuntu-dev-tools so that people who want to experiment with building a rootfs. It would also provide a canonical way of building the rootfs and could superseed tools like rootstock and BuildLiveCD.

A careful review for this is needed as I'm new to the world of livefs building/buildds and may miss important setup steps that are taken before buildlivefs is called (i.e. I'm not sure if the deboostrap step I added is sufficient).

Thanks for your consideration,
 Michael

To post a comment you must log in.
lp:~mvo/launchpad-buildd/mvo updated
131. By Michael Vogt

add a default to build-id assuming that local use is mostly sequentical

Revision history for this message
Colin Watson (cjwatson) :
review: Needs Fixing
lp:~mvo/launchpad-buildd/mvo updated
132. By Michael Vogt

fix review issues raised by Colin

Revision history for this message
Michael Vogt (mvo) wrote :

Thanks a lot for your review Colin. I addressed your points in r132. From reading your reply it seems like you disapprove of the idea to make this something that could live outside of launchpad-buildd. In which case the revert of the chroot creation and the build-id default make sense of course.

Revision history for this message
Colin Watson (cjwatson) wrote :

I think it would be odd to move buildlivefs outside of launchpad-buildd and not the corresponding helpers for other build types, and buildlivefs's interface is quite closely tied to launchpad-buildd so it would be nice not to end up overcomplicating our deployments, especially as buildds have historically been stuck on old Ubuntu releases (maybe this will change with scalingstack, but let's see). I don't mind making buildlivefs friendlier for occasional non-launchpad-buildd use; I'd just prefer this not to involve things that might be less resilient to bugs elsewhere in production.

Unmerged revisions

132. By Michael Vogt

fix review issues raised by Colin

131. By Michael Vogt

add a default to build-id assuming that local use is mostly sequentical

130. By Michael Vogt

refactor debootrap into _prepare_chroot() and add friendly message at the end of the build

129. By Michael Vogt

make buildlivefs more general purpose

128. By Michael Vogt

buildlivefs: if the chroot_path does not exits, bootstrap it

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'buildlivefs'
2--- buildlivefs 2014-06-24 14:59:08 +0000
3+++ buildlivefs 2014-07-24 11:39:17 +0000
4@@ -19,14 +19,14 @@
5 RETCODE_FAILURE_BUILD = 201
6
7
8-def get_build_path(build_id, *extra):
9+def get_build_path(build_home, build_id, *extra):
10 """Generate a path within the build directory.
11
12 :param build_id: the build id to use.
13 :param extra: the extra path segments within the build directory.
14 :return: the generated path.
15 """
16- return os.path.join(os.environ["HOME"], "build-" + build_id, *extra)
17+ return os.path.join(build_home, "build-" + build_id, *extra)
18
19
20 non_meta_re = re.compile(r'^[a-zA-Z0-9+,./:=@_-]+$')
21@@ -64,13 +64,36 @@
22 ]
23
24
25+class MissingOptionError(Exception):
26+ """A required option for the LiveFSBuilder is missing"""
27+ pass
28+
29+
30+class MissingChrootError(Exception):
31+ """A chroot is missing"""
32+ pass
33+
34+
35 class LiveFSBuilder:
36 """Builds a live file system."""
37
38 def __init__(self, options):
39+ self._check_options(options)
40 self.options = options
41 self.chroot_path = get_build_path(
42- self.options.build_id, 'chroot-autobuild')
43+ options.build_home, options.build_id, 'chroot-autobuild')
44+ # be gentle to people who run it outside the buildd environment
45+ if not os.path.exists(self.chroot_path):
46+ raise MissingChrootError(
47+ "Missing chroot at '%s'. Please check chroot_url from "
48+ "https://api.launchpad.net/devel/ubuntu/%s/%s" % (
49+ self.chroot_path, options.series, options.arch))
50+
51+ def _check_options(self, options):
52+ for required_option in ("arch", "project", "series"):
53+ if getattr(options, required_option) is None:
54+ raise MissingOptionError(
55+ "Option '--%s' is required" % required_option)
56
57 def chroot(self, args, echo=False):
58 """Run a command in the chroot.
59@@ -161,19 +184,23 @@
60
61 def main():
62 parser = OptionParser()
63- parser.add_option("--build-id", help="build identifier")
64- parser.add_option(
65- "--arch", metavar="ARCH", help="build for architecture ARCH")
66+ parser.add_option(
67+ "--build-id", help="build identifier (use buildlivefs if in doubt)")
68+ parser.add_option(
69+ "--arch", metavar="ARCH",
70+ help="build for architecture ARCH (e.g. amd64)")
71 parser.add_option(
72 "--subarch", metavar="SUBARCH",
73 help="build for subarchitecture SUBARCH")
74 parser.add_option(
75- "--project", metavar="PROJECT", help="build for project PROJECT")
76+ "--project", metavar="PROJECT",
77+ help="build for project PROJECT (e.g. ubuntu-desktop)")
78 parser.add_option(
79 "--subproject", metavar="SUBPROJECT",
80 help="build for subproject SUBPROJECT")
81 parser.add_option(
82- "--series", metavar="SERIES", help="build for series SERIES")
83+ "--series", metavar="SERIES",
84+ help="build for series SERIES (e.g. trusty)")
85 parser.add_option("--datestamp", help="date stamp")
86 parser.add_option(
87 "--image-format", metavar="FORMAT", help="produce an image in FORMAT")
88@@ -186,6 +213,9 @@
89 parser.add_option(
90 "--extra-ppa", dest="extra_ppas", default=[], action="append",
91 help="use this additional PPA")
92+ parser.add_option(
93+ "--build-home", metavar="DIRECTORY", default=os.environ["HOME"],
94+ help="Root directory for the build results (default to $HOME)")
95 options, _ = parser.parse_args()
96
97 builder = LiveFSBuilder(options)
98@@ -196,6 +226,8 @@
99 return RETCODE_FAILURE_INSTALL
100 try:
101 builder.build()
102+ print("Success. Build result is available at '%s'" %
103+ os.path.join(builder.chroot_path, "build"))
104 except Exception:
105 traceback.print_exc()
106 return RETCODE_FAILURE_BUILD

Subscribers

People subscribed via source and target branches