summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2014-03-20 11:11:11 +0000
committerPedro Alvarez <pedro.alvarez@codethink.co.uk>2014-03-20 16:52:14 +0000
commit69e48f2cca2e70224562efc75a946dde70a4cfc8 (patch)
tree65f8509b5171108e96f6284b24e4dbddc9c66f06
parentd29557989a2542bf8c34202eeec9b45390121de7 (diff)
downloadmorph-69e48f2cca2e70224562efc75a946dde70a4cfc8.tar.gz
Run the system integration commands when building
-rw-r--r--morphlib/builder2.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/morphlib/builder2.py b/morphlib/builder2.py
index caaad0d0..02e8b485 100644
--- a/morphlib/builder2.py
+++ b/morphlib/builder2.py
@@ -588,6 +588,7 @@ class SystemBuilder(BuilderBase): # pragma: no cover
fs_root = self.staging_area.destdir(self.artifact.source)
self.unpack_strata(fs_root)
self.write_metadata(fs_root, rootfs_name)
+ self.run_system_integration_commands(fs_root)
self.copy_kernel_into_artifact_cache(fs_root)
unslashy_root = fs_root[1:]
def uproot_info(info):
@@ -687,6 +688,51 @@ class SystemBuilder(BuilderBase): # pragma: no cover
os.chmod(os_release_file, 0644)
+ def run_system_integration_commands(self, rootdir): # pragma: no cover
+ ''' Run the system integration commands '''
+
+ sys_integration_dir = os.path.join(rootdir, SYSTEM_INTEGRATION_PATH)
+ if not os.path.isdir(sys_integration_dir):
+ return
+
+ env = {
+ 'PATH': '/bin:/usr/bin:/sbin:/usr/sbin'
+ }
+
+ self.app.status(msg='Running the system integration commands',
+ error=True)
+
+ mounted = []
+ to_mount = (
+ ('proc', 'proc', 'none'),
+ ('dev/shm', 'tmpfs', 'none'),
+ )
+
+ try:
+ for mount_point, mount_type, source in to_mount:
+ logging.debug('Mounting %s in system root filesystem'
+ % mount_point)
+ path = os.path.join(rootdir, mount_point)
+ if not os.path.exists(path):
+ os.makedirs(path)
+ morphlib.fsutils.mount(self.app.runcmd, source, path,
+ mount_type)
+ mounted.append(path)
+
+ self.app.runcmd(['chroot', rootdir, 'sh', '-c',
+ 'cd / && run-parts "$1"', '-', SYSTEM_INTEGRATION_PATH],
+ env=env)
+ except BaseException, e:
+ self.app.status(
+ msg='Error while running system integration commands',
+ error=True)
+ raise
+ finally:
+ for mount_path in reversed(mounted):
+ logging.debug('Unmounting %s in system root filesystem'
+ % mount_path)
+ morphlib.fsutils.unmount(self.app.runcmd, mount_path)
+
def copy_kernel_into_artifact_cache(self, path):
'''Copy the installed kernel image into the local artifact cache.