summaryrefslogtreecommitdiff
path: root/morphlib
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-07-26 11:12:35 +0100
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-07-26 12:01:58 +0100
commit7fa0fe6fca5af3fc9b917ee6e10239efc265b1aa (patch)
tree8eece0119eb0cfac9bda13e7df023d4493d61048 /morphlib
parent05fe245d1771ec25d8675b2dd9e4aeee6b22802c (diff)
downloadmorph-7fa0fe6fca5af3fc9b917ee6e10239efc265b1aa.tar.gz
Move fstab creation into base class
Diffstat (limited to 'morphlib')
-rw-r--r--morphlib/builder2.py20
-rw-r--r--morphlib/plugins/syslinux-disk-systembuilder_plugin.py14
-rw-r--r--morphlib/plugins/tarball-systembuilder_plugin.py14
3 files changed, 22 insertions, 26 deletions
diff --git a/morphlib/builder2.py b/morphlib/builder2.py
index dd3c530b..83f5ae84 100644
--- a/morphlib/builder2.py
+++ b/morphlib/builder2.py
@@ -530,6 +530,26 @@ class SystemKindBuilder(BuilderBase): # pragma: no cover
ldconfig(self.app.runcmd, path)
+ def create_fstab(self, path):
+ '''Create an /etc/fstab inside a system tree.
+
+ The fstab is created using assumptions of the disk layout.
+ If the assumptions are wrong, extend this code so it can deal
+ with other cases.
+
+ '''
+
+ self.app.status(msg='Creating fstab in %(path)s',
+ path=path, chatty=True)
+ with self.build_watch('create-fstab'):
+ fstab = os.path.join(path, 'etc', 'fstab')
+ if not os.path.exists(os.path.dirname(fstab)):# FIXME: should exist
+ os.makedirs(os.path.dirname(fstab))
+ with open(fstab, 'w') as f:
+ f.write('proc /proc proc defaults 0 0\n')
+ f.write('sysfs /sys sysfs defaults 0 0\n')
+ f.write('/dev/sda1 / btrfs defaults,rw,noatime 0 1\n')
+
class SystemKindBuilderFactory(object): # pragma: no cover
diff --git a/morphlib/plugins/syslinux-disk-systembuilder_plugin.py b/morphlib/plugins/syslinux-disk-systembuilder_plugin.py
index 41a95000..3728f553 100644
--- a/morphlib/plugins/syslinux-disk-systembuilder_plugin.py
+++ b/morphlib/plugins/syslinux-disk-systembuilder_plugin.py
@@ -59,7 +59,7 @@ class SyslinuxDiskBuilder(SystemKindBuilder): # pragma: no cover
factory_path = os.path.join(mount_point, 'factory')
self._create_subvolume(factory_path)
self.unpack_strata(factory_path)
- self._create_fstab(factory_path)
+ self.create_fstab(factory_path)
self._create_extlinux_config(factory_path)
self._create_subvolume_snapshot(
mount_point, 'factory', 'factory-run')
@@ -139,18 +139,6 @@ class SyslinuxDiskBuilder(SystemKindBuilder): # pragma: no cover
with self.build_watch('create-factory-subvolume'):
self.app.runcmd(['btrfs', 'subvolume', 'create', path])
- def _create_fstab(self, path):
- self.app.status(msg='Creating fstab in %(path)s',
- path=path, chatty=True)
- with self.build_watch('create-fstab'):
- fstab = os.path.join(path, 'etc', 'fstab')
- if not os.path.exists(os.path.dirname(fstab)):# FIXME: should exist
- os.makedirs(os.path.dirname(fstab))
- with open(fstab, 'w') as f:
- f.write('proc /proc proc defaults 0 0\n')
- f.write('sysfs /sys sysfs defaults 0 0\n')
- f.write('/dev/sda1 / btrfs defaults,rw,noatime 0 1\n')
-
def _create_extlinux_config(self, path):
self.app.status(msg='Creating extlinux.conf in %(path)s',
path=path, chatty=True)
diff --git a/morphlib/plugins/tarball-systembuilder_plugin.py b/morphlib/plugins/tarball-systembuilder_plugin.py
index 5582eec2..9b3f11f2 100644
--- a/morphlib/plugins/tarball-systembuilder_plugin.py
+++ b/morphlib/plugins/tarball-systembuilder_plugin.py
@@ -50,7 +50,7 @@ class RootfsTarballBuilder(SystemKindBuilder): # pragma: no cover
mount_point = self.staging_area.destdir(self.artifact.source)
factory_path = mount_point
self.unpack_strata(factory_path)
- self._create_fstab(factory_path)
+ self.create_fstab(factory_path)
if arch in ('x86', 'x86_64'):
self._create_extlinux_config(factory_path)
if arch in ('arm',):
@@ -73,18 +73,6 @@ class RootfsTarballBuilder(SystemKindBuilder): # pragma: no cover
self.save_build_times()
return [self.artifact]
- def _create_fstab(self, path):
- self.app.status(msg='Creating fstab in %(path)s',
- path=path, chatty=True)
- with self.build_watch('create-fstab'):
- fstab = os.path.join(path, 'etc', 'fstab')
- if not os.path.exists(os.path.dirname(fstab)):# FIXME: should exist
- os.makedirs(os.path.dirname(fstab))
- with open(fstab, 'w') as f:
- f.write('proc /proc proc defaults 0 0\n')
- f.write('sysfs /sys sysfs defaults 0 0\n')
- f.write('/dev/sda1 / btrfs defaults,rw,noatime 0 1\n')
-
def _create_extlinux_config(self, path):
self.app.status(msg='Creating extlinux.conf in %(path)s',
path=path, chatty=True)