summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@gmail.com>2014-10-15 18:01:55 +0000
committerRichard Maw <richard.maw@gmail.com>2014-10-15 18:14:49 +0000
commitc5d1527c34ca7374a51366e54056145a5bd4bcb7 (patch)
tree63ced733f9584fe3d2955a8dc14620eb95258ea3
parent048f117a45a37237894aa7e20ddf92ee14a47fc9 (diff)
downloadmorph-c5d1527c34ca7374a51366e54056145a5bd4bcb7.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.py4
-rw-r--r--morphlib/stagingarea.py24
2 files changed, 18 insertions, 10 deletions
diff --git a/morphlib/builder2.py b/morphlib/builder2.py
index 9cd3a074..f2ef7393 100644
--- a/morphlib/builder2.py
+++ b/morphlib/builder2.py
@@ -341,6 +341,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 = [
@@ -390,7 +391,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