Branch 'f17-branch' - 2 commits - imgcreate/live.py tools/edit-livecd tools/livecd-iso-to-disk.sh
by Brian C. Lane
imgcreate/live.py | 58 ++++++++++++++++++++++++++++++--------------
tools/edit-livecd | 4 +--
tools/livecd-iso-to-disk.sh | 2 -
3 files changed, 43 insertions(+), 21 deletions(-)
New commits:
commit eab4dcca46a17cd31c74c558665a5d7b9d328f4a
Author: Matthew Garrett <mjg(a)redhat.com>
Date: Wed Feb 29 14:57:58 2012 -0500
Change EFI/boot to EFI/BOOT
Fix this up for consistency with other build tools
diff --git a/imgcreate/live.py b/imgcreate/live.py
index 685a306..adcf34f 100755
--- a/imgcreate/live.py
+++ b/imgcreate/live.py
@@ -231,9 +231,9 @@ class LiveImageCreatorBase(LoopImageCreator):
"""Generate EFI boot images."""
if not os.path.exists(self._instroot + "/boot/efi/EFI/redhat/grub.efi"):
return False
- subprocess.call(["mkefiboot", isodir + "/EFI/boot",
+ subprocess.call(["mkefiboot", isodir + "/EFI/BOOT",
isodir + "/isolinux/efiboot.img"])
- subprocess.call(["mkefiboot", "-a", isodir + "/EFI/boot",
+ subprocess.call(["mkefiboot", "-a", isodir + "/EFI/BOOT",
isodir + "/isolinux/macboot.img"])
def _create_bootconfig(self):
@@ -690,19 +690,19 @@ menu end
if not os.path.exists(self._instroot + "/boot/efi/EFI/redhat/grub.efi"):
return False
shutil.copy(self._instroot + "/boot/efi/EFI/redhat/grub.efi",
- isodir + "/EFI/boot/grub.efi")
+ isodir + "/EFI/BOOT/grub.efi")
# 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")
+ isodir + "/EFI/BOOT/splash.xpm.gz")
return True
def __get_basic_efi_config(self, **args):
return """
default=0
-splashimage=/EFI/boot/splash.xpm.gz
+splashimage=/EFI/BOOT/splash.xpm.gz
timeout %(timeout)d
hiddenmenu
@@ -715,8 +715,8 @@ hiddenmenu
args["rootlabel"] = "CDLABEL=%(fslabel)s" % args
return """title %(long)s
findiso
- kernel /EFI/boot/vmlinuz%(index)s root=%(rootlabel)s rootfstype=%(isofstype)s %(liveargs)s %(extra)s
- initrd /EFI/boot/initrd%(index)s.img
+ kernel /EFI/BOOT/vmlinuz%(index)s root=%(rootlabel)s rootfstype=%(isofstype)s %(liveargs)s %(extra)s
+ initrd /EFI/BOOT/initrd%(index)s.img
""" %args
def __get_efi_image_stanzas(self, isodir, name):
@@ -729,7 +729,7 @@ hiddenmenu
for index in range(0, 9):
# we don't support xen kernels
- if os.path.exists("%s/EFI/boot/xen%d.gz" %(isodir, index)):
+ if os.path.exists("%s/EFI/BOOT/xen%d.gz" %(isodir, index)):
continue
cfg += self.__get_efi_image_stanza(fslabel = self.fslabel,
isofstype = "auto",
@@ -749,7 +749,7 @@ hiddenmenu
def _configure_efi_bootloader(self, isodir):
"""Set up the configuration for an EFI bootloader"""
- makedirs(isodir + "/EFI/boot")
+ makedirs(isodir + "/EFI/BOOT")
if not self.__copy_efi_files(isodir):
shutil.rmtree(isodir + "/EFI")
@@ -757,27 +757,27 @@ hiddenmenu
for f in os.listdir(isodir + "/isolinux"):
os.link("%s/isolinux/%s" %(isodir, f),
- "%s/EFI/boot/%s" %(isodir, f))
+ "%s/EFI/BOOT/%s" %(isodir, f))
cfg = self.__get_basic_efi_config(name = self.name,
timeout = self._timeout)
cfg += self.__get_efi_image_stanzas(isodir, self.name)
- cfgf = open(isodir + "/EFI/boot/grub.conf", "w")
+ cfgf = open(isodir + "/EFI/BOOT/grub.conf", "w")
cfgf.write(cfg)
cfgf.close()
# first gen mactel machines get the bootloader name wrong apparently
if rpmUtils.arch.getBaseArch() == "i386":
- os.link(isodir + "/EFI/boot/grub.efi", isodir + "/EFI/boot/boot.efi")
- os.link(isodir + "/EFI/boot/grub.conf", isodir + "/EFI/boot/boot.conf")
+ os.link(isodir + "/EFI/BOOT/grub.efi", isodir + "/EFI/BOOT/BOOT.efi")
+ os.link(isodir + "/EFI/BOOT/grub.conf", isodir + "/EFI/BOOT/BOOT.conf")
# for most things, we want them named boot$efiarch
efiarch = {"i386": "ia32", "x86_64": "x64"}
efiname = efiarch[rpmUtils.arch.getBaseArch()]
- os.rename(isodir + "/EFI/boot/grub.efi", isodir + "/EFI/boot/boot%s.efi" %(efiname,))
- os.link(isodir + "/EFI/boot/grub.conf", isodir + "/EFI/boot/boot%s.conf" %(efiname,))
+ os.rename(isodir + "/EFI/BOOT/grub.efi", isodir + "/EFI/BOOT/BOOT%s.efi" %(efiname,))
+ os.link(isodir + "/EFI/BOOT/grub.conf", isodir + "/EFI/BOOT/BOOT%s.conf" %(efiname,))
def _configure_bootloader(self, isodir):
diff --git a/tools/edit-livecd b/tools/edit-livecd
index 0df2fa8..948064b 100755
--- a/tools/edit-livecd
+++ b/tools/edit-livecd
@@ -640,9 +640,9 @@ def get_fsvalue(filesystem, tag):
def rebuild_iso_symlinks(isodir):
# remove duplicate files and rebuild symlinks to reduce iso size
- efi_vmlinuz = "%s/EFI/boot/vmlinuz0" % isodir
+ efi_vmlinuz = "%s/EFI/BOOT/vmlinuz0" % isodir
isolinux_vmlinuz = "%s/isolinux/vmlinuz0" % isodir
- efi_initrd = "%s/EFI/boot/initrd0.img" % isodir
+ efi_initrd = "%s/EFI/BOOT/initrd0.img" % isodir
isolinux_initrd = "%s/isolinux/initrd0.img" % isodir
if os.path.exists(efi_vmlinuz):
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index 3ae88a2..db57067 100755
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -1397,7 +1397,7 @@ if [ -z "$multi" ]; then
echo "Installing boot loader"
if [ -n "$efi" ]; then
# replace the ia32 hack
- if [ -f "$TGTMNT$EFI_BOOT/boot.conf" ]; then
+ if [ -f "$TGTMNT$EFI_BOOT/BOOT.conf" ]; then
cp -f $TGTMNT$EFI_BOOT/BOOTia32.conf $TGTMNT$EFI_BOOT/BOOT.conf
fi
fi
commit 135df7dd03a354d456c993dfd3ca0455ab5b8987
Author: Matthew Garrett <mjg(a)redhat.com>
Date: Wed Feb 29 14:57:57 2012 -0500
Add support for generating EFI-bootable hybrid images
This patch adds support for generating efiboot and macboot images, passing
them to the ISO generation and then performing the appropriate isohybrid
call.
diff --git a/imgcreate/live.py b/imgcreate/live.py
index 7eefbc3..685a306 100755
--- a/imgcreate/live.py
+++ b/imgcreate/live.py
@@ -227,9 +227,19 @@ class LiveImageCreatorBase(LoopImageCreator):
self.__isodir = self._mkdtemp("iso-")
return self.__isodir
+ def _generate_efiboot(self, isodir):
+ """Generate EFI boot images."""
+ if not os.path.exists(self._instroot + "/boot/efi/EFI/redhat/grub.efi"):
+ return False
+ subprocess.call(["mkefiboot", isodir + "/EFI/boot",
+ isodir + "/isolinux/efiboot.img"])
+ subprocess.call(["mkefiboot", "-a", isodir + "/EFI/boot",
+ isodir + "/isolinux/macboot.img"])
+
def _create_bootconfig(self):
"""Configure the image so that it's bootable."""
self._configure_bootloader(self.__ensure_isodir())
+ self._generate_efiboot(self.__ensure_isodir())
def _get_post_scripts_env(self, in_chroot):
env = LoopImageCreator._get_post_scripts_env(self, in_chroot)
@@ -305,7 +315,10 @@ class LiveImageCreatorBase(LoopImageCreator):
raise CreatorError("ISO creation failed!")
if os.path.exists("/usr/bin/isohybrid"):
- subprocess.call(["/usr/bin/isohybrid", iso])
+ if os.path.exists(isodir + "/isolinux/efiboot.img"):
+ subprocess.call(["/usr/bin/isohybrid", "-u", "-m", iso])
+ else:
+ subprocess.call(["/usr/bin/isohybrid", iso])
self.__implant_md5sum(iso)
@@ -358,10 +371,18 @@ class LiveImageCreatorBase(LoopImageCreator):
class x86LiveImageCreator(LiveImageCreatorBase):
"""ImageCreator for x86 machines"""
def _get_mkisofs_options(self, isodir):
- return [ "-b", "isolinux/isolinux.bin",
- "-c", "isolinux/boot.cat",
- "-no-emul-boot", "-boot-info-table",
- "-boot-load-size", "4" ]
+ options = [ "-b", "isolinux/isolinux.bin",
+ "-c", "isolinux/boot.cat",
+ "-no-emul-boot", "-boot-info-table",
+ "-boot-load-size", "4" ]
+ if os.path.exists(isodir + "/isolinux/efiboot.img"):
+ options.extend([ "-eltorito-alt-boot",
+ "-e", "isolinux/efiboot.img",
+ "-no-emul-boot",
+ "-eltorito-alt-boot",
+ "-e", "isolinux/macboot.img",
+ "-no-emul-boot"])
+ return options
def _get_required_packages(self):
return ["syslinux"] + LiveImageCreatorBase._get_required_packages(self)
@@ -693,6 +714,7 @@ hiddenmenu
else:
args["rootlabel"] = "CDLABEL=%(fslabel)s" % args
return """title %(long)s
+ findiso
kernel /EFI/boot/vmlinuz%(index)s root=%(rootlabel)s rootfstype=%(isofstype)s %(liveargs)s %(extra)s
initrd /EFI/boot/initrd%(index)s.img
""" %args
11 years, 7 months
2 commits - imgcreate/live.py tools/edit-livecd tools/livecd-iso-to-disk.sh
by Brian C. Lane
imgcreate/live.py | 58 ++++++++++++++++++++++++++++++--------------
tools/edit-livecd | 4 +--
tools/livecd-iso-to-disk.sh | 2 -
3 files changed, 43 insertions(+), 21 deletions(-)
New commits:
commit 36d9750c974dfa0202978102cf281d52fc1a9ff2
Author: Matthew Garrett <mjg(a)redhat.com>
Date: Wed Feb 29 14:57:58 2012 -0500
Change EFI/boot to EFI/BOOT
Fix this up for consistency with other build tools
diff --git a/imgcreate/live.py b/imgcreate/live.py
index 685a306..adcf34f 100755
--- a/imgcreate/live.py
+++ b/imgcreate/live.py
@@ -231,9 +231,9 @@ class LiveImageCreatorBase(LoopImageCreator):
"""Generate EFI boot images."""
if not os.path.exists(self._instroot + "/boot/efi/EFI/redhat/grub.efi"):
return False
- subprocess.call(["mkefiboot", isodir + "/EFI/boot",
+ subprocess.call(["mkefiboot", isodir + "/EFI/BOOT",
isodir + "/isolinux/efiboot.img"])
- subprocess.call(["mkefiboot", "-a", isodir + "/EFI/boot",
+ subprocess.call(["mkefiboot", "-a", isodir + "/EFI/BOOT",
isodir + "/isolinux/macboot.img"])
def _create_bootconfig(self):
@@ -690,19 +690,19 @@ menu end
if not os.path.exists(self._instroot + "/boot/efi/EFI/redhat/grub.efi"):
return False
shutil.copy(self._instroot + "/boot/efi/EFI/redhat/grub.efi",
- isodir + "/EFI/boot/grub.efi")
+ isodir + "/EFI/BOOT/grub.efi")
# 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")
+ isodir + "/EFI/BOOT/splash.xpm.gz")
return True
def __get_basic_efi_config(self, **args):
return """
default=0
-splashimage=/EFI/boot/splash.xpm.gz
+splashimage=/EFI/BOOT/splash.xpm.gz
timeout %(timeout)d
hiddenmenu
@@ -715,8 +715,8 @@ hiddenmenu
args["rootlabel"] = "CDLABEL=%(fslabel)s" % args
return """title %(long)s
findiso
- kernel /EFI/boot/vmlinuz%(index)s root=%(rootlabel)s rootfstype=%(isofstype)s %(liveargs)s %(extra)s
- initrd /EFI/boot/initrd%(index)s.img
+ kernel /EFI/BOOT/vmlinuz%(index)s root=%(rootlabel)s rootfstype=%(isofstype)s %(liveargs)s %(extra)s
+ initrd /EFI/BOOT/initrd%(index)s.img
""" %args
def __get_efi_image_stanzas(self, isodir, name):
@@ -729,7 +729,7 @@ hiddenmenu
for index in range(0, 9):
# we don't support xen kernels
- if os.path.exists("%s/EFI/boot/xen%d.gz" %(isodir, index)):
+ if os.path.exists("%s/EFI/BOOT/xen%d.gz" %(isodir, index)):
continue
cfg += self.__get_efi_image_stanza(fslabel = self.fslabel,
isofstype = "auto",
@@ -749,7 +749,7 @@ hiddenmenu
def _configure_efi_bootloader(self, isodir):
"""Set up the configuration for an EFI bootloader"""
- makedirs(isodir + "/EFI/boot")
+ makedirs(isodir + "/EFI/BOOT")
if not self.__copy_efi_files(isodir):
shutil.rmtree(isodir + "/EFI")
@@ -757,27 +757,27 @@ hiddenmenu
for f in os.listdir(isodir + "/isolinux"):
os.link("%s/isolinux/%s" %(isodir, f),
- "%s/EFI/boot/%s" %(isodir, f))
+ "%s/EFI/BOOT/%s" %(isodir, f))
cfg = self.__get_basic_efi_config(name = self.name,
timeout = self._timeout)
cfg += self.__get_efi_image_stanzas(isodir, self.name)
- cfgf = open(isodir + "/EFI/boot/grub.conf", "w")
+ cfgf = open(isodir + "/EFI/BOOT/grub.conf", "w")
cfgf.write(cfg)
cfgf.close()
# first gen mactel machines get the bootloader name wrong apparently
if rpmUtils.arch.getBaseArch() == "i386":
- os.link(isodir + "/EFI/boot/grub.efi", isodir + "/EFI/boot/boot.efi")
- os.link(isodir + "/EFI/boot/grub.conf", isodir + "/EFI/boot/boot.conf")
+ os.link(isodir + "/EFI/BOOT/grub.efi", isodir + "/EFI/BOOT/BOOT.efi")
+ os.link(isodir + "/EFI/BOOT/grub.conf", isodir + "/EFI/BOOT/BOOT.conf")
# for most things, we want them named boot$efiarch
efiarch = {"i386": "ia32", "x86_64": "x64"}
efiname = efiarch[rpmUtils.arch.getBaseArch()]
- os.rename(isodir + "/EFI/boot/grub.efi", isodir + "/EFI/boot/boot%s.efi" %(efiname,))
- os.link(isodir + "/EFI/boot/grub.conf", isodir + "/EFI/boot/boot%s.conf" %(efiname,))
+ os.rename(isodir + "/EFI/BOOT/grub.efi", isodir + "/EFI/BOOT/BOOT%s.efi" %(efiname,))
+ os.link(isodir + "/EFI/BOOT/grub.conf", isodir + "/EFI/BOOT/BOOT%s.conf" %(efiname,))
def _configure_bootloader(self, isodir):
diff --git a/tools/edit-livecd b/tools/edit-livecd
index 0df2fa8..948064b 100755
--- a/tools/edit-livecd
+++ b/tools/edit-livecd
@@ -640,9 +640,9 @@ def get_fsvalue(filesystem, tag):
def rebuild_iso_symlinks(isodir):
# remove duplicate files and rebuild symlinks to reduce iso size
- efi_vmlinuz = "%s/EFI/boot/vmlinuz0" % isodir
+ efi_vmlinuz = "%s/EFI/BOOT/vmlinuz0" % isodir
isolinux_vmlinuz = "%s/isolinux/vmlinuz0" % isodir
- efi_initrd = "%s/EFI/boot/initrd0.img" % isodir
+ efi_initrd = "%s/EFI/BOOT/initrd0.img" % isodir
isolinux_initrd = "%s/isolinux/initrd0.img" % isodir
if os.path.exists(efi_vmlinuz):
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index 3ae88a2..db57067 100755
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -1397,7 +1397,7 @@ if [ -z "$multi" ]; then
echo "Installing boot loader"
if [ -n "$efi" ]; then
# replace the ia32 hack
- if [ -f "$TGTMNT$EFI_BOOT/boot.conf" ]; then
+ if [ -f "$TGTMNT$EFI_BOOT/BOOT.conf" ]; then
cp -f $TGTMNT$EFI_BOOT/BOOTia32.conf $TGTMNT$EFI_BOOT/BOOT.conf
fi
fi
commit e4d1c7ef9796930bc42e91046b8720422c60c742
Author: Matthew Garrett <mjg(a)redhat.com>
Date: Wed Feb 29 14:57:57 2012 -0500
Add support for generating EFI-bootable hybrid images
This patch adds support for generating efiboot and macboot images, passing
them to the ISO generation and then performing the appropriate isohybrid
call.
diff --git a/imgcreate/live.py b/imgcreate/live.py
index 7eefbc3..685a306 100755
--- a/imgcreate/live.py
+++ b/imgcreate/live.py
@@ -227,9 +227,19 @@ class LiveImageCreatorBase(LoopImageCreator):
self.__isodir = self._mkdtemp("iso-")
return self.__isodir
+ def _generate_efiboot(self, isodir):
+ """Generate EFI boot images."""
+ if not os.path.exists(self._instroot + "/boot/efi/EFI/redhat/grub.efi"):
+ return False
+ subprocess.call(["mkefiboot", isodir + "/EFI/boot",
+ isodir + "/isolinux/efiboot.img"])
+ subprocess.call(["mkefiboot", "-a", isodir + "/EFI/boot",
+ isodir + "/isolinux/macboot.img"])
+
def _create_bootconfig(self):
"""Configure the image so that it's bootable."""
self._configure_bootloader(self.__ensure_isodir())
+ self._generate_efiboot(self.__ensure_isodir())
def _get_post_scripts_env(self, in_chroot):
env = LoopImageCreator._get_post_scripts_env(self, in_chroot)
@@ -305,7 +315,10 @@ class LiveImageCreatorBase(LoopImageCreator):
raise CreatorError("ISO creation failed!")
if os.path.exists("/usr/bin/isohybrid"):
- subprocess.call(["/usr/bin/isohybrid", iso])
+ if os.path.exists(isodir + "/isolinux/efiboot.img"):
+ subprocess.call(["/usr/bin/isohybrid", "-u", "-m", iso])
+ else:
+ subprocess.call(["/usr/bin/isohybrid", iso])
self.__implant_md5sum(iso)
@@ -358,10 +371,18 @@ class LiveImageCreatorBase(LoopImageCreator):
class x86LiveImageCreator(LiveImageCreatorBase):
"""ImageCreator for x86 machines"""
def _get_mkisofs_options(self, isodir):
- return [ "-b", "isolinux/isolinux.bin",
- "-c", "isolinux/boot.cat",
- "-no-emul-boot", "-boot-info-table",
- "-boot-load-size", "4" ]
+ options = [ "-b", "isolinux/isolinux.bin",
+ "-c", "isolinux/boot.cat",
+ "-no-emul-boot", "-boot-info-table",
+ "-boot-load-size", "4" ]
+ if os.path.exists(isodir + "/isolinux/efiboot.img"):
+ options.extend([ "-eltorito-alt-boot",
+ "-e", "isolinux/efiboot.img",
+ "-no-emul-boot",
+ "-eltorito-alt-boot",
+ "-e", "isolinux/macboot.img",
+ "-no-emul-boot"])
+ return options
def _get_required_packages(self):
return ["syslinux"] + LiveImageCreatorBase._get_required_packages(self)
@@ -693,6 +714,7 @@ hiddenmenu
else:
args["rootlabel"] = "CDLABEL=%(fslabel)s" % args
return """title %(long)s
+ findiso
kernel /EFI/boot/vmlinuz%(index)s root=%(rootlabel)s rootfstype=%(isofstype)s %(liveargs)s %(extra)s
initrd /EFI/boot/initrd%(index)s.img
""" %args
11 years, 7 months
[PATCH] livecd-iso-to-disk - Restore capability to load the running image
by Frederick Grose
This apparently has been broken since 15 Feb 2011 with commit
5e8c294abe448bc15839c7781174ea9b7156228b.
Sorry for not noticing sooner.
commit 357799425eefea9599c559c8e001f33bdd52f4cb
Author: Frederick Grose <fgrose(a)sugarlabs.org>
Date: Sun Feb 26 20:05:42 2012 -0800
Restore capability to load the running LiveOS image.
If the source is /dev/live or /dev/sr0, mount it on a loop device.
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index 3ae88a2..3b1add8 100755
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -906,13 +906,15 @@ fi
# do some basic sanity checks.
checkMounted $TGTDEV
-
# FIXME: would be better if we had better mountpoints
SRCMNT=$(mktemp -d /media/srctmp.XXXXXX)
-if [ -b "$SRC" ]; then
- mount -o ro "$SRC" $SRCMNT || exitclean
-elif [ -f "$SRC" ]; then
+if [[ -f $SRC || /dev/live == $1 || /dev/sr0 == $1 ]]; then
mount -o loop,ro "$SRC" $SRCMNT || exitclean
+ imgtype='iso'
+ [[ /dev/live == $1 ]] && imgtype='live'
+elif [[ -b $SRC ]]; then
+ mount -o ro "$SRC" $SRCMNT || exitclean
+ imgtype='blk'
else
echo "$SRC is not a file or block device."
exitclean
11 years, 7 months
tools/livecd-iso-to-disk.sh
by Brian C. Lane
tools/livecd-iso-to-disk.sh | 248 ++++++++++++++++++++++++++++++--------------
1 file changed, 171 insertions(+), 77 deletions(-)
New commits:
commit c0477e593a8c1660dc497e893c61604f73a48ef2
Author: Brian C. Lane <bcl(a)redhat.com>
Date: Tue Feb 21 14:55:51 2012 -0800
livecd-iso-to-disk: create partition for iso
In Fedora 17 the installer runs from the squashfs.img on the install
media. This means that the installer environment doesn't have direct
access to the install media, and it cannot mount it.
In order to support writing DVD's to USB sticks we now need to create a
second partition just for the .iso image and direct the installer to it
using the repo=UUID=... command
This patch adds creating the 2nd partition if needed and also cleans up
some of the bootloader config editing code.
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index 2db2903..3ae88a2 100755
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -1,7 +1,9 @@
#!/bin/bash
# Transfer a Live image so that it's bootable off of a USB/SD device.
-# Copyright 2007 Red Hat, Inc.
+# Copyright 2007-2012 Red Hat, Inc.
+#
# Jeremy Katz <katzj(a)redhat.com>
+# Brian C. Lane <bcl(a)redhat.com>
#
# overlay/persistence enhancements by Douglas McClendon <dmc(a)viros.org>
# GPT+MBR hybrid enhancements by Stewart Adam <s.adam(a)diffingo.com>
@@ -274,11 +276,14 @@ cleanup() {
sleep 2
[ -d "$SRCMNT" ] && umount $SRCMNT && rmdir $SRCMNT
[ -d "$TGTMNT" ] && umount $TGTMNT && rmdir $TGTMNT
+ if [ -n "$REPOMNT" ]; then
+ [ -d "$REPOMNT" ] && umount $REPOMNT && rmdir $REPOMNT
+ fi
}
exitclean() {
RETVAL=$?
- if [ -d "$SRCMNT" ] || [ -d "$TGTMNT" ];
+ if [ -d "$SRCMNT" ] || [ -d "$TGTMNT" ] || [ -n "$REPOMNT" ];
then
[ "$RETVAL" = 0 ] || echo "Cleaning up to exit..."
cleanup
@@ -319,13 +324,6 @@ getdisk() {
partnum=${p##$device}
}
-getpartition() {
- DEV=$1
- pa=$( < /proc/partitions )
- pa=${pa##*$DEV}
- partnum=${pa%% *}
-}
-
resetMBR() {
if isdevloop "$DEV"; then
return
@@ -423,18 +421,47 @@ createGPTLayout() {
umount ${device}* &> /dev/null || :
wipefs -a ${device}
/sbin/parted --script $device mklabel gpt
- partinfo=$(LC_ALL=C /sbin/parted --script -m $device "unit b print" |grep ^$device:)
- size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/B$//')
- /sbin/parted --script $device unit b mkpart '"EFI System Partition"' fat32 1048576 $(($size - 1048576)) set 1 boot on
+ partinfo=$(LC_ALL=C /sbin/parted --script -m $device "unit MB print" |grep ^$device:)
+ dev_size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/MB$//')
+
+ # Is a 2nd partition needed for package iso?
+ if [ -n "$packages" ]; then
+ src_size=$(du -s -B 1MB "$SRC" | awk {'print $1;'})
+ # iso size + 7% of slop for filesystem metadata
+ p2_size=$(($src_size * 107 / 100))
+ else
+ p2_size=0
+ fi
+ p1_size=$(($dev_size - 1 - $p2_size))
+
+ if [ $p1_size -le 0 ]; then
+ echo "Your device isn't big enough to hold $SRC"
+ echo "It is $(($p1_size * -1)) MB too small"
+ exitclean
+ fi
+ p1_start=1
+ p1_end=$(($p1_size + 1))
+ /sbin/parted -s $device u MB mkpart '"EFI System Partition"' fat32 $p1_start $p1_end set 1 boot on
+ if [ $p2_size -gt 0 ]; then
+ p2_start=$p1_end
+ p2_end=$(($p2_size + $p2_start))
+ /sbin/parted -s $device u MB mkpart '"LIVE REPO"' fat32 $p2_start $p2_end
+ fi
# Sometimes automount can be _really_ annoying.
echo "Waiting for devices to settle..."
/sbin/udevadm settle
sleep 5
- getpartition ${device#/dev/}
- TGTDEV=${device}${partnum}
+ TGTDEV=${device}1
umount $TGTDEV &> /dev/null || :
/sbin/mkdosfs -n LIVE $TGTDEV
TGTLABEL="UUID=$(/sbin/blkid -s UUID -o value $TGTDEV)"
+
+ if [ $p2_size -gt 0 ]; then
+ REPODEV=${device}2
+ umount $REPODEV &> /dev/null || :
+ /sbin/mkdosfs -n LIVE-REPO $REPODEV
+ REPOLABEL="UUID=$(/sbin/blkid -s UUID -o value $REPODEV)"
+ fi
}
createMSDOSLayout() {
@@ -447,22 +474,51 @@ createMSDOSLayout() {
umount ${device}* &> /dev/null || :
wipefs -a ${device}
/sbin/parted --script $device mklabel msdos
- partinfo=$(LC_ALL=C /sbin/parted --script -m $device "unit b print" |grep ^$device:)
- size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/B$//')
- /sbin/parted --script $device unit b mkpart primary fat32 1048576 $(($size - 1048576)) set 1 boot on
+ partinfo=$(LC_ALL=C /sbin/parted --script -m $device "unit MB print" |grep ^$device:)
+ dev_size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/MB$//')
+
+ # Is a 2nd partition needed for package iso?
+ if [ -n "$packages" ]; then
+ src_size=$(du -s -B 1MB "$SRC" | awk {'print $1;'})
+ # iso size + 7% of slop for filesystem metadata
+ p2_size=$(($src_size * 107 / 100))
+ else
+ p2_size=0
+ fi
+ p1_size=$(($dev_size - 1 - $p2_size))
+
+ if [ $p1_size -le 0 ]; then
+ echo "Your device isn't big enough to hold $SRC"
+ echo "It is $(($p1_size * -1)) MB too small"
+ exitclean
+ fi
+ p1_start=1
+ p1_end=$(($p1_size + 1))
+ /sbin/parted -s $device u MB mkpart primary fat32 $p1_start $p1_end set 1 boot on
+ if [ $p2_size -gt 0 ]; then
+ p2_start=$p1_end
+ p2_end=$(($p2_size + $p2_start))
+ /sbin/parted -s $device u MB mkpart primary fat32 $p2_start $p2_end
+ fi
# Sometimes automount can be _really_ annoying.
echo "Waiting for devices to settle..."
/sbin/udevadm settle
sleep 5
if ! isdevloop "$DEV"; then
- getpartition ${device#/dev/}
- TGTDEV=${device}${partnum}
+ TGTDEV=${device}1
else
TGTDEV=${device}
fi
umount $TGTDEV &> /dev/null || :
/sbin/mkdosfs -n LIVE $TGTDEV
TGTLABEL="UUID=$(/sbin/blkid -s UUID -o value $TGTDEV)"
+
+ if [ $p2_size -gt 0 ]; then
+ REPODEV=${device}2
+ umount $REPODEV &> /dev/null || :
+ /sbin/mkdosfs -n LIVE-REPO $REPODEV
+ REPOLABEL="UUID=$(/sbin/blkid -s UUID -o value $REPODEV)"
+ fi
}
createEXTFSLayout() {
@@ -474,25 +530,55 @@ createEXTFSLayout() {
read
umount ${device}* &> /dev/null || :
wipefs -a ${device}
- /sbin/parted --script $device mklabel msdos
- partinfo=$(LC_ALL=C /sbin/parted --script -m $device "unit b print" |grep ^$device:)
- size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/B$//')
- /sbin/parted --script $device unit b mkpart primary ext2 1048576 $(($size - 1048576)) set 1 boot on
+ /sbin/parted -s $device mklabel msdos
+ partinfo=$(LC_ALL=C /sbin/parted -s -m $device "u MB print" |grep ^$device:)
+ dev_size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/MB$//')
+
+ # Is a 2nd partition needed for package iso?
+ if [ -n "$packages" ]; then
+ src_size=$(du -s -B 1MB "$SRC" | awk {'print $1;'})
+ # iso size + 7% of slop for filesystem metadata
+ p2_size=$(($src_size * 107 / 100))
+ else
+ p2_size=0
+ fi
+ p1_size=$(($dev_size - 1 - $p2_size))
+
+ if [ $p1_size -le 0 ]; then
+ echo "Your device isn't big enough to hold $SRC"
+ echo "It is $(($p1_size * -1)) MB too small"
+ exitclean
+ fi
+ p1_start=1
+ p1_end=$(($p1_size + 1))
+ /sbin/parted -s $device u MB mkpart primary ext2 $p1_start $p1_end set 1 boot on
+ if [ $p2_size -gt 0 ]; then
+ p2_start=$p1_end
+ p2_end=$(($p2_size + $p2_start))
+ /sbin/parted -s $device u MB mkpart primary ext2 $p2_start $p2_end
+ fi
# Sometimes automount can be _really_ annoying.
echo "Waiting for devices to settle..."
/sbin/udevadm settle
sleep 5
- getpartition ${device#/dev/}
- TGTDEV=${device}${partnum}
+ TGTDEV=${device}1
umount $TGTDEV &> /dev/null || :
# Check extlinux version
if extlinux -v 2>&1 | grep -q 'extlinux 3'; then
- /sbin/mkfs.ext3 -L LIVE $TGTDEV
+ mkfs=/sbin/mkfs.ext3
else
- /sbin/mkfs.ext4 -L LIVE $TGTDEV
+ mkfs=/sbin/mkfs.ext4
fi
+ $mkfs -L LIVE $TGTDEV
TGTLABEL="UUID=$(/sbin/blkid -s UUID -o value $TGTDEV)"
+
+ if [ $p2_size -gt 0 ]; then
+ REPODEV=${device}2
+ umount $REPODEV &> /dev/null || :
+ $mkfs -L LIVE-REPO $REPODEV
+ REPOLABEL="UUID=$(/sbin/blkid -s UUID -o value $REPODEV)"
+ fi
}
checkGPT() {
@@ -607,17 +693,24 @@ if [ $(id -u) != 0 ]; then
fi
detectsrctype() {
- if [[ -e $SRCMNT/LiveOS/squashfs.img ]]; then
+ if [[ -e "$SRCMNT/Packages" ]]; then
+ # This will cause the source .iso to be copied to a second partiton
+ # on the target and the boot args to have repo=... pointing to the iso
+ echo "/Packages found, will copy source .iso to target"
+ packages=1
+ fi
+ if [[ -e "$SRCMNT/LiveOS/squashfs.img" ]]; then
+ # LiveOS style boot image
srctype=live
return
fi
if [ -e $SRCMNT/images/install.img -o $SRCMNT/isolinux/initrd.img ]; then
- imgtype=install
- if [ -e $SRCMNT/Packages ]; then
+ if [ -n "$packages" ]; then
srctype=installer
else
srctype=netinst
fi
+ imgtype=install
if [ ! -e $SRCMNT/images/install.img ]; then
echo "$SRC uses initrd.img w/o install.img"
imgtype=initrd
@@ -674,6 +767,7 @@ swapsizemb=0
overlaysizemb=0
srctype=
imgtype=
+packages=
LIVEOS=LiveOS
HOMEFILE="home.img"
@@ -813,6 +907,19 @@ fi
# do some basic sanity checks.
checkMounted $TGTDEV
+# FIXME: would be better if we had better mountpoints
+SRCMNT=$(mktemp -d /media/srctmp.XXXXXX)
+if [ -b "$SRC" ]; then
+ mount -o ro "$SRC" $SRCMNT || exitclean
+elif [ -f "$SRC" ]; then
+ mount -o loop,ro "$SRC" $SRCMNT || exitclean
+else
+ echo "$SRC is not a file or block device."
+ exitclean
+fi
+# Figure out what needs to be done based on the source image
+detectsrctype
+
# Format the device
if [ -n "$format" -a -z "$skipcopy" ]; then
checkLVM $TGTDEV
@@ -865,23 +972,15 @@ if [ "$swapsizemb" -gt 0 -a "$TGTFS" = "vfat" ]; then
fi
fi
-# FIXME: would be better if we had better mountpoints
-SRCMNT=$(mktemp -d /media/srctmp.XXXXXX)
-if [ -b "$SRC" ]; then
- mount -o ro "$SRC" $SRCMNT || exitclean
-elif [ -f "$SRC" ]; then
- mount -o loop,ro "$SRC" $SRCMNT || exitclean
-else
- echo "$SRC is not a file or block device."
- exitclean
-fi
TGTMNT=$(mktemp -d /media/tgttmp.XXXXXX)
mount $mountopts $TGTDEV $TGTMNT || exitclean
+if [ -n "$REPODEV" ]; then
+ REPOMNT=$(mktemp -d /media/repotmp.XXXXXX)
+ mount $mountopts $REPODEV $REPOMNT || exitclean
+fi
trap exitclean SIGINT SIGTERM
-detectsrctype
-
if [ -f "$TGTMNT/$LIVEOS/$HOMEFILE" -a -n "$keephome" -a "$homesizemb" -gt 0 ]; then
echo "ERROR: Requested keeping existing /home and specified a size for /home"
echo "Please either don't specify a size or specify --delete-home"
@@ -979,11 +1078,6 @@ fi
# Verify available space for DVD installer
if [ "$srctype" = "installer" ]; then
- if [ -z "$skipcopy" ]; then
- srcsize=$(du -s -B 1M "$SRC" | awk {'print $1;'})
- else
- srcsize=0
- fi
if [ "$imgtype" = "install" ]; then
imgpath=images/install.img
else
@@ -998,10 +1092,9 @@ if [ "$srctype" = "installer" ]; then
if [ -e $TGTMNT/$(basename "$SRC") ]; then
tbd=$(($tbd + $(du -s -B 1M $TGTMNT/$(basename "$SRC") | awk {'print $1;'})))
fi
- echo "Size of DVD image: $srcsize"
echo "Size of $imgpath: $installimgsize"
echo "Available space: $((freespace + tbd))"
- if (( ((srcsize + installimgsize)) > ((freespace + tbd)) )); then
+ if (( installimgsize > ((freespace + tbd)) )); then
echo "ERROR: Unable to fit DVD image + install.img on available space on the target device."
exitclean
fi
@@ -1051,6 +1144,7 @@ if [ "$srctype" = "live" -a -z "$skipcopy" ]; then
fi
# DVD installer copy
+# Also copies over the source .iso if the image is a new-style LiveOS DVD (F17+)
if [ \( "$srctype" = "installer" -o "$srctype" = "netinst" \) ]; then
echo "Copying DVD image to target device."
mkdir -p $TGTMNT/images/
@@ -1061,9 +1155,12 @@ if [ \( "$srctype" = "installer" -o "$srctype" = "netinst" \) ]; then
fi
done
fi
- if [ "$srctype" = "installer" -a -z "$skipcopy" ]; then
- copyFile "$SRC" $TGTMNT/
- fi
+fi
+
+# Copy source .iso to repo partition
+if [ -n "$packages" -a -z "$skipcopy" ]; then
+ echo "Copying $SRC"
+ copyFile "$SRC" $REPOMNT/
sync
fi
@@ -1139,40 +1236,45 @@ if [[ live == $srctype ]]; then
-e "/^totaltimeout.*$/d" $BOOTCONFIG
fi
fi
+
+
echo "Updating boot config file"
# adjust label and fstype
-if [ -n "$LANG" ]; then
- kernelargs="$kernelargs LANG=$LANG"
-fi
sed -i -e "s/CDLABEL=[^ ]*/$TGTLABEL/" -e "s/rootfstype=[^ ]*/rootfstype=$TGTFS/" -e "s/LABEL=[^ ]*/$TGTLABEL/" $BOOTCONFIG $BOOTCONFIG_EFI
if [ -n "$kernelargs" ]; then
- sed -i -e "s/liveimg/liveimg ${kernelargs}/" $BOOTCONFIG $BOOTCONFIG_EFI
+ sed -i -e "s;initrd.img;initrd.img ${kernelargs};" $BOOTCONFIG
+ if [ -n "$efi" ]; then
+ sed -i -e "s;vmlinuz;vmlinuz ${kernelargs};" $BOOTCONFIG_EFI
+ fi
fi
if [ "$LIVEOS" != "LiveOS" ]; then
sed -i -e "s;liveimg;liveimg live_dir=$LIVEOS;" $BOOTCONFIG $BOOTCONFIG_EFI
fi
-# DVD Installer
-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
+# EFI images are in $SYSLINUXPATH now
+if [ -n "$efi" ]; then
+ sed -i -e "s;/images/pxeboot/;/$SYSLINUXPATH/;g" $BOOTCONFIG_EFI
+ sed -i -e "s;findiso;;g" $BOOTCONFIG_EFI
+fi
+
+# Add repo= to point to the source .iso with the packages
+if [[ -n "$packages" ]]; then
+ sed -i -e "s;initrd.img;initrd.img repo=hd:$REPOLABEL:/;g" $BOOTCONFIG
if [ -n "$efi" ]; then
- # 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
+ sed -i -e "s;vmlinuz;vmlinuz repo=hd:$REPOLABEL:/;g" $BOOTCONFIG_EFI
fi
fi
# DVD Installer for netinst
-if [ "$srctype" = "netinst" ]; then
+if [ "$srctype" != "live" ]; then
if [ "$imgtype" = "install" ]; then
- sed -i -e "s;stage2=\S*;stage2=hd:$TGTLABEL:/images/install.img;g" $BOOTCONFIG
+ sed -i -e "s;initrd.img;initrd.img stage2=hd:$TGTLABEL:/images/install.img;g" $BOOTCONFIG
+ if [ -n "$efi" ]; then
+ sed -i -e "s;vmlinuz;vmlinuz stage2=hd:$TGTLABEL:/images/install.img;g" $BOOTCONFIG_EFI
+ fi
else
# The initrd has everything, so no stage2
- sed -i -e "s;stage2=\S*;;g" $BOOTCONFIG
- fi
- if [ -n "$efi" ]; then
- # Images are in $SYSLINUXPATH now
- sed -ie "s;/images/pxeboot/;/$SYSLINUXPATH/;g" $BOOTCONFIG_EFI
+ sed -i -e "s;stage2=\S*;;g" $BOOTCONFIG $BOOTCONFIG_EFI
fi
fi
@@ -1184,14 +1286,6 @@ if [ -n "$totaltimeout" ]; then
sed -i -e "/^timeout.*$/a\totaltimeout\ $totaltimeout" $BOOTCONFIG
fi
-# Use repo if the .iso has the repository on it, otherwise use stage2 which
-# will default to using the network mirror
-if [ -e "$SRCMNT/.discinfo" ]; then
- METHODSTR=repo
-else
- METHODSTR=stage2
-fi
-
if [ "$overlaysizemb" -gt 0 ]; then
echo "Initializing persistent overlay file"
OVERFILE="overlay-$( /sbin/blkid -s LABEL -o value $TGTDEV )-$( /sbin/blkid -s UUID -o value $TGTDEV )"
11 years, 7 months
Changes to 'refs/tags/livecd-tools-17.6'
by Brian C. Lane
Tag 'livecd-tools-17.6' created by Brian C. Lane <bcl(a)redhat.com> at 2012-02-24 02:09 +0000
Tag as livecd-tools-17.6
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iQEVAwUAT0bxVBF+jBaO/jp/AQJ2UAf+KdgbgkCBPHIESW+aS2hIDk3cQ9aKz7wq
PPIHgxJwhXMU+KVo1soZUqrRD2tV5ECkaplAIQXZUr7a9jd8kwxTlWPq39gH53qo
fWA5YC8o4nwcqtU0wwysAIN5aG3XR7pqQI4r5cHNFj4iSxgo0WpCeMTVtHX3Oq17
xDAWc3m5kG/lfBlkzyK0GqDNNcyusJcNxdvhslvehcf8UMiLBAS/j0RzwBXqcxgI
hhSXgVo085PH9ICae++riSouQZ5tTKqzorsw2vTo28xHreuGdmAgBpeYHjavdhR4
kPAznjKHN5Znr165wY6zGOsxI/cGchFxpRmohALByJ3mASGJA1XEtQ==
=hv+6
-----END PGP SIGNATURE-----
Changes since livecd-tools-17.5:
Brian C. Lane (2):
livecd-iso-to-disk: create partition for iso
Version 17.6
---
Makefile | 2
tools/livecd-iso-to-disk.sh | 248 ++++++++++++++++++++++++++++++--------------
2 files changed, 172 insertions(+), 78 deletions(-)
---
11 years, 7 months
Branch 'f17-branch' - Makefile
by Brian C. Lane
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 4f8736fd53bcab293b2fcd9cedbf87db072602a8
Author: Brian C. Lane <bcl(a)redhat.com>
Date: Thu Feb 23 18:09:12 2012 -0800
Version 17.6
diff --git a/Makefile b/Makefile
index c647546..42019b1 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
-VERSION = 17.5
+VERSION = 17.6
INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = ${INSTALL}
11 years, 7 months
Changes to 'refs/tags/livecd-tools-18.1'
by Brian C. Lane
Tag 'livecd-tools-18.1' created by Brian C. Lane <bcl(a)redhat.com> at 2012-02-24 02:04 +0000
Tag as livecd-tools-18.1
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iQEVAwUAT0bwPxF+jBaO/jp/AQJEDQgAgnYYMnBaJTmcTPNhcjUyktBkitv/gVCP
wKc0xYgxKV/iApmzF6st+TNk+K3+xqy6pdRYY+X15ILqCbiDfipVNNUvT9zO5nLW
JxjjrCo+5H+TxW0YHGkHqVSPUyH+oUUHqNUoKe00Uu7fLaWuSBkuZne36bDiE1NY
OQPudguCVdIqETfu1oUWK8Sb0li1mUjMJpWZPXp+wkmFzMCamkzEsW/BfflS8eDw
X+kf1UmY+5jBru8iz8ZmhGxAANczk/36G1q2erEf0vWUUAJj7raVYsCBKTJZaopA
ZPgU20VINBs8eXzBMKcwT9uThTnPNYA5U7DVJ1seJhV4JFf1WkXgfQ==
=xbgK
-----END PGP SIGNATURE-----
Changes since livecd-tools-18.0:
Brian C. Lane (2):
livecd-iso-to-disk: create partition for iso
Version 18.1
---
Makefile | 2
tools/livecd-iso-to-disk.sh | 248 ++++++++++++++++++++++++++++++--------------
2 files changed, 172 insertions(+), 78 deletions(-)
---
11 years, 7 months
Makefile
by Brian C. Lane
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 064c88616c74c069499c563ec222ccb94aac350d
Author: Brian C. Lane <bcl(a)redhat.com>
Date: Thu Feb 23 18:04:25 2012 -0800
Version 18.1
diff --git a/Makefile b/Makefile
index 05e553c..0ea4d5e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
-VERSION = 18.0
+VERSION = 18.1
INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = ${INSTALL}
11 years, 7 months
Branch 'f17-branch' - tools/livecd-iso-to-disk.sh
by Brian C. Lane
tools/livecd-iso-to-disk.sh | 248 ++++++++++++++++++++++++++++++--------------
1 file changed, 171 insertions(+), 77 deletions(-)
New commits:
commit d97c367698d6f43f6a354f7077cbda8373384427
Author: Brian C. Lane <bcl(a)redhat.com>
Date: Tue Feb 21 14:55:51 2012 -0800
livecd-iso-to-disk: create partition for iso
In Fedora 17 the installer runs from the squashfs.img on the install
media. This means that the installer environment doesn't have direct
access to the install media, and it cannot mount it.
In order to support writing DVD's to USB sticks we now need to create a
second partition just for the .iso image and direct the installer to it
using the repo=UUID=... command
This patch adds creating the 2nd partition if needed and also cleans up
some of the bootloader config editing code.
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index 2db2903..3ae88a2 100755
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -1,7 +1,9 @@
#!/bin/bash
# Transfer a Live image so that it's bootable off of a USB/SD device.
-# Copyright 2007 Red Hat, Inc.
+# Copyright 2007-2012 Red Hat, Inc.
+#
# Jeremy Katz <katzj(a)redhat.com>
+# Brian C. Lane <bcl(a)redhat.com>
#
# overlay/persistence enhancements by Douglas McClendon <dmc(a)viros.org>
# GPT+MBR hybrid enhancements by Stewart Adam <s.adam(a)diffingo.com>
@@ -274,11 +276,14 @@ cleanup() {
sleep 2
[ -d "$SRCMNT" ] && umount $SRCMNT && rmdir $SRCMNT
[ -d "$TGTMNT" ] && umount $TGTMNT && rmdir $TGTMNT
+ if [ -n "$REPOMNT" ]; then
+ [ -d "$REPOMNT" ] && umount $REPOMNT && rmdir $REPOMNT
+ fi
}
exitclean() {
RETVAL=$?
- if [ -d "$SRCMNT" ] || [ -d "$TGTMNT" ];
+ if [ -d "$SRCMNT" ] || [ -d "$TGTMNT" ] || [ -n "$REPOMNT" ];
then
[ "$RETVAL" = 0 ] || echo "Cleaning up to exit..."
cleanup
@@ -319,13 +324,6 @@ getdisk() {
partnum=${p##$device}
}
-getpartition() {
- DEV=$1
- pa=$( < /proc/partitions )
- pa=${pa##*$DEV}
- partnum=${pa%% *}
-}
-
resetMBR() {
if isdevloop "$DEV"; then
return
@@ -423,18 +421,47 @@ createGPTLayout() {
umount ${device}* &> /dev/null || :
wipefs -a ${device}
/sbin/parted --script $device mklabel gpt
- partinfo=$(LC_ALL=C /sbin/parted --script -m $device "unit b print" |grep ^$device:)
- size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/B$//')
- /sbin/parted --script $device unit b mkpart '"EFI System Partition"' fat32 1048576 $(($size - 1048576)) set 1 boot on
+ partinfo=$(LC_ALL=C /sbin/parted --script -m $device "unit MB print" |grep ^$device:)
+ dev_size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/MB$//')
+
+ # Is a 2nd partition needed for package iso?
+ if [ -n "$packages" ]; then
+ src_size=$(du -s -B 1MB "$SRC" | awk {'print $1;'})
+ # iso size + 7% of slop for filesystem metadata
+ p2_size=$(($src_size * 107 / 100))
+ else
+ p2_size=0
+ fi
+ p1_size=$(($dev_size - 1 - $p2_size))
+
+ if [ $p1_size -le 0 ]; then
+ echo "Your device isn't big enough to hold $SRC"
+ echo "It is $(($p1_size * -1)) MB too small"
+ exitclean
+ fi
+ p1_start=1
+ p1_end=$(($p1_size + 1))
+ /sbin/parted -s $device u MB mkpart '"EFI System Partition"' fat32 $p1_start $p1_end set 1 boot on
+ if [ $p2_size -gt 0 ]; then
+ p2_start=$p1_end
+ p2_end=$(($p2_size + $p2_start))
+ /sbin/parted -s $device u MB mkpart '"LIVE REPO"' fat32 $p2_start $p2_end
+ fi
# Sometimes automount can be _really_ annoying.
echo "Waiting for devices to settle..."
/sbin/udevadm settle
sleep 5
- getpartition ${device#/dev/}
- TGTDEV=${device}${partnum}
+ TGTDEV=${device}1
umount $TGTDEV &> /dev/null || :
/sbin/mkdosfs -n LIVE $TGTDEV
TGTLABEL="UUID=$(/sbin/blkid -s UUID -o value $TGTDEV)"
+
+ if [ $p2_size -gt 0 ]; then
+ REPODEV=${device}2
+ umount $REPODEV &> /dev/null || :
+ /sbin/mkdosfs -n LIVE-REPO $REPODEV
+ REPOLABEL="UUID=$(/sbin/blkid -s UUID -o value $REPODEV)"
+ fi
}
createMSDOSLayout() {
@@ -447,22 +474,51 @@ createMSDOSLayout() {
umount ${device}* &> /dev/null || :
wipefs -a ${device}
/sbin/parted --script $device mklabel msdos
- partinfo=$(LC_ALL=C /sbin/parted --script -m $device "unit b print" |grep ^$device:)
- size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/B$//')
- /sbin/parted --script $device unit b mkpart primary fat32 1048576 $(($size - 1048576)) set 1 boot on
+ partinfo=$(LC_ALL=C /sbin/parted --script -m $device "unit MB print" |grep ^$device:)
+ dev_size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/MB$//')
+
+ # Is a 2nd partition needed for package iso?
+ if [ -n "$packages" ]; then
+ src_size=$(du -s -B 1MB "$SRC" | awk {'print $1;'})
+ # iso size + 7% of slop for filesystem metadata
+ p2_size=$(($src_size * 107 / 100))
+ else
+ p2_size=0
+ fi
+ p1_size=$(($dev_size - 1 - $p2_size))
+
+ if [ $p1_size -le 0 ]; then
+ echo "Your device isn't big enough to hold $SRC"
+ echo "It is $(($p1_size * -1)) MB too small"
+ exitclean
+ fi
+ p1_start=1
+ p1_end=$(($p1_size + 1))
+ /sbin/parted -s $device u MB mkpart primary fat32 $p1_start $p1_end set 1 boot on
+ if [ $p2_size -gt 0 ]; then
+ p2_start=$p1_end
+ p2_end=$(($p2_size + $p2_start))
+ /sbin/parted -s $device u MB mkpart primary fat32 $p2_start $p2_end
+ fi
# Sometimes automount can be _really_ annoying.
echo "Waiting for devices to settle..."
/sbin/udevadm settle
sleep 5
if ! isdevloop "$DEV"; then
- getpartition ${device#/dev/}
- TGTDEV=${device}${partnum}
+ TGTDEV=${device}1
else
TGTDEV=${device}
fi
umount $TGTDEV &> /dev/null || :
/sbin/mkdosfs -n LIVE $TGTDEV
TGTLABEL="UUID=$(/sbin/blkid -s UUID -o value $TGTDEV)"
+
+ if [ $p2_size -gt 0 ]; then
+ REPODEV=${device}2
+ umount $REPODEV &> /dev/null || :
+ /sbin/mkdosfs -n LIVE-REPO $REPODEV
+ REPOLABEL="UUID=$(/sbin/blkid -s UUID -o value $REPODEV)"
+ fi
}
createEXTFSLayout() {
@@ -474,25 +530,55 @@ createEXTFSLayout() {
read
umount ${device}* &> /dev/null || :
wipefs -a ${device}
- /sbin/parted --script $device mklabel msdos
- partinfo=$(LC_ALL=C /sbin/parted --script -m $device "unit b print" |grep ^$device:)
- size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/B$//')
- /sbin/parted --script $device unit b mkpart primary ext2 1048576 $(($size - 1048576)) set 1 boot on
+ /sbin/parted -s $device mklabel msdos
+ partinfo=$(LC_ALL=C /sbin/parted -s -m $device "u MB print" |grep ^$device:)
+ dev_size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/MB$//')
+
+ # Is a 2nd partition needed for package iso?
+ if [ -n "$packages" ]; then
+ src_size=$(du -s -B 1MB "$SRC" | awk {'print $1;'})
+ # iso size + 7% of slop for filesystem metadata
+ p2_size=$(($src_size * 107 / 100))
+ else
+ p2_size=0
+ fi
+ p1_size=$(($dev_size - 1 - $p2_size))
+
+ if [ $p1_size -le 0 ]; then
+ echo "Your device isn't big enough to hold $SRC"
+ echo "It is $(($p1_size * -1)) MB too small"
+ exitclean
+ fi
+ p1_start=1
+ p1_end=$(($p1_size + 1))
+ /sbin/parted -s $device u MB mkpart primary ext2 $p1_start $p1_end set 1 boot on
+ if [ $p2_size -gt 0 ]; then
+ p2_start=$p1_end
+ p2_end=$(($p2_size + $p2_start))
+ /sbin/parted -s $device u MB mkpart primary ext2 $p2_start $p2_end
+ fi
# Sometimes automount can be _really_ annoying.
echo "Waiting for devices to settle..."
/sbin/udevadm settle
sleep 5
- getpartition ${device#/dev/}
- TGTDEV=${device}${partnum}
+ TGTDEV=${device}1
umount $TGTDEV &> /dev/null || :
# Check extlinux version
if extlinux -v 2>&1 | grep -q 'extlinux 3'; then
- /sbin/mkfs.ext3 -L LIVE $TGTDEV
+ mkfs=/sbin/mkfs.ext3
else
- /sbin/mkfs.ext4 -L LIVE $TGTDEV
+ mkfs=/sbin/mkfs.ext4
fi
+ $mkfs -L LIVE $TGTDEV
TGTLABEL="UUID=$(/sbin/blkid -s UUID -o value $TGTDEV)"
+
+ if [ $p2_size -gt 0 ]; then
+ REPODEV=${device}2
+ umount $REPODEV &> /dev/null || :
+ $mkfs -L LIVE-REPO $REPODEV
+ REPOLABEL="UUID=$(/sbin/blkid -s UUID -o value $REPODEV)"
+ fi
}
checkGPT() {
@@ -607,17 +693,24 @@ if [ $(id -u) != 0 ]; then
fi
detectsrctype() {
- if [[ -e $SRCMNT/LiveOS/squashfs.img ]]; then
+ if [[ -e "$SRCMNT/Packages" ]]; then
+ # This will cause the source .iso to be copied to a second partiton
+ # on the target and the boot args to have repo=... pointing to the iso
+ echo "/Packages found, will copy source .iso to target"
+ packages=1
+ fi
+ if [[ -e "$SRCMNT/LiveOS/squashfs.img" ]]; then
+ # LiveOS style boot image
srctype=live
return
fi
if [ -e $SRCMNT/images/install.img -o $SRCMNT/isolinux/initrd.img ]; then
- imgtype=install
- if [ -e $SRCMNT/Packages ]; then
+ if [ -n "$packages" ]; then
srctype=installer
else
srctype=netinst
fi
+ imgtype=install
if [ ! -e $SRCMNT/images/install.img ]; then
echo "$SRC uses initrd.img w/o install.img"
imgtype=initrd
@@ -674,6 +767,7 @@ swapsizemb=0
overlaysizemb=0
srctype=
imgtype=
+packages=
LIVEOS=LiveOS
HOMEFILE="home.img"
@@ -813,6 +907,19 @@ fi
# do some basic sanity checks.
checkMounted $TGTDEV
+# FIXME: would be better if we had better mountpoints
+SRCMNT=$(mktemp -d /media/srctmp.XXXXXX)
+if [ -b "$SRC" ]; then
+ mount -o ro "$SRC" $SRCMNT || exitclean
+elif [ -f "$SRC" ]; then
+ mount -o loop,ro "$SRC" $SRCMNT || exitclean
+else
+ echo "$SRC is not a file or block device."
+ exitclean
+fi
+# Figure out what needs to be done based on the source image
+detectsrctype
+
# Format the device
if [ -n "$format" -a -z "$skipcopy" ]; then
checkLVM $TGTDEV
@@ -865,23 +972,15 @@ if [ "$swapsizemb" -gt 0 -a "$TGTFS" = "vfat" ]; then
fi
fi
-# FIXME: would be better if we had better mountpoints
-SRCMNT=$(mktemp -d /media/srctmp.XXXXXX)
-if [ -b "$SRC" ]; then
- mount -o ro "$SRC" $SRCMNT || exitclean
-elif [ -f "$SRC" ]; then
- mount -o loop,ro "$SRC" $SRCMNT || exitclean
-else
- echo "$SRC is not a file or block device."
- exitclean
-fi
TGTMNT=$(mktemp -d /media/tgttmp.XXXXXX)
mount $mountopts $TGTDEV $TGTMNT || exitclean
+if [ -n "$REPODEV" ]; then
+ REPOMNT=$(mktemp -d /media/repotmp.XXXXXX)
+ mount $mountopts $REPODEV $REPOMNT || exitclean
+fi
trap exitclean SIGINT SIGTERM
-detectsrctype
-
if [ -f "$TGTMNT/$LIVEOS/$HOMEFILE" -a -n "$keephome" -a "$homesizemb" -gt 0 ]; then
echo "ERROR: Requested keeping existing /home and specified a size for /home"
echo "Please either don't specify a size or specify --delete-home"
@@ -979,11 +1078,6 @@ fi
# Verify available space for DVD installer
if [ "$srctype" = "installer" ]; then
- if [ -z "$skipcopy" ]; then
- srcsize=$(du -s -B 1M "$SRC" | awk {'print $1;'})
- else
- srcsize=0
- fi
if [ "$imgtype" = "install" ]; then
imgpath=images/install.img
else
@@ -998,10 +1092,9 @@ if [ "$srctype" = "installer" ]; then
if [ -e $TGTMNT/$(basename "$SRC") ]; then
tbd=$(($tbd + $(du -s -B 1M $TGTMNT/$(basename "$SRC") | awk {'print $1;'})))
fi
- echo "Size of DVD image: $srcsize"
echo "Size of $imgpath: $installimgsize"
echo "Available space: $((freespace + tbd))"
- if (( ((srcsize + installimgsize)) > ((freespace + tbd)) )); then
+ if (( installimgsize > ((freespace + tbd)) )); then
echo "ERROR: Unable to fit DVD image + install.img on available space on the target device."
exitclean
fi
@@ -1051,6 +1144,7 @@ if [ "$srctype" = "live" -a -z "$skipcopy" ]; then
fi
# DVD installer copy
+# Also copies over the source .iso if the image is a new-style LiveOS DVD (F17+)
if [ \( "$srctype" = "installer" -o "$srctype" = "netinst" \) ]; then
echo "Copying DVD image to target device."
mkdir -p $TGTMNT/images/
@@ -1061,9 +1155,12 @@ if [ \( "$srctype" = "installer" -o "$srctype" = "netinst" \) ]; then
fi
done
fi
- if [ "$srctype" = "installer" -a -z "$skipcopy" ]; then
- copyFile "$SRC" $TGTMNT/
- fi
+fi
+
+# Copy source .iso to repo partition
+if [ -n "$packages" -a -z "$skipcopy" ]; then
+ echo "Copying $SRC"
+ copyFile "$SRC" $REPOMNT/
sync
fi
@@ -1139,40 +1236,45 @@ if [[ live == $srctype ]]; then
-e "/^totaltimeout.*$/d" $BOOTCONFIG
fi
fi
+
+
echo "Updating boot config file"
# adjust label and fstype
-if [ -n "$LANG" ]; then
- kernelargs="$kernelargs LANG=$LANG"
-fi
sed -i -e "s/CDLABEL=[^ ]*/$TGTLABEL/" -e "s/rootfstype=[^ ]*/rootfstype=$TGTFS/" -e "s/LABEL=[^ ]*/$TGTLABEL/" $BOOTCONFIG $BOOTCONFIG_EFI
if [ -n "$kernelargs" ]; then
- sed -i -e "s/liveimg/liveimg ${kernelargs}/" $BOOTCONFIG $BOOTCONFIG_EFI
+ sed -i -e "s;initrd.img;initrd.img ${kernelargs};" $BOOTCONFIG
+ if [ -n "$efi" ]; then
+ sed -i -e "s;vmlinuz;vmlinuz ${kernelargs};" $BOOTCONFIG_EFI
+ fi
fi
if [ "$LIVEOS" != "LiveOS" ]; then
sed -i -e "s;liveimg;liveimg live_dir=$LIVEOS;" $BOOTCONFIG $BOOTCONFIG_EFI
fi
-# DVD Installer
-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
+# EFI images are in $SYSLINUXPATH now
+if [ -n "$efi" ]; then
+ sed -i -e "s;/images/pxeboot/;/$SYSLINUXPATH/;g" $BOOTCONFIG_EFI
+ sed -i -e "s;findiso;;g" $BOOTCONFIG_EFI
+fi
+
+# Add repo= to point to the source .iso with the packages
+if [[ -n "$packages" ]]; then
+ sed -i -e "s;initrd.img;initrd.img repo=hd:$REPOLABEL:/;g" $BOOTCONFIG
if [ -n "$efi" ]; then
- # 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
+ sed -i -e "s;vmlinuz;vmlinuz repo=hd:$REPOLABEL:/;g" $BOOTCONFIG_EFI
fi
fi
# DVD Installer for netinst
-if [ "$srctype" = "netinst" ]; then
+if [ "$srctype" != "live" ]; then
if [ "$imgtype" = "install" ]; then
- sed -i -e "s;stage2=\S*;stage2=hd:$TGTLABEL:/images/install.img;g" $BOOTCONFIG
+ sed -i -e "s;initrd.img;initrd.img stage2=hd:$TGTLABEL:/images/install.img;g" $BOOTCONFIG
+ if [ -n "$efi" ]; then
+ sed -i -e "s;vmlinuz;vmlinuz stage2=hd:$TGTLABEL:/images/install.img;g" $BOOTCONFIG_EFI
+ fi
else
# The initrd has everything, so no stage2
- sed -i -e "s;stage2=\S*;;g" $BOOTCONFIG
- fi
- if [ -n "$efi" ]; then
- # Images are in $SYSLINUXPATH now
- sed -ie "s;/images/pxeboot/;/$SYSLINUXPATH/;g" $BOOTCONFIG_EFI
+ sed -i -e "s;stage2=\S*;;g" $BOOTCONFIG $BOOTCONFIG_EFI
fi
fi
@@ -1184,14 +1286,6 @@ if [ -n "$totaltimeout" ]; then
sed -i -e "/^timeout.*$/a\totaltimeout\ $totaltimeout" $BOOTCONFIG
fi
-# Use repo if the .iso has the repository on it, otherwise use stage2 which
-# will default to using the network mirror
-if [ -e "$SRCMNT/.discinfo" ]; then
- METHODSTR=repo
-else
- METHODSTR=stage2
-fi
-
if [ "$overlaysizemb" -gt 0 ]; then
echo "Initializing persistent overlay file"
OVERFILE="overlay-$( /sbin/blkid -s LABEL -o value $TGTDEV )-$( /sbin/blkid -s UUID -o value $TGTDEV )"
11 years, 7 months
Gnome Keyring
by wbsec.flive@new.rr.com
I am making a remix of F16 and really don't see the need for the Gnome Keyring Daemon. This remix is for a live CD, so all of the saved passwords will be lost once I reboot. Is there a way to remove or disable the Gnome Keyring Daemon?
Thank you
11 years, 7 months