diff options
author | Richard Maw <richard.maw@gmail.com> | 2014-10-15 18:01:55 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2014-10-24 14:31:15 +0000 |
commit | 595c92f65deb02e56414d80a7cfe8cfde508ca4d (patch) | |
tree | f9fbff53181c6347f0646106cd8574904c6911be | |
parent | 11669de95de7e8a9ad8b41fa5e9be3fbb845c52e (diff) | |
download | morph-595c92f65deb02e56414d80a7cfe8cfde508ca4d.tar.gz |
stagingarea: Mount proc and ccache inside the namespace
This works towards allowing multiple concurrent builds in the same
system, which has the same problem as deployments.
This is the easy bit, since linux-user-chroot has support for bind
mounts and /proc mounts.
We also need to get rid of the /dev/shm mount to be able to build in
parallel though.
-rw-r--r-- | morphlib/builder2.py | 4 | ||||
-rw-r--r-- | morphlib/stagingarea.py | 24 |
2 files changed, 18 insertions, 10 deletions
diff --git a/morphlib/builder2.py b/morphlib/builder2.py index 596cd645..8615ed59 100644 --- a/morphlib/builder2.py +++ b/morphlib/builder2.py @@ -342,6 +342,7 @@ class ChunkBuilder(BuilderBase): relative_builddir = self.staging_area.relative(builddir) relative_destdir = self.staging_area.relative(destdir) + ccache_dir = self.staging_area.ccache_dir(self.source) extra_env = { 'DESTDIR': relative_destdir } steps = [ @@ -391,7 +392,8 @@ class ChunkBuilder(BuilderBase): cwd=relative_builddir, stdout=stdout or subprocess.PIPE, stderr=subprocess.STDOUT, - logfile=logfilepath) + logfile=logfilepath, + ccache_dir=ccache_dir) if stdout: stdout.flush() diff --git a/morphlib/stagingarea.py b/morphlib/stagingarea.py index bfe0a716..25e33b3f 100644 --- a/morphlib/stagingarea.py +++ b/morphlib/stagingarea.py @@ -192,11 +192,10 @@ class StagingArea(object): shutil.rmtree(self.dirname) to_mount = ( - ('proc', 'proc', 'none'), ('dev/shm', 'tmpfs', 'none'), ) - def mount_ccachedir(self, source): #pragma: no cover + def ccache_dir(self, source): #pragma: no cover ccache_dir = self._app.settings['compiler-cache-dir'] if not os.path.isdir(ccache_dir): os.makedirs(ccache_dir) @@ -223,10 +222,7 @@ class StagingArea(object): # to avoid breaking when faced with an empty staging area. if not os.path.isdir(ccache_destdir): os.makedirs(ccache_destdir) - # Mount it into the staging-area - self._app.runcmd(['mount', '--bind', ccache_repodir, - ccache_destdir]) - return ccache_destdir + return ccache_repodir def do_mounts(self, setup_mounts): # pragma: no cover if not setup_mounts: @@ -257,9 +253,6 @@ class StagingArea(object): self.do_mounts(setup_mounts) - if not self._app.settings['no-ccache']: - self.mounted.append(self.mount_ccachedir(source)) - return builddir, destdir def chroot_close(self): # pragma: no cover @@ -284,6 +277,7 @@ class StagingArea(object): del kwargs['cwd'] else: cwd = '/' + ccache_dir = kwargs.pop('ccache_dir', None) chroot_dir = self.dirname if self.use_chroot else '/' temp_dir = kwargs["env"].get("TMPDIR", "/tmp") @@ -304,6 +298,18 @@ class StagingArea(object): if not os.path.islink(d): real_argv += ['--mount-readonly', self.relative(d)] + if self.use_chroot: + proc_target = os.path.join(self.dirname, 'proc') + if not os.path.exists(proc_target): + os.makedirs(proc_target) + real_argv += ['--mount-proc', self.relative(proc_target)] + + if ccache_dir and not self._app.settings['no-ccache']: + ccache_target = os.path.join( + self.dirname, kwargs['env']['CCACHE_DIR'].lstrip('/')) + real_argv += ['--mount-bind', ccache_dir, + self.relative(ccache_target)] + real_argv += [chroot_dir] real_argv += argv |