diff options
author | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-11-30 12:35:29 +0000 |
---|---|---|
committer | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-11-30 12:35:29 +0000 |
commit | 8cd95022df4a01a9ffa2f36a4118d0ace8ddbdc0 (patch) | |
tree | b95c413aaabedd0255e49d27010514b1d1afcca9 /morphlib/builder2.py | |
parent | c859d70d86423a52bc7053abf64e9ca21f62a487 (diff) | |
download | morph-8cd95022df4a01a9ffa2f36a4118d0ace8ddbdc0.tar.gz |
Revert "Merge branch 'liw/hardlink-staging-area-pre-rebase'"
This reverts commit c859d70d86423a52bc7053abf64e9ca21f62a487, reversing
changes made to 3085a672d1e8b5177be33f0463385de72a0ef5bf.
Unfortunately, hardlinking and linux-user-chroot both break builds
in various ways. Hardlinking breaks the bootstrap process by creating
symlinks like /usr/libexec that can then not be overwritten with real
files by install scripts from morphologies like gcc.
linux-user-chroot caused problems by breaking privileged operations such
as chgrp and CAP_SETFCAP. As a consequence, chunks like util-linux and
libcap can no longer be built.
Diffstat (limited to 'morphlib/builder2.py')
-rw-r--r-- | morphlib/builder2.py | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/morphlib/builder2.py b/morphlib/builder2.py index 28a5e0ba..c7d25e1a 100644 --- a/morphlib/builder2.py +++ b/morphlib/builder2.py @@ -259,31 +259,53 @@ class ChunkBuilder(BuilderBase): def build_and_cache(self): # pragma: no cover with self.build_watch('overall-build'): - - builddir, destdir = \ - self.staging_area.chroot_open(self.artifact.source) + mounted = self.do_mounts() log_name = None try: + builddir = self.staging_area.builddir(self.artifact.source) self.get_sources(builddir) + destdir = self.staging_area.destdir(self.artifact.source) with self.local_artifact_cache.put_source_metadata( self.artifact.source, self.artifact.cache_key, 'build-log') as log: log_name = log.real_filename self.run_commands(builddir, destdir, log) except: - self.staging_area.chroot_close() + self.do_unmounts(mounted) if log_name: with open(log_name) as f: for line in f: logging.error('OUTPUT FROM FAILED BUILD: %s' % line.rstrip('\n')) raise - self.staging_area.chroot_close() + self.do_unmounts(mounted) built_artifacts = self.assemble_chunk_artifacts(destdir) self.save_build_times() return built_artifacts + to_mount = ( + ('proc', 'proc', 'none'), + ('dev/shm', 'tmpfs', 'none'), + ) + + def do_mounts(self): # pragma: no cover + mounted = [] + if not self.setup_mounts: + return mounted + for mount_point, mount_type, source in ChunkBuilder.to_mount: + logging.debug('Mounting %s in staging area' % mount_point) + path = os.path.join(self.staging_area.dirname, mount_point) + if not os.path.exists(path): + os.makedirs(path) + self.app.runcmd(['mount', '-t', mount_type, source, path]) + mounted.append(path) + return mounted + + def do_unmounts(self, mounted): # pragma: no cover + for path in mounted: + logging.debug('Unmounting %s in staging area' % path) + morphlib.fsutils.unmount(self.app.runcmd, path) def get_sources(self, srcdir): # pragma: no cover '''Get sources from git to a source directory, for building.''' |