tools/liveimage-mount | 47 +++++++++++++++++++++++++++--------------------
1 file changed, 27 insertions(+), 20 deletions(-)
New commits:
commit befb1751f9a5f97897d11ac756b6acf841bcf928
Author: Colin Walters <walters(a)verbum.org>
Date: Wed Mar 24 14:50:03 2010 -0400
Rename --proc to --mount-hacks, strip whitespace
diff --git a/tools/liveimage-mount b/tools/liveimage-mount
index 272c702..76602a7 100755
--- a/tools/liveimage-mount
+++ b/tools/liveimage-mount
@@ -1,8 +1,8 @@
#!/usr/bin/python -tt
#
# livecd-mount: Mount a live CD at the specified point, and log
-# into a shell.
-#
+# into a shell.
+#
# Copyright 2010, Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
@@ -30,42 +30,47 @@ def usage(ecode):
def main():
try:
- opts,args = getopt.getopt(sys.argv[1:], 'h', ['help', 'chroot', 'proc'])
+ opts,args = getopt.getopt(sys.argv[1:], 'h', ['help', 'chroot', 'mount-hacks'])
except getopt.GetoptError, e:
usage(1)
-
+
+ rw = False
chroot = False
- proc = False
+ mount_hacks = False
for o,a in opts:
if o in ('-h', '--help'):
usage(0)
elif o in ('--chroot', ):
chroot = True
- elif o in ('--proc', ):
- proc = True
-
+ elif o in ('--mount-hacks', ):
+ mount_hacks = True
+
if len(args) < 2:
usage(1)
-
+
isopath = args[0]
destmnt = args[1]
-
+
command = args[2:]
verbose = not command
-
+
isomnt = tempfile.mkdtemp(prefix='livemnt-iso')
squashmnt = tempfile.mkdtemp(prefix='livemnt-squash')
-
+
+ mountflags = ['loop', 'ro']
+ mountflags_str = ','.join(mountflags)
+
try:
- subprocess.check_call(['mount', '-o', 'loop,ro', isopath, isomnt], stderr=sys.stderr)
+ subprocess.check_call(['mount', '-o', mountflags_str, isopath, isomnt], stderr=sys.stderr)
squash_img_path = os.path.join(isomnt, 'LiveOS', 'squashfs.img')
- subprocess.check_call(['mount', '-o', 'loop,ro', squash_img_path, squashmnt], stderr=sys.stderr)
+ subprocess.check_call(['mount', '-o', mountflags_str, squash_img_path, squashmnt], stderr=sys.stderr)
ext3_img_path = os.path.join(squashmnt, 'LiveOS', 'ext3fs.img')
- subprocess.check_call(['mount', '-o', 'loop,ro', ext3_img_path, destmnt], stderr=sys.stderr)
-
- if proc:
+ subprocess.check_call(['mount', '-o', mountflags_str, ext3_img_path, destmnt], stderr=sys.stderr)
+
+ if mount_hacks:
subprocess.check_call(['mount', '-t', 'proc', 'proc', os.path.join(destmnt, 'proc')], stderr=sys.stderr)
-
+ subprocess.check_call(['mount', '-t', 'tmpfs', 'tmpfs', os.path.join(destmnt, 'var', 'run')], stderr=sys.stderr)
+
if len(command) > 0:
args = ['chroot', destmnt]
args.extend(command)
@@ -79,7 +84,9 @@ def main():
finally:
if verbose:
print "Cleaning up..."
- subprocess.call(['umount', os.path.join(destmnt, 'proc')])
+ if mount_hacks:
+ subprocess.call(['umount', os.path.join(destmnt, 'var', 'run')])
+ subprocess.call(['umount', os.path.join(destmnt, 'proc')])
subprocess.call(['umount', destmnt])
subprocess.call(['umount', squashmnt])
os.rmdir(squashmnt)
@@ -87,7 +94,7 @@ def main():
os.rmdir(isomnt)
if verbose:
print "Cleanup complete"
-
+
sys.exit(ecode)
if __name__ == '__main__':