From ce10825407081d52d79c0021a5aa83cf27a0000c Mon Sep 17 00:00:00 2001 From: Jonathan Maw Date: Tue, 17 Sep 2013 16:34:54 +0100 Subject: Make cross-bootstrap successfully build everything This does three things: 1. It makes sure that the native-bootstrap script terminates if any steps fail. 2. It installs files to a temporary directory, then copies them out, so that builds don't break in cases where we delete files from DESTDIR. 3. It makes appropriate minor fixes so that a cross-bootstrap build can happen from beginning to end. Note: native-bootstrap does not succeed in every case. It has been observed to fail in an x86_64 virtual machine. --- morphlib/plugins/cross-bootstrap_plugin.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'morphlib/plugins/cross-bootstrap_plugin.py') diff --git a/morphlib/plugins/cross-bootstrap_plugin.py b/morphlib/plugins/cross-bootstrap_plugin.py index 8593b076..72c7924f 100644 --- a/morphlib/plugins/cross-bootstrap_plugin.py +++ b/morphlib/plugins/cross-bootstrap_plugin.py @@ -28,7 +28,7 @@ echo "Generated by Morph version %s\n" set -eu -export PATH=/tools/bin:$PATH +export PATH=$PATH:/tools/bin:/tools/sbin export SRCDIR=/src ''' % morphlib.__version__ @@ -36,14 +36,13 @@ export SRCDIR=/src driver_footer = ''' echo "Complete!" -echo "Bootstrapped system rootfs is in $DESTDIR." ''' def escape_source_name(source): repo_name = source.repo.original_name ref = source.original_ref source_name = '%s__%s' % (repo_name, ref) - return re.sub(':/', '_', source_name) + return re.sub('[:/]', '_', source_name) # Most of this is ripped from RootfsTarballBuilder, and should be reconciled # with it. @@ -128,7 +127,8 @@ class BootstrapSystemBuilder(morphlib.builder2.BuilderBase): f.write('echo Setting up build environment...\n') for k,v in self.staging_area.env.iteritems(): - f.write('export %s="%s"\n' % (k, v)) + if k != 'PATH': + f.write('export %s="%s"\n' % (k, v)) # FIXME: really, of course, we need to iterate the sources not the # artifacts ... this will break when we have chunk splitting! @@ -140,7 +140,12 @@ class BootstrapSystemBuilder(morphlib.builder2.BuilderBase): name = a.source.morphology['name'] f.write('\necho Building %s\n' % name) - f.write('$SRCDIR/build-%s\n' % name) + f.write('mkdir /%s.inst\n' % name) + f.write('env DESTDIR=/%s.inst $SRCDIR/build-%s\n' + % (name, name)) + f.write('echo Installing %s\n' % name) + f.write('(cd /%s.inst; find . | cpio -umdp /)\n' % name) + f.write('if [ -e /sbin/ldconfig ]; then /sbin/ldconfig; fi\n') f.write(driver_footer) os.chmod(driver_script, 0777) @@ -149,6 +154,7 @@ class BootstrapSystemBuilder(morphlib.builder2.BuilderBase): m = chunk.source.morphology f.write('#!/bin/sh\n') f.write('# Build script generated by morph\n') + f.write('set -e\n') f.write('chunk_name=%s\n' % m['name']) repo = escape_source_name(chunk.source) @@ -178,12 +184,13 @@ class BootstrapSystemBuilder(morphlib.builder2.BuilderBase): key = '%s-commands' % step cmds = m.get_commands(key) for cmd in cmds: + f.write('(') if in_parallel: max_jobs = m['max-jobs'] if max_jobs is None: max_jobs = self.max_jobs - f.write('MAKEFLAGS=-j%s ' % max_jobs) - f.write(cmd + '\n') + f.write('export MAKEFLAGS=-j%s; ' % max_jobs) + f.write('set -e; %s) || exit 1\n' % cmd) f.write('rm -Rf $DESTDIR/$chunk_name.build') -- cgit v1.2.1