2 commits - imgcreate/live.py
by Brian C. Lane
imgcreate/live.py | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
New commits:
commit 8041f10645981473d111f9295f0d49d4a43e9327
Author: Brian C. Lane <bcl(a)redhat.com>
Date: Thu Mar 31 11:51:46 2011 -0700
Copy old initrd/xen files to isolinux when using base-on (#690940)
These are not present in the original .iso's /boot so copy them
over to the new /isolinux
This could fail with mismatched files if the kernels change, in that
case a new .iso needs to be made instead of using base-on
diff --git a/imgcreate/live.py b/imgcreate/live.py
index a15eb72..655eb16 100755
--- a/imgcreate/live.py
+++ b/imgcreate/live.py
@@ -22,6 +22,7 @@ import glob
import shutil
import subprocess
import logging
+import re
from imgcreate.errors import *
from imgcreate.fs import *
@@ -79,6 +80,7 @@ class LiveImageCreatorBase(LoopImageCreator):
self.__modules.extend(kickstart.get_modules(self.ks))
self._isofstype = "iso9660"
+ self.base_on = False
#
# Hooks for subclasses
@@ -149,12 +151,24 @@ class LiveImageCreatorBase(LoopImageCreator):
raise CreatorError("Failed to loopback mount '%s' : %s" %
(base_on, e))
+ # Copy the initrd%d.img and xen%d.gz files over to /isolinux
+ # This is because the originals in /boot are removed when the
+ # original .iso was created.
+ src = isoloop.mountdir + "/isolinux/"
+ dest = self.__ensure_isodir() + "/isolinux/"
+ makedirs(dest)
+ pattern = re.compile(r"(initrd\d+\.img|xen\d+\.gz)")
+ files = [f for f in os.listdir(src) if pattern.search(f)
+ and os.path.isfile(src+f)]
+ for f in files:
+ shutil.copyfile(src+f, dest+f)
+
# legacy LiveOS filesystem layout support, remove for F9 or F10
if os.path.exists(isoloop.mountdir + "/squashfs.img"):
squashimg = isoloop.mountdir + "/squashfs.img"
else:
squashimg = isoloop.mountdir + "/LiveOS/squashfs.img"
-
+
squashloop = DiskMount(LoopbackDisk(squashimg, 0), self._mkdtemp(), "squashfs")
# 'self.compress_type = None' will force reading it from base_on.
@@ -194,6 +208,7 @@ class LiveImageCreatorBase(LoopImageCreator):
isoloop.cleanup()
def _mount_instroot(self, base_on = None):
+ self.base_on = True
LoopImageCreator._mount_instroot(self, base_on)
self.__write_initrd_conf(self._instroot + "/etc/sysconfig/mkinitrd")
self.__write_dracut_conf(self._instroot + "/etc/dracut.conf")
@@ -410,9 +425,11 @@ class x86LiveImageCreator(LiveImageCreatorBase):
shutil.copyfile(bootdir + "/initramfs-" + version + ".img",
isodir + "/isolinux/initrd" + index + ".img")
isDracut = True
- else:
+ elif os.path.exists(bootdir + "/initrd-" + version + ".img"):
shutil.copyfile(bootdir + "/initrd-" + version + ".img",
isodir + "/isolinux/initrd" + index + ".img")
+ elif not self.base_on:
+ logging.error("No initrd or initramfs found for %s" % (version,))
is_xen = False
if os.path.exists(bootdir + "/xen.gz-" + version[:-3]):
commit 0d3136dcaa62c85778ca5759e2580a48fc464c79
Author: Brian C. Lane <bcl(a)redhat.com>
Date: Wed Mar 30 16:31:27 2011 -0700
Don't fail on missing splash image
The splash image is provided by the logo package.
It shouldn't be a fatal error if it is missing.
diff --git a/imgcreate/live.py b/imgcreate/live.py
index 10d5cec..a15eb72 100755
--- a/imgcreate/live.py
+++ b/imgcreate/live.py
@@ -605,8 +605,11 @@ menu hiddenrow 5
return False
shutil.copy(self._instroot + "/boot/efi/EFI/redhat/grub.efi",
isodir + "/EFI/boot/grub.efi")
- shutil.copy(self._instroot + "/boot/grub/splash.xpm.gz",
- isodir + "/EFI/boot/splash.xpm.gz")
+
+ # Should exist, but if it doesn't we should fail
+ if os.path.exists(self._instroot + "/boot/grub/splash.xpm.gz"):
+ shutil.copy(self._instroot + "/boot/grub/splash.xpm.gz",
+ isodir + "/EFI/boot/splash.xpm.gz")
return True
11 years, 12 months
[PATCH] Enable live-mounting of LiveOS device together with an active overlay
by Frederick Grose
https://bugzilla.redhat.com/show_bug.cgi?id=448030#c38
Author: Frederick Grose <fgrose(a)gmail.com>
Date: Thu Mar 17 00:15:22 2011 -0400
Enable standalone live-mounting of an installed LiveOS image with access
to
its overlay.
Detect the presence of an overlay on a device with an installed LiveOS,
and
use loop mounts and the device-mapper service to create a 'live-mounted'
block device for the attached LiveOS-bearing partition. Provide an
option
to --persist the mounting for chaining to another script.
The script continues to be a standalone tool with limited error
checking.
The script requires 3 to 4 free loop devices, so is not yet suitable for
use
within a booted LiveOS image.
diff --git a/tools/liveimage-mount b/tools/liveimage-mount
index 76602a7..185f070 100755
--- a/tools/liveimage-mount
+++ b/tools/liveimage-mount
@@ -1,9 +1,11 @@
#!/usr/bin/python -tt
#
-# livecd-mount: Mount a live CD at the specified point, and log
+# liveimage-mount: Mount a LiveOS at the specified point, and log
# into a shell.
#
-# Copyright 2010, Red Hat Inc.
+# Copyright 2011, Red Hat Inc.
+# Code for Live mounting an attached LiveOS device added by Frederick
Grose,
+# <fgrose at sugarlabs.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -20,22 +22,101 @@
import os
import sys
+import stat
import getopt
import tempfile
import subprocess
+
def usage(ecode):
- print "Usage: %s ISO.iso MOUNTPOINT [COMMAND] [ARGS]"
+ print """Usage:
+ liveimage-mount [opts] ISO.iso|LiveOSdevice MOUNTPOINT [COMMAND]
[ARGS]
+
+ where [opts] = [-h|--help
+ [--chroot
+ [--mount-hacks
+ [--persist]]]]]
+
+ and [ARGS] = [arg1[ arg2[ ...]]]\n"""
sys.exit(ecode)
+
+def call(*popenargs, **kwargs):
+ '''
+ Calls subprocess.Popen() with the provided arguments. All stdout
and
+ stderr output is sent to print. The return value is the exit
+ code of the command.
+ '''
+ p = subprocess.Popen(*popenargs, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT, **kwargs)
+ rc = p.wait()
+
+ # Log output using logging module
+ while True:
+ # FIXME choose a more appropriate buffer size
+ buf = p.stdout.read(4096)
+ if not buf:
+ break
+ print buf
+
+ return rc
+
+
+def rcall(args, env=None):
+ if env:
+ environ = os.environ.copy()
+ environ.update(env)
+ else:
+ environ = None
+ try:
+ p = subprocess.Popen(args, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, env=environ)
+ out, err = p.communicate()
+ except OSError, e:
+ raise CreatorError(u"Failed to execute:\n'%s'\n'%s'" % (args, e))
+ except:
+ raise CreatorError(u"""Failed to execute:\n'%s'
+ \renviron: '%s'\nstdout: '%s'\nstderr: '%s'\nreturncode:
'%s'""" %
+ (args, environ, out, err, p.returncode))
+ else:
+ if p.returncode != 0:
+ raise CreatorError(u"""Error in call:\n'%s'\nenviron: '%s'
+ \rstdout: '%s'\nstderr: '%s'\nreturncode: '%s'""" %
+ (args, environ, out, err, p.returncode))
+ return out
+
+
+def get_device_mountpoint(path):
+ """Return the device and mountpoint for a file or device path."""
+
+ info = list()
+ info[0:5] = [None] * 6
+ if os.path.exists(path):
+ st_mode = os.stat(path).st_mode
+ if stat.S_ISBLK(st_mode) or os.path.ismount(path):
+ devinfo = rcall(['/bin/df', path]).splitlines()
+ info = devinfo[1].split(None)
+ if len(info) == 1:
+ info.extend(devinfo[2].split(None))
+ return [info[0], info[5]]
+
+
def main():
+ if os.geteuid() != 0:
+ print >> sys.stderr, """\n Exiting...
+ \r You must run liveimage-mount with root priviledges.\n"""
+ return 1
+
try:
- opts,args = getopt.getopt(sys.argv[1:], 'h', ['help', 'chroot',
'mount-hacks'])
+ opts,args = getopt.getopt(sys.argv[1:], 'h', ['help',
+ 'chroot', 'persist',
+ 'mount-hacks'])
except getopt.GetoptError, e:
usage(1)
- rw = False
+ img_type = None
chroot = False
+ persist = False
mount_hacks = False
for o,a in opts:
if o in ('-h', '--help'):
@@ -44,34 +125,121 @@ def main():
chroot = True
elif o in ('--mount-hacks', ):
mount_hacks = True
+ elif o in ('--persist', ):
+ """Option used to run a command in a spawned process."""
+ persist = True
if len(args) < 2:
usage(1)
- isopath = args[0]
+ liveos = args[0]
destmnt = args[1]
+ if not os.path.exists(liveos):
+ print """\n Exiting...
+ %s is not a file, directory, or device.\n""" % liveos
+ ecode = 1
+ return
+
+ if stat.S_ISBLK(os.stat(liveos).st_mode):
+ img_type = 'blk'
+ imgloop = None
+ overlayloop = None
+ else:
+ img_type = 'iso'
+
+ if img_type is 'blk':
+ liveosmnt = tempfile.mkdtemp(prefix='livemnt-device-')
+ if img_type is 'iso':
+ liveosmnt = tempfile.mkdtemp(prefix='livemnt-iso-')
+
+ liveosdir = os.path.join(liveosmnt, 'LiveOS')
+ homemnt = None
+ dm_cow = None
+ mntlive = None
+
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)
+ squashmnt = tempfile.mkdtemp(prefix='livemnt-squash-')
+ squashloop = None
+ imgloop = None
+ losetup_args = ['/sbin/losetup', '-f', '--show']
try:
- 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', mountflags_str,
squash_img_path, squashmnt], stderr=sys.stderr)
- ext3_img_path = os.path.join(squashmnt, 'LiveOS', 'ext3fs.img')
- subprocess.check_call(['mount', '-o', mountflags_str,
ext3_img_path, destmnt], stderr=sys.stderr)
+ if img_type is 'blk':
+ call(['/bin/mount', liveos, liveosmnt])
+ elif img_type is 'iso':
+ liveosloop = rcall(losetup_args + [liveos]).rstrip()
+ call(['/bin/mount', '-o', 'ro', liveosloop, liveosmnt])
+
+ squash_img = os.path.join(liveosdir, 'squashfs.img')
+ if not os.path.exists(squash_img):
+ ext3_img = os.path.join(liveosdir, 'ext3fs.img')
+ if not os.path.exists(ext3_img):
+ print """
+ \r\tNo LiveOS was found on %s\n\t Exiting...\n""" % liveos
+ ecode = 1
+ return
+ else:
+ squashloop = rcall(losetup_args + [squash_img]).rstrip()
+ call(['/bin/mount', '-o', 'ro', squashloop, squashmnt])
+ ext3_img = os.path.join(squashmnt, 'LiveOS', 'ext3fs.img')
+
+ if img_type is 'blk':
+ imgloop = rcall(losetup_args + [ext3_img]).rstrip()
+ imgsize = rcall(['/sbin/blockdev', '--getsz',
imgloop]).rstrip()
+ files = os.listdir(liveosdir)
+ overlay = None
+ for f in files:
+ if f.find('overlay-') == 0:
+ overlay = f
+ break
+ overlayloop = rcall(['/sbin/losetup', '-f']).rstrip()
+ if overlay:
+ call(['/sbin/losetup', overlayloop, os.path.join(liveosdir,
+ overlay)])
+ dm_cow = 'live-rw'
+ else:
+ overlay = tempfile.NamedTemporaryFile(dir='/dev/shm')
+ print "\npreparing temporary overlay..."
+ call(['/bin/dd', 'if=/dev/null', 'of=%s' % overlay.name,
+ 'bs=1024', 'count=1', 'seek=%s' % (512 * 1024)])
+ call(['/sbin/losetup', overlayloop, overlay.name])
+ dm_cow = 'live-ro'
+ call(['/sbin/dmsetup', '--noudevrules', '--noudevsync',
+ 'create', dm_cow, '--table=0 %s snapshot %s %s p 8' %
+ (imgsize, imgloop, overlayloop)])
+ call(['/bin/mount', os.path.join('/dev/mapper', dm_cow),
destmnt])
+ home_path = os.path.join(liveosdir, 'home.img')
+ if os.path.exists(home_path):
+ homemnt = os.path.join(destmnt, 'home')
+ homeloop = rcall(losetup_args + [home_path]).rstrip()
+ call(['/bin/mount', homeloop, homemnt])
+ mntlive = os.path.join(destmnt, 'mnt', 'live')
+ if not os.path.exists(mntlive):
+ os.makedirs(mntlive)
+ call(['/bin/mount', '--bind', liveosmnt, mntlive])
+ elif img_type is 'iso':
+ imgloop = rcall(losetup_args + [ext3_img]).rstrip()
+ call(['/bin/mount', '-o', 'ro', imgloop, destmnt])
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:
+ if len(command) > 0 and persist:
+ args = []
+ args.extend(command)
+ live = ''
+ if img_type is 'blk':
+ live = 'live-'
+ print """Starting process with this command line:
+ \r%s\n %s is %smounted.""" % (' '.join(command), liveos, live)
+ p = subprocess.Popen(args, close_fds=True)
+ print "Process id: %s" % p.pid
+ ecode = p.returncode
+ elif len(command) > 0:
args = ['chroot', destmnt]
args.extend(command)
ecode = subprocess.call(args, stdin=sys.stdin,
stdout=sys.stdout, stderr=sys.stderr)
@@ -79,21 +247,49 @@ def main():
print "Starting subshell in chroot, press Ctrl-D to exit..."
ecode = subprocess.call(['chroot', destmnt], stdin=sys.stdin,
stdout=sys.stdout, stderr=sys.stderr)
else:
- print "Starting subshell, press Ctrl-D to exit..."
+ if dm_cow == 'live-ro':
+ status = ' with NO LiveOS persistence,'
+ else:
+ status = ''
+ print "Entering subshell,%s press Ctrl-D to exit..." % status
ecode = subprocess.call([os.environ['SHELL']], cwd=destmnt,
stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr)
finally:
- if verbose:
- print "Cleaning up..."
- 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)
- subprocess.call(['umount', isomnt])
- os.rmdir(isomnt)
- if verbose:
- print "Cleanup complete"
+ call(['/bin/sync'])
+ if not persist:
+ if verbose:
+ print """Cleaning up...
+ Please wait if large files were written."""
+ if mount_hacks:
+ subprocess.call(['umount', os.path.join(destmnt, 'var',
'run')])
+ subprocess.call(['umount', os.path.join(destmnt, 'proc')])
+ if homemnt:
+ call(['/bin/umount', homemnt])
+ call(['/sbin/losetup', '-d', homeloop])
+ if img_type is 'blk':
+ if mntlive:
+ call(['/bin/umount', mntlive])
+ os.rmdir(mntlive)
+ if os.path.ismount(destmnt):
+ call(['/bin/umount', destmnt])
+ if img_type is 'blk':
+ if dm_cow:
+ call(['/sbin/dmsetup', '--noudevrules', '--noudevsync',
+ 'remove', dm_cow])
+ if overlayloop:
+ call(['/sbin/losetup', '-d', overlayloop])
+ if imgloop:
+ call(['/sbin/losetup', '-d', imgloop])
+ if squashloop:
+ call(['/bin/umount', squashloop])
+ call(['/sbin/losetup', '-d', squashloop])
+ call(['/bin/umount', liveosmnt])
+ if not img_type is 'blk':
+ call(['/sbin/losetup', '-d', liveosloop])
+ os.rmdir(squashmnt)
+ if not os.path.ismount(liveosmnt):
+ os.rmdir(liveosmnt)
+ if verbose:
+ print "Cleanup complete"
sys.exit(ecode)
11 years, 12 months
Changes to 'refs/tags/livecd-tools-15.6'
by Brian C. Lane
Tag 'livecd-tools-15.6' created by Brian C. Lane <bcl(a)redhat.com> at 2011-03-29 16:14 +0000
Tag as livecd-tools-15.6
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
iQEVAwUATZIFbhF+jBaO/jp/AQJTdAgAhK15k0EwUirxkjUcuFt70I9fV8WULkWC
qcI6pwW6QwtKycnEYjANrQi2LLgsXU8s0L1KWVglkMbtsQPFOfr/63jJPciQITuF
UxbPv5l+4jV/7HEYxCa3+6dI2MF7Ox2/t5c0fxzrdvPNU4tlY9A5Bu1qm6t9D+3o
ctgSUbW+VUJDH1GadeotC9/LyF5Wk2CM4hVTaA4l7+aJm+bLOPvftF7y5/ThnW7Y
HXp2wnDC6MW3TBoP4HxgaDcUTB+vLRvJbu2hrz1lat2Qo0dQuQYreLJMeg3vtLbV
6fM/AEJNsvM0IAM7D3+9e0YrILz7p8V7+/N1Eks0ipLnSuIi4xkbww==
=5/L4
-----END PGP SIGNATURE-----
Changes since livecd-tools-15.5:
Brian C. Lane (3):
gptmbr can be written directly to the mbr
Symlink image-creator instead of hardlink (#689167)
Version 15.6
Jan Kratochvil (1):
Fixup livedir support (#679023)
Lubomir Rintel (1):
Mailing list address changed
---
HACKING | 4 ++--
Makefile | 4 ++--
tools/livecd-iso-to-disk.sh | 32 +++++++++++++++-----------------
3 files changed, 19 insertions(+), 21 deletions(-)
---
12 years
Branch 'f15-branch' - 3 commits - HACKING Makefile
by Brian C. Lane
HACKING | 4 ++--
Makefile | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
New commits:
commit a7c3d91d07450b328c45c6dbef8d5cf038802240
Author: Brian C. Lane <bcl(a)redhat.com>
Date: Tue Mar 29 09:12:27 2011 -0700
Version 15.6
diff --git a/Makefile b/Makefile
index 027f6a5..1751834 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
-VERSION = 15.5
+VERSION = 15.6
INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = ${INSTALL}
commit 15595b2192750bee6a20225a35b9baea708e5f77
Author: Brian C. Lane <bcl(a)redhat.com>
Date: Mon Mar 21 09:38:58 2011 -0700
Symlink image-creator instead of hardlink (#689167)
Fixes conflicting selinux contexts between livecd-creator and
image-creator
diff --git a/Makefile b/Makefile
index 5d360aa..027f6a5 100644
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,7 @@ man:
install: man
$(INSTALL_PROGRAM) -D tools/livecd-creator $(DESTDIR)/usr/bin/livecd-creator
- ln $(DESTDIR)/usr/bin/livecd-creator $(DESTDIR)/usr/bin/image-creator
+ ln -s ./livecd-creator $(DESTDIR)/usr/bin/image-creator
$(INSTALL_PROGRAM) -D tools/liveimage-mount $(DESTDIR)/usr/bin/liveimage-mount
$(INSTALL_PROGRAM) -D tools/livecd-iso-to-disk.sh $(DESTDIR)/usr/bin/livecd-iso-to-disk
$(INSTALL_PROGRAM) -D tools/livecd-iso-to-pxeboot.sh $(DESTDIR)/usr/bin/livecd-iso-to-pxeboot
commit 839e0ba17cacedaa7da10506a51a54b65644a39d
Author: Lubomir Rintel <lkundrak(a)v3.sk>
Date: Fri Mar 11 12:19:05 2011 -0800
Mailing list address changed
diff --git a/HACKING b/HACKING
index e912112..00fbe3c 100644
--- a/HACKING
+++ b/HACKING
@@ -17,9 +17,9 @@ Change history etc. can be obtained from the web interface
PATCHES
=======
-Send patches to the fedora-livecd-list(a)redhat.com mailing list
+Send patches to the livecd(a)lists.fedoraproject.org mailing list
- http://www.redhat.com/mailman/listinfo/fedora-livecd-list
+ https://lists.fedoraproject.org/mailman/listinfo/livecd
If you have a number of patches and want to have them pulled from a
public git repository, please post a pointer to it as well as sending
12 years
Turning an Android phone into a Fedora live USB installation
by James Heather
I've been having fun over the last few days with putting a Linux
installation onto the SD card in my phone, so that I can then boot my
computer up from it. Just plug the phone into any old PC, reboot, tell
it to boot off the USB device, and there you go... all my docs are now
stored encrypted on my phone, and I can even mount the encrypted
partition directly on the phone if I want so that I can get to the files
when I'm on the move. I've been carrying a live USB stick round with me
for years, but I might ditch it in favour of just booting straight off
the phone.
Full details if you want to try it out:
http://let-the-reader-understand.blogspot.com/2011/03/how-to-use-your-and...
James
12 years
Help: How to boot a Live CD by using EFI?
by Lee Eric
Hi,
To boot a live CD by using EFI, what stuff I need to add into the Live
CD? Any instruction for that? I know normally legacy booting by using
Syslinux but it does not support EFI as far as I know.
Thanks in advance.
Eric
12 years
2 commits - tools/livecd-iso-to-disk.sh
by Brian C. Lane
tools/livecd-iso-to-disk.sh | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
New commits:
commit 13bf748e61c44980d138b2046f5e46b7acf48cd2
Author: Brian C. Lane <bcl(a)redhat.com>
Date: Wed Mar 23 14:06:25 2011 -0700
Images go into $SYSLINUXPATH
Now that syslinux version check is fixed they end up in the correct
place.
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index b37d9f2..5261aab 100755
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -1136,8 +1136,8 @@ if [ "$srctype" = "installer" ]; then
sed -i -e "s;initrd=initrd.img;initrd=initrd.img ${LANG:+LANG=$LANG} repo=hd:$TGTLABEL:/;g" $BOOTCONFIG
sed -i -e "s;stage2=\S*;;g" $BOOTCONFIG
if [ -n "$efi" ]; then
- # Images are in / now
- sed -i -e "s;images/pxeboot/;;g" -e "s;vmlinuz;vmlinuz ${LANG:+LANG=$LANG} repo=hd:$TGTLABEL:/;g" $BOOTCONFIG_EFI
+ # Images are in $SYSLINUXPATH now
+ sed -i -e "s;/images/pxeboot/;/$SYSLINUXPATH/;g" -e "s;vmlinuz;vmlinuz ${LANG:+LANG=$LANG} repo=hd:$TGTLABEL:/;g" $BOOTCONFIG_EFI
fi
fi
@@ -1148,11 +1148,10 @@ if [ "$srctype" = "netinst" ]; then
else
# The initrd has everything, so no stage2
sed -i -e "s;stage2=\S*;;g" $BOOTCONFIG
-
- if [ -n "$efi" ]; then
- # Images are in / now
- sed -ie "s;images/pxeboot/;;g" $BOOTCONFIG_EFI
- fi
+ fi
+ if [ -n "$efi" ]; then
+ # Images are in $SYSLINUXPATH now
+ sed -ie "s;/images/pxeboot/;/$SYSLINUXPATH/;g" $BOOTCONFIG_EFI
fi
fi
commit 731b1adb6a2e48299f193af5637d2e3d7c45dfec
Author: Brian C. Lane <bcl(a)redhat.com>
Date: Wed Mar 23 15:33:06 2011 -0700
fix typo
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index 088188b..b37d9f2 100755
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -828,7 +828,7 @@ if [ "$overlaysizemb" -gt 0 ]; then
fi
LABEL=$(/sbin/blkid -s LABEL -o value $TGTDEV)
if [[ "$LABEL" =~ ( ) ]]; then
- echo "The LABEL($LABEL) on $TGTDEV has spaces in it, which not work with the overlay"
+ echo "The LABEL($LABEL) on $TGTDEV has spaces in it, which do not work with the overlay"
echo "You can re-format or use dosfslabel/e2fslabel to change it"
exitclean
fi
12 years
4 commits - tools/livecd-iso-to-disk.sh tools/liveimage-mount
by Brian C. Lane
tools/livecd-iso-to-disk.sh | 14 +-
tools/liveimage-mount | 256 ++++++++++++++++++++++++++++++++++++++------
2 files changed, 233 insertions(+), 37 deletions(-)
New commits:
commit 731ba56081dcc580b314d3214d0758a932a96118
Author: Frederick Grose <fgrose(a)gmail.com>
Date: Mon Mar 21 14:38:18 2011 -0700
liveimage-mount installed LiveOS with overlay
Enable standalone live-mounting of an installed LiveOS image with access to its
overlay.
Detect the presence of an overlay on a device with an installed LiveOS, and use
loop mounts and the device-mapper service to create a 'live-mounted' block
device for the attached LiveOS-bearing partition. Provide an option to
--persist the mounting for chaining to another script.
The script continues to be a standalone tool with limited error checking. The
script requires 3 to 4 free loop devices, so is not yet suitable for use within
a booted LiveOS image.
diff --git a/tools/liveimage-mount b/tools/liveimage-mount
index 76602a7..80d67d1 100755
--- a/tools/liveimage-mount
+++ b/tools/liveimage-mount
@@ -1,9 +1,11 @@
#!/usr/bin/python -tt
#
-# livecd-mount: Mount a live CD at the specified point, and log
+# liveimage-mount: Mount a LiveOS at the specified point, and log
# into a shell.
#
-# Copyright 2010, Red Hat Inc.
+# Copyright 2011, Red Hat Inc.
+# Code for Live mounting an attached LiveOS device added by Frederick Grose,
+# <fgrose at sugarlabs.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -20,22 +22,101 @@
import os
import sys
+import stat
import getopt
import tempfile
import subprocess
+
def usage(ecode):
- print "Usage: %s ISO.iso MOUNTPOINT [COMMAND] [ARGS]"
+ print """Usage:
+ liveimage-mount [opts] ISO.iso|LiveOSdevice MOUNTPOINT [COMMAND] [ARGS]
+
+ where [opts] = [-h|--help
+ [--chroot
+ [--mount-hacks
+ [--persist]]]]]
+
+ and [ARGS] = [arg1[ arg2[ ...]]]\n"""
sys.exit(ecode)
+
+def call(*popenargs, **kwargs):
+ '''
+ Calls subprocess.Popen() with the provided arguments. All stdout and
+ stderr output is sent to print. The return value is the exit
+ code of the command.
+ '''
+ p = subprocess.Popen(*popenargs, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT, **kwargs)
+ rc = p.wait()
+
+ # Log output using logging module
+ while True:
+ # FIXME choose a more appropriate buffer size
+ buf = p.stdout.read(4096)
+ if not buf:
+ break
+ print buf
+
+ return rc
+
+
+def rcall(args, env=None):
+ if env:
+ environ = os.environ.copy()
+ environ.update(env)
+ else:
+ environ = None
+ try:
+ p = subprocess.Popen(args, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, env=environ)
+ out, err = p.communicate()
+ except OSError, e:
+ raise CreatorError(u"Failed to execute:\n'%s'\n'%s'" % (args, e))
+ except:
+ raise CreatorError(u"""Failed to execute:\n'%s'
+ \renviron: '%s'\nstdout: '%s'\nstderr: '%s'\nreturncode: '%s'""" %
+ (args, environ, out, err, p.returncode))
+ else:
+ if p.returncode != 0:
+ raise CreatorError(u"""Error in call:\n'%s'\nenviron: '%s'
+ \rstdout: '%s'\nstderr: '%s'\nreturncode: '%s'""" %
+ (args, environ, out, err, p.returncode))
+ return out
+
+
+def get_device_mountpoint(path):
+ """Return the device and mountpoint for a file or device path."""
+
+ info = list()
+ info[0:5] = [None] * 6
+ if os.path.exists(path):
+ st_mode = os.stat(path).st_mode
+ if stat.S_ISBLK(st_mode) or os.path.ismount(path):
+ devinfo = rcall(['/bin/df', path]).splitlines()
+ info = devinfo[1].split(None)
+ if len(info) == 1:
+ info.extend(devinfo[2].split(None))
+ return [info[0], info[5]]
+
+
def main():
+ if os.geteuid() != 0:
+ print >> sys.stderr, """\n Exiting...
+ \r You must run liveimage-mount with root priviledges.\n"""
+ return 1
+
try:
- opts,args = getopt.getopt(sys.argv[1:], 'h', ['help', 'chroot', 'mount-hacks'])
+ opts,args = getopt.getopt(sys.argv[1:], 'h', ['help',
+ 'chroot', 'persist',
+ 'mount-hacks'])
except getopt.GetoptError, e:
usage(1)
- rw = False
+ img_type = None
chroot = False
+ persist = False
mount_hacks = False
for o,a in opts:
if o in ('-h', '--help'):
@@ -44,34 +125,121 @@ def main():
chroot = True
elif o in ('--mount-hacks', ):
mount_hacks = True
+ elif o in ('--persist', ):
+ """Option used to run a command in a spawned process."""
+ persist = True
if len(args) < 2:
usage(1)
- isopath = args[0]
+ liveos = args[0]
destmnt = args[1]
+ if not os.path.exists(liveos):
+ print """\n Exiting...
+ %s is not a file, directory, or device.\n""" % liveos
+ ecode = 1
+ return
+
+ if stat.S_ISBLK(os.stat(liveos).st_mode):
+ img_type = 'blk'
+ imgloop = None
+ overlayloop = None
+ else:
+ img_type = 'iso'
+
+ if img_type is 'blk':
+ liveosmnt = tempfile.mkdtemp(prefix='livemnt-device-')
+ if img_type is 'iso':
+ liveosmnt = tempfile.mkdtemp(prefix='livemnt-iso-')
+
+ liveosdir = os.path.join(liveosmnt, 'LiveOS')
+ homemnt = None
+ dm_cow = None
+ mntlive = None
+
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)
+ squashmnt = tempfile.mkdtemp(prefix='livemnt-squash-')
+ squashloop = None
+ imgloop = None
+ losetup_args = ['/sbin/losetup', '-f', '--show']
try:
- 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', mountflags_str, squash_img_path, squashmnt], stderr=sys.stderr)
- ext3_img_path = os.path.join(squashmnt, 'LiveOS', 'ext3fs.img')
- subprocess.check_call(['mount', '-o', mountflags_str, ext3_img_path, destmnt], stderr=sys.stderr)
+ if img_type is 'blk':
+ call(['/bin/mount', liveos, liveosmnt])
+ elif img_type is 'iso':
+ liveosloop = rcall(losetup_args + [liveos]).rstrip()
+ call(['/bin/mount', '-o', 'ro', liveosloop, liveosmnt])
+
+ squash_img = os.path.join(liveosdir, 'squashfs.img')
+ if not os.path.exists(squash_img):
+ ext3_img = os.path.join(liveosdir, 'ext3fs.img')
+ if not os.path.exists(ext3_img):
+ print """
+ \r\tNo LiveOS was found on %s\n\t Exiting...\n""" % liveos
+ ecode = 1
+ return
+ else:
+ squashloop = rcall(losetup_args + [squash_img]).rstrip()
+ call(['/bin/mount', '-o', 'ro', squashloop, squashmnt])
+ ext3_img = os.path.join(squashmnt, 'LiveOS', 'ext3fs.img')
+
+ if img_type is 'blk':
+ imgloop = rcall(losetup_args + [ext3_img]).rstrip()
+ imgsize = rcall(['/sbin/blockdev', '--getsz', imgloop]).rstrip()
+ files = os.listdir(liveosdir)
+ overlay = None
+ for f in files:
+ if f.find('overlay-') == 0:
+ overlay = f
+ break
+ overlayloop = rcall(['/sbin/losetup', '-f']).rstrip()
+ if overlay:
+ call(['/sbin/losetup', overlayloop, os.path.join(liveosdir,
+ overlay)])
+ dm_cow = 'live-rw'
+ else:
+ overlay = tempfile.NamedTemporaryFile(dir='/dev/shm')
+ print "\npreparing temporary overlay..."
+ call(['/bin/dd', 'if=/dev/null', 'of=%s' % overlay.name,
+ 'bs=1024', 'count=1', 'seek=%s' % (512 * 1024)])
+ call(['/sbin/losetup', overlayloop, overlay.name])
+ dm_cow = 'live-ro'
+ call(['/sbin/dmsetup', '--noudevrules', '--noudevsync',
+ 'create', dm_cow, '--table=0 %s snapshot %s %s p 8' %
+ (imgsize, imgloop, overlayloop)])
+ call(['/bin/mount', os.path.join('/dev/mapper', dm_cow), destmnt])
+ home_path = os.path.join(liveosdir, 'home.img')
+ if os.path.exists(home_path):
+ homemnt = os.path.join(destmnt, 'home')
+ homeloop = rcall(losetup_args + [home_path]).rstrip()
+ call(['/bin/mount', homeloop, homemnt])
+ mntlive = os.path.join(destmnt, 'mnt', 'live')
+ if not os.path.exists(mntlive):
+ os.makedirs(mntlive)
+ call(['/bin/mount', '--bind', liveosmnt, mntlive])
+ elif img_type is 'iso':
+ imgloop = rcall(losetup_args + [ext3_img]).rstrip()
+ call(['/bin/mount', '-o', 'ro', imgloop, destmnt])
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:
+ if len(command) > 0 and persist:
+ args = []
+ args.extend(command)
+ live = ''
+ if img_type is 'blk':
+ live = 'live-'
+ print """Starting process with this command line:
+ \r%s\n %s is %smounted.""" % (' '.join(command), liveos, live)
+ p = subprocess.Popen(args, close_fds=True)
+ print "Process id: %s" % p.pid
+ ecode = p.returncode
+ elif len(command) > 0:
args = ['chroot', destmnt]
args.extend(command)
ecode = subprocess.call(args, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr)
@@ -79,21 +247,49 @@ def main():
print "Starting subshell in chroot, press Ctrl-D to exit..."
ecode = subprocess.call(['chroot', destmnt], stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr)
else:
- print "Starting subshell, press Ctrl-D to exit..."
+ if dm_cow == 'live-ro':
+ status = ' with NO LiveOS persistence,'
+ else:
+ status = ''
+ print "Entering subshell,%s press Ctrl-D to exit..." % status
ecode = subprocess.call([os.environ['SHELL']], cwd=destmnt, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr)
finally:
- if verbose:
- print "Cleaning up..."
- 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)
- subprocess.call(['umount', isomnt])
- os.rmdir(isomnt)
- if verbose:
- print "Cleanup complete"
+ call(['/bin/sync'])
+ if not persist:
+ if verbose:
+ print """Cleaning up...
+ Please wait if large files were written."""
+ if mount_hacks:
+ subprocess.call(['umount', os.path.join(destmnt, 'var', 'run')])
+ subprocess.call(['umount', os.path.join(destmnt, 'proc')])
+ if homemnt:
+ call(['/bin/umount', homemnt])
+ call(['/sbin/losetup', '-d', homeloop])
+ if img_type is 'blk':
+ if mntlive:
+ call(['/bin/umount', mntlive])
+ os.rmdir(mntlive)
+ if os.path.ismount(destmnt):
+ call(['/bin/umount', destmnt])
+ if img_type is 'blk':
+ m_cow:
+ call(['/sbin/dmsetup', '--noudevrules', '--noudevsync',
+ 'remove', dm_cow])
+ if overlayloop:
+ call(['/sbin/losetup', '-d', overlayloop])
+ if imgloop:
+ call(['/sbin/losetup', '-d', imgloop])
+ if squashloop:
+ call(['/bin/umount', squashloop])
+ call(['/sbin/losetup', '-d', squashloop])
+ call(['/bin/umount', liveosmnt])
+ if not img_type is 'blk':
+ call(['/sbin/losetup', '-d', liveosloop])
+ os.rmdir(squashmnt)
+ if not os.path.ismount(liveosmnt):
+ os.rmdir(liveosmnt)
+ if verbose:
+ print "Cleanup complete"
sys.exit(ecode)
commit aea37a23dafe3d540a3fd2e463d69e36fa9ba650
Author: Brian C. Lane <bcl(a)redhat.com>
Date: Mon Mar 21 14:24:48 2011 -0700
Fix overzealous boot->BOOT change
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index 3e160e3..8ea2081 100755
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -890,7 +890,7 @@ fi
if [[ live == $srctype ]]; then
targets="$TGTMNT/$SYSLINUXPATH"
[[ -n $efi ]] && targets+=" $TGTMNT$EFI_BOOT"
- [[ -n $xo ]] && targets+=" $TGTMNT/BOOT/olpc.fth"
+ [[ -n $xo ]] && targets+=" $TGTMNT/boot/olpc.fth"
duTable=($(du -c -B 1M $targets 2> /dev/null || :))
tbd=$((tbd + ${duTable[*]: -2:1}))
fi
@@ -922,7 +922,7 @@ if [[ live == $srctype ]]; then
[[ -z $skipcompress ]] && sources+=" $SRCMNT/LiveOS/squashfs.img"
sources+=" $SRCMNT/isolinux $SRCMNT/syslinux"
[[ -n $efi ]] && sources+=" $SRCMNT$EFI_BOOT"
- [[ -n $xo ]] && sources+=" $SRCMNT/BOOT/olpc.fth"
+ [[ -n $xo ]] && sources+=" $SRCMNT/boot/olpc.fth"
duTable=($(du -c -B 1M "$thisScriptpath" $sources 2> /dev/null || :))
livesize=$((livesize + ${duTable[*]: -2:1}))
fi
commit a00fc723389cc9c531d61e5f2c70025da8d67ab4
Author: Frederick Grose <fgrose(a)gmail.com>
Date: Mon Mar 21 14:22:52 2011 -0700
Fix return code failure (#689360)
A runtime zero-valued arithmetic expression returns "FAILURE",
so with the new set -e autoexit setting, the code logic or
command must be adjusted to accommodate.
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index 70e80ba..3e160e3 100755
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -881,7 +881,7 @@ if [[ -d $TGTMNT/$LIVEOS ]]; then
tbd=($(du -B 1M $TGTMNT/$LIVEOS))
if [[ -s $TGTMNT/$LIVEOS/$HOMEFILE ]] && [[ -n $keephome ]]; then
homesize=($(du -B 1M $TGTMNT/$LIVEOS/$HOMEFILE))
- ((tbd -= homesize))
+ tbd=$((tbd - homesize))
fi
else
tbd=0
@@ -892,7 +892,7 @@ if [[ live == $srctype ]]; then
[[ -n $efi ]] && targets+=" $TGTMNT$EFI_BOOT"
[[ -n $xo ]] && targets+=" $TGTMNT/BOOT/olpc.fth"
duTable=($(du -c -B 1M $targets 2> /dev/null || :))
- ((tbd += ${duTable[*]: -2:1}))
+ tbd=$((tbd + ${duTable[*]: -2:1}))
fi
if [[ -n $skipcompress ]] && [[ -s $SRCMNT/LiveOS/squashfs.img ]]; then
@@ -924,7 +924,7 @@ if [[ live == $srctype ]]; then
[[ -n $efi ]] && sources+=" $SRCMNT$EFI_BOOT"
[[ -n $xo ]] && sources+=" $SRCMNT/BOOT/olpc.fth"
duTable=($(du -c -B 1M "$thisScriptpath" $sources 2> /dev/null || :))
- ((livesize += ${duTable[*]: -2:1}))
+ livesize=$((livesize + ${duTable[*]: -2:1}))
fi
freespace=($(df -B 1M --total $TGTDEV))
commit ab97a013c88441a7d6f1e0ac85342f9025e9f6ae
Author: Frederick Grose <fgrose(a)gmail.com>
Date: Mon Mar 21 14:09:49 2011 -0700
Fix pipefailure in checkSyslinuxVersion (#689329)
Use a list operation to bypass the erroneous return value.
Alter the test to something that could be used to check the
syslinux version, if desired.
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index deb5473..70e80ba 100755
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -559,7 +559,8 @@ checkSyslinuxVersion() {
echo "You need to have syslinux installed to run this script"
exit 1
fi
- if ! syslinux 2>&1 | grep -qe -d; then
+ check=($(syslinux --version 2>&1)) || :
+ if [[ 'syslinux' == $check ]]; then
SYSLINUXPATH=""
elif [ -n "$multi" ]; then
SYSLINUXPATH="$LIVEOS/syslinux"
@@ -1006,7 +1007,6 @@ fi
[ -n "$efi" -a ! -d $TGTMNT$EFI_BOOT ] && mkdir -p $TGTMNT$EFI_BOOT
# Live image copy
-set -o pipefail
if [ "$srctype" = "live" -a -z "$skipcopy" ]; then
echo "Copying live image to target device."
[ ! -d $TGTMNT/$LIVEOS ] && mkdir $TGTMNT/$LIVEOS
12 years
tools/livecd-iso-to-disk.sh
by Brian C. Lane
tools/livecd-iso-to-disk.sh | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
New commits:
commit 74434baadbfeb9c3407a2a673c7e5a0f1c18834b
Author: Brian C. Lane <bcl(a)redhat.com>
Date: Tue Mar 22 11:00:04 2011 -0700
Check for spaces in fs label when using overlay (#597599)
Spaces don't work in the overlay filename, don't allow them.
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index b48dd79..088188b 100755
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -821,11 +821,17 @@ checkSyslinuxVersion
checkMBR $TGTDEV
-if [ "$overlaysizemb" -gt 0 -a "$TGTFS" = "vfat" ]; then
- if [ "$overlaysizemb" -gt 2047 ]; then
+if [ "$overlaysizemb" -gt 0 ]; then
+ if [ "$TGTFS" = "vfat" -a "$overlaysizemb" -gt 2047 ]; then
echo "Can't have an overlay of 2048MB or greater on VFAT"
exitclean
fi
+ LABEL=$(/sbin/blkid -s LABEL -o value $TGTDEV)
+ if [[ "$LABEL" =~ ( ) ]]; then
+ echo "The LABEL($LABEL) on $TGTDEV has spaces in it, which not work with the overlay"
+ echo "You can re-format or use dosfslabel/e2fslabel to change it"
+ exitclean
+ fi
fi
if [ "$homesizemb" -gt 0 -a "$TGTFS" = "vfat" ]; then
12 years
tools/livecd-iso-to-disk.sh
by Brian C. Lane
tools/livecd-iso-to-disk.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 3abe55a265e2059bbbcb06994e75c4c08c81f7c9
Author: Brian C. Lane <bcl(a)redhat.com>
Date: Tue Mar 22 09:52:03 2011 -0700
Fix logic for syslinux check
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index 8ea2081..b48dd79 100755
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -560,7 +560,7 @@ checkSyslinuxVersion() {
exit 1
fi
check=($(syslinux --version 2>&1)) || :
- if [[ 'syslinux' == $check ]]; then
+ if [[ 'syslinux' != $check ]]; then
SYSLINUXPATH=""
elif [ -n "$multi" ]; then
SYSLINUXPATH="$LIVEOS/syslinux"
12 years