summaryrefslogtreecommitdiff
path: root/morphlib/fsutils.py
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2012-05-29 17:18:46 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2012-05-30 13:11:13 +0100
commitb088e31b740c62b90ddf9c3342b876736790c1e8 (patch)
treeb73ea9c49d130c584c50c3b8c55f755f5cfa6d4a /morphlib/fsutils.py
parent34817d54a193c6c0937ef3868f31d822e90aa740 (diff)
downloadmorph-b088e31b740c62b90ddf9c3342b876736790c1e8.tar.gz
morph: remove dead code and replace Execute with app.runcmd
Diffstat (limited to 'morphlib/fsutils.py')
-rw-r--r--morphlib/fsutils.py44
1 files changed, 22 insertions, 22 deletions
diff --git a/morphlib/fsutils.py b/morphlib/fsutils.py
index 15ad7ebf..d4f9f474 100644
--- a/morphlib/fsutils.py
+++ b/morphlib/fsutils.py
@@ -17,26 +17,26 @@ import os
import re
-def create_image(ex, image_name, size):
+def create_image(runcmd, image_name, size):
# FIXME a pure python implementation may be better
- ex.runv(['dd', 'if=/dev/zero', 'of=' + image_name, 'bs=1',
- 'seek=%d' % size, 'count=0'])
+ runcmd(['dd', 'if=/dev/zero', 'of=' + image_name, 'bs=1',
+ 'seek=%d' % size, 'count=0'])
-def partition_image(ex, image_name):
+def partition_image(runcmd, image_name):
# FIXME make this more flexible with partitioning options
- ex.runv(['sfdisk', image_name], feed_stdin='1,,83,*\n')
+ runcmd(['sfdisk', image_name], feed_stdin='1,,83,*\n')
-def install_mbr(ex, image_name):
+def install_mbr(runcmd, image_name):
for path in ['/usr/lib/extlinux/mbr.bin',
'/usr/share/syslinux/mbr.bin']:
if os.path.exists(path):
- ex.runv(['dd', 'if=' + path, 'of=' + image_name,
- 'conv=notrunc'])
+ runcmd(['dd', 'if=' + path, 'of=' + image_name,
+ 'conv=notrunc'])
break
-def setup_device_mapping(ex, image_name):
+def setup_device_mapping(runcmd, image_name):
findstart = re.compile(r"start=\s+(\d+),")
- out = ex.runv(['sfdisk', '-d', image_name])
+ out = runcmd(['sfdisk', '-d', image_name])
for line in out.splitlines():
match = findstart.search(line)
if match is None:
@@ -45,30 +45,30 @@ def setup_device_mapping(ex, image_name):
if start != 0:
break
- ex.runv(['losetup', '-o', str(start), '-f', image_name])
+ runcmd(['losetup', '-o', str(start), '-f', image_name])
- out = ex.runv(['losetup', '-j', image_name])
+ out = runcmd(['losetup', '-j', image_name])
line = out.strip()
i = line.find(':')
return line[:i]
-def create_fs(ex, partition):
+def create_fs(runcmd, partition):
# FIXME: the hardcoded size of 4GB is icky but the default broke
# when we used mkfs -t ext4
- ex.runv(['mkfs.btrfs', '-L', 'baserock',
- '-b', '4294967296', partition])
+ runcmd(['mkfs.btrfs', '-L', 'baserock',
+ '-b', '4294967296', partition])
-def mount(ex, partition, mount_point):
+def mount(runcmd, partition, mount_point):
if not os.path.exists(mount_point):
os.mkdir(mount_point)
- ex.runv(['mount', partition, mount_point])
+ runcmd(['mount', partition, mount_point])
-def unmount(ex, mount_point):
- ex.runv(['umount', mount_point])
+def unmount(runcmd, mount_point):
+ runcmd(['umount', mount_point])
-def undo_device_mapping(ex, image_name):
- out = ex.runv(['losetup', '-j', image_name])
+def undo_device_mapping(runcmd, image_name):
+ out = runcmd(['losetup', '-j', image_name])
for line in out.splitlines():
i = line.find(':')
device = line[:i]
- ex.runv(['losetup', '-d', device])
+ runcmd(['losetup', '-d', device])