diff options
author | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2015-02-05 13:51:23 +0000 |
---|---|---|
committer | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2015-03-19 10:53:26 +0000 |
commit | a89982205f132a9f6004aacfffc7b5c56eaa714e (patch) | |
tree | c56a7ca6c08dfc6fe8177b161bb90087c6cdac02 | |
parent | 2d527d0653913df3f7d836ffc1f29c4d601ea52c (diff) | |
download | morph-a89982205f132a9f6004aacfffc7b5c56eaa714e.tar.gz |
Add support for unionfs-fuse
Overlayfs is new in version 3.18 of the kernel, so add support for a
different implementation of a union/overlay filesystem in order to
allow morph to work on older kernels.
-rw-r--r-- | morphlib/app.py | 7 | ||||
-rw-r--r-- | morphlib/builder.py | 14 | ||||
-rw-r--r-- | morphlib/fsutils.py | 16 | ||||
-rw-r--r-- | morphlib/plugins/deploy_plugin.py | 19 |
4 files changed, 40 insertions, 16 deletions
diff --git a/morphlib/app.py b/morphlib/app.py index c8fe397d..f7c07726 100644 --- a/morphlib/app.py +++ b/morphlib/app.py @@ -120,6 +120,13 @@ class Morph(cliapp.Application): metavar='URL', default=None, group=group_advanced) + self.settings.string(['union-filesystem'], + 'filesystem used to provide "union filesystem" ' + 'functionality when building and deploying. ' + 'Only "overlayfs" and "unionfs-fuse" are ' + 'supported at this time.', + default='overlayfs', + group=group_advanced) group_build = 'Build Options' self.settings.integer(['max-jobs'], diff --git a/morphlib/builder.py b/morphlib/builder.py index 86b04a4a..9405c89a 100644 --- a/morphlib/builder.py +++ b/morphlib/builder.py @@ -536,19 +536,19 @@ class SystemBuilder(BuilderBase): # pragma: no cover try: fs_root = self.staging_area.destdir(self.source) self.unpack_strata(fs_root) - overlay_root = self.staging_area.overlay_upperdir( + upperdir = self.staging_area.overlay_upperdir( self.source) editable_root = self.staging_area.overlaydir(self.source) workdir = os.path.join(self.staging_area.dirname, 'overlayfs-workdir') if not os.path.exists(workdir): os.makedirs(workdir) - options = '-olowerdir=%s,upperdir=%s,workdir=%s' % \ - (fs_root, overlay_root, workdir) - morphlib.fsutils.mount(self.app.runcmd, - 'overlay-%s' % a_name, - editable_root, - 'overlay', options) + union_filesystem = self.app.settings['union-filesystem'] + morphlib.fsutils.overlay_mount(self.app.runcmd, + 'overlay-%s' % a_name, + editable_root, fs_root, + upperdir, workdir, + union_filesystem) self.write_metadata(editable_root, a_name) self.run_system_integration_commands(editable_root) unslashy_root = editable_root[1:] diff --git a/morphlib/fsutils.py b/morphlib/fsutils.py index 87b4cf3b..400ff7d8 100644 --- a/morphlib/fsutils.py +++ b/morphlib/fsutils.py @@ -59,6 +59,22 @@ def mount(runcmd, partition, mount_point, runcmd(['mount', partition, mount_point] + fstype + options) +def overlay_mount(runcmd, partition, mount_point, + lowerdir, upperdir, workdir, method): # pragma: no cover + if method == 'overlayfs': + options = '-olowerdir=%s,upperdir=%s,workdir=%s' % \ + (lowerdir, upperdir, workdir) + mount(runcmd, partition, mount_point, 'overlay', options) + elif method == 'unionfs': + if not os.path.exists(mount_point): + os.mkdir(mount_point) + dir_string = '%s=RW:%s=RO' % (upperdir, lowerdir) + runcmd(['unionfs', '-o', 'cow', dir_string, mount_point]) + else: + raise cliapp.AppException('Union filesystem %s not supported' % + method) + + def unmount(runcmd, mount_point): # pragma: no cover runcmd(['umount', mount_point]) diff --git a/morphlib/plugins/deploy_plugin.py b/morphlib/plugins/deploy_plugin.py index 9c771cd6..537afc33 100644 --- a/morphlib/plugins/deploy_plugin.py +++ b/morphlib/plugins/deploy_plugin.py @@ -581,12 +581,13 @@ class DeployPlugin(cliapp.Plugin): msg='System unpacked at %(system_tree)s', system_tree=system_tree) - options = '-olowerdir=%s,upperdir=%s,workdir=%s' % \ - (system_tree, overlay_dir, work_dir) - morphlib.fsutils.mount(self.app.runcmd, - 'overlay-deploy-%s' % artifact.name, - deploy_tree, fstype='overlay', - options=options) + union_filesystem = self.app.settings['union-filesystem'] + morphlib.fsutils.overlay_mount(self.app.runcmd, + 'overlay-deploy-%s' % + artifact.name, + deploy_tree, system_tree, + overlay_dir, work_dir, + union_filesystem) self.app.status( msg='Writing deployment metadata file') @@ -599,12 +600,12 @@ class DeployPlugin(cliapp.Plugin): sort_keys=True, encoding='unicode-escape') return deploy_tree except Exception: - shutil.rmtree(system_tree) - shutil.rmtree(overlay_dir) - shutil.rmtree(work_dir) if deploy_tree and os.path.exists(deploy_tree): morphlib.fsutils.unmount(self.app.runcmd, deploy_tree) shutil.rmtree(deploy_tree) + shutil.rmtree(system_tree) + shutil.rmtree(overlay_dir) + shutil.rmtree(work_dir) raise def run_deploy_commands(self, deploy_tempdir, env, artifact, root_repo_dir, |