[Fedora-livecd-list] 3 commits - imgcreate/live.py tools/livecd-iso-to-disk.sh

Jeremy Katz katzj at fedoraproject.org
Mon Jan 19 16:16:14 UTC 2009


 imgcreate/live.py           |   12 +--
 tools/livecd-iso-to-disk.sh |  169 +++++++++++++++++++++++++++++---------------
 2 files changed, 119 insertions(+), 62 deletions(-)

New commits:
commit 616642a5d56b8e453614f7a8845a61b033c9ac4f
Author: Jeremy Katz <katzj at redhat.com>
Date:   Mon Jan 19 11:14:10 2009 -0500

    Use rootfstype='auto' instead of trying to discover iso9660 vs udf (#479846)

diff --git a/imgcreate/live.py b/imgcreate/live.py
index a6a9c46..c75cc92 100644
--- a/imgcreate/live.py
+++ b/imgcreate/live.py
@@ -442,7 +442,7 @@ menu hiddenrow 5
 
             cfg += self.__get_image_stanza(is_xen,
                                            fslabel = self.fslabel,
-                                           isofstype = self._isofstype,
+                                           isofstype = "auto",
                                            liveargs = kernel_options,
                                            long = long,
                                            short = "linux" + index,
@@ -455,7 +455,7 @@ menu hiddenrow 5
             if checkisomd5:
                 cfg += self.__get_image_stanza(is_xen,
                                                fslabel = self.fslabel,
-                                               isofstype = self._isofstype,
+                                               isofstype = "auto",
                                                liveargs = kernel_options,
                                                long = "Verify and " + long,
                                                short = "check" + index,
@@ -549,13 +549,13 @@ hiddenmenu
             if os.path.exists("%s/EFI/boot/xen%d.gz" %(isodir, index)):
                 continue
             cfg += self.__get_efi_image_stanza(fslabel = self.fslabel,
-                                               isofstype = self._isofstype,
+                                               isofstype = "auto",
                                                liveargs = kernel_options,
                                                long = name,
                                                extra = "", index = index)
             if checkisomd5:
                 cfg += self.__get_efi_image_stanza(fslabel = self.fslabel,
-                                                   isofstype = self._isofstype,
+                                                   isofstype = "auto",
                                                    liveargs = kernel_options,
                                                    long = "Verify and Boot " + name,
                                                    extra = "check",
@@ -674,7 +674,7 @@ image=/ppc/ppc%(bit)s/vmlinuz
         kernel_options = self._get_kernel_options()
 
         cfg += self.__get_image_stanza(fslabel = self.fslabel,
-                                       isofstype = self._isofstype,
+                                       isofstype = "auto",
                                        short = "linux",
                                        long = "Run from image",
                                        extra = "",
@@ -683,7 +683,7 @@ image=/ppc/ppc%(bit)s/vmlinuz
 
         if self._has_checkisomd5():
             cfg += self.__get_image_stanza(fslabel = self.fslabel,
-                                           isofstype = self._isofstype,
+                                           isofstype = "auto",
                                            short = "check",
                                            long = "Verify and run from image",
                                            extra = "check",


commit 08da762ce7893c79bb22772c843e492765ff15f4
Author: Jeremy Katz <katzj at redhat.com>
Date:   Mon Jan 19 10:54:42 2009 -0500

    Don't make an inability to find the hybrid gptmbr.bin fatal

diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index 3777c21..d37a2e9 100755
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -74,9 +74,6 @@ resetMBR() {
         cat /usr/lib/syslinux/gptmbr.bin > $device
       elif [ -f /usr/share/syslinux/gptmbr.bin ]; then
         cat /usr/share/syslinux/gptmbr.bin > $device
-      else
-        echo "Could not find gptmbr.bin (syslinux)"
-        exitclean
       fi
     else
       if [ -f /usr/lib/syslinux/mbr.bin ]; then


commit f0ed14fce156fd97480e833440898cdc378e8f89
Author: Stweart Adam <s.adam at diffingo.com>
Date:   Fri Jan 16 16:15:50 2009 -0500

    Start to support creating/using hybrid GPT/MBR USB sticks
    
    What it changes:
    * Exit messages when syslinux's MBR files can't be found
    * Unmounts $USBDEV after creating GPT, as HAL attempts to automount
    * Allows for hybrid (GPT+MBR) USB keys
    * Adds --skipcopy to skip copying the live OS
    * Adds --format option to replace --mactel + --reset-mbr
    * --reset-mbr will now reset the MBR, GPT or not.
    * if --format is specified, a valid partition isn't required (only a valid
    device instead)
    
    Notes worth mentioning:
    * --format + --mactel = new GPT table, resets PMBR (GPT's Protective MBR)
    * --format = new MSDOS table, resets MBR
    * syslinux support isn't complete let, hopefully coming soon
    * GPT hybrid tables requires /usr/{lib,share}/syslinux/gptmbr.bin which is
    only in the newest syslinux (not available in the Fedora repos yet).

diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index fba2567..3777c21 100755
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -4,6 +4,7 @@
 # Jeremy Katz <katzj at redhat.com>
 #
 # overlay/persistence enhancements by Douglas McClendon <dmc at viros.org>
+# GPT+MBR hybrid enhancements by Stewart Adam <s.adam at diffingo.com>
 # 
 # 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
@@ -22,7 +23,7 @@
 export PATH=/sbin:/usr/sbin:$PATH
 
 usage() {
-    echo "$0 [--reset-mbr] [--noverify] [--overlay-size-mb <size>] [--home-size-mb <size>] [--unencrypted-home] <isopath> <usbstick device>"
+    echo "$0 [--format] [--reset-mbr] [--noverify] [--overlay-size-mb <size>] [--home-size-mb <size>] [--unencrypted-home] [--skipcopy] <isopath> <usbstick device>"
     exit 1
 }
 
@@ -67,12 +68,25 @@ resetMBR() {
        return
     fi
     getdisk $1
-    if [ -f /usr/lib/syslinux/mbr.bin ]; then
-	cat /usr/lib/syslinux/mbr.bin > $device
-    elif [ -f /usr/share/syslinux/mbr.bin ]; then
-	cat /usr/share/syslinux/mbr.bin > $device
+    # if mactel, we need to use the hybrid MBR
+    if [ -n "$mactel" ];then
+      if [ -f /usr/lib/syslinux/gptmbr.bin ]; then
+        cat /usr/lib/syslinux/gptmbr.bin > $device
+      elif [ -f /usr/share/syslinux/gptmbr.bin ]; then
+        cat /usr/share/syslinux/gptmbr.bin > $device
+      else
+        echo "Could not find gptmbr.bin (syslinux)"
+        exitclean
+      fi
     else
-	exitclean
+      if [ -f /usr/lib/syslinux/mbr.bin ]; then
+        cat /usr/lib/syslinux/mbr.bin > $device
+      elif [ -f /usr/share/syslinux/mbr.bin ]; then
+        cat /usr/share/syslinux/mbr.bin > $device
+      else
+        echo "Could not find mbr.bin (syslinux)"
+        exitclean
+      fi
     fi
 }
 
@@ -131,9 +145,35 @@ createGPTLayout() {
     size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/B$//')
     /sbin/parted --script $device unit b mkpart '"EFI System Partition"' fat32 17408 $(($size - 17408)) set 1 boot on
     USBDEV=${device}1
+    # Sometimes automount can be _really_ annoying.
+    echo "Waiting for devices to settle..."
     /sbin/udevadm settle
+    sleep 5
+    umount $USBDEV &> /dev/null
     /sbin/mkdosfs -n LIVE $USBDEV
-    USBLABEL="UUID=$(/lib/udev/vol_id -u $dev)"
+    USBLABEL="UUID=$(/lib/udev/vol_id -u $USBDEV)"
+}
+
+createMSDOSLayout() {
+    dev=$1
+    getdisk $dev
+
+    echo "WARNING: THIS WILL DESTROY ANY DATA ON $device!!!"
+    echo "Press Enter to continue or ctrl-c to abort"
+    read
+
+    /sbin/parted --script $device mklabel msdos
+    partinfo=$(/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 17408 $(($size - 17408)) set 1 boot on
+    USBDEV=${device}1
+    # Sometimes automount can be _really_ annoying.
+    echo "Waiting for devices to settle..."
+    /sbin/udevadm settle
+    sleep 5
+    umount $USBDEV &> /dev/null
+    /sbin/mkdosfs -n LIVE $USBDEV
+    USBLABEL="UUID=$(/lib/udev/vol_id -u $USBDEV)"
 }
 
 checkGPT() {
@@ -142,7 +182,7 @@ checkGPT() {
 
     if [ "$(/sbin/fdisk -l $device 2>/dev/null |grep -c GPT)" -eq "0" ]; then
        echo "EFI boot requires a GPT partition table."
-       echo "This can be done manually or you can run with --reset-mbr"
+       echo "This can be done manually or you can run with --format"
        exitclean
     fi
 
@@ -273,6 +313,12 @@ while [ $# -gt 2 ]; do
 	--mactel)
 	    mactel=1
 	    ;;
+	--format)
+	    format=1
+	    ;;
+	--skipcopy)
+	    skipcopy=1
+	    ;;
 	--xo)
 	    xo=1
 	    skipcompress=1
@@ -311,6 +357,7 @@ if [ ! -b "$ISO" -a ! -f "$ISO" ]; then
     usage
 fi
 
+# FIXME: If --format is given, we shouldn't care and just use /dev/foo1
 if [ -z "$USBDEV" -o ! -b "$USBDEV" ]; then
     usage
 fi
@@ -327,17 +374,24 @@ if [ -z "$noverify" ]; then
 fi
 
 # do some basic sanity checks.  
-checkFilesystem $USBDEV
 checkMounted $USBDEV
-if [ -z "$mactel" ]; then
-  checkSyslinuxVersion
-  checkPartActive $USBDEV
-  [ -n "$resetmbr" ] && resetMBR $USBDEV
-  checkMBR $USBDEV
-elif [ -n "$mactel" ]; then
-  [ -n "$resetmbr" ] && createGPTLayout $USBDEV
+if [ -n "$format" ];then
+  # checks for a valid filesystem
+  if [ -n "$mactel" ];then
+    createGPTLayout $USBDEV
+  else
+    createMSDOSLayout $USBDEV
+  fi
+fi
+checkFilesystem $USBDEV
+if [ -n "$mactel" ]; then
   checkGPT $USBDEV
 fi
+checkSyslinuxVersion
+# Because we can't set boot flag for EFI Protective on msdos partition tables
+[ -z "$mactel" ] && checkPartActive $USBDEV
+[ -n "$resetmbr" ] && resetMBR $USBDEV
+checkMBR $USBDEV
 
 
 if [ "$overlaysizemb" -gt 0 -a "$USBFS" = "vfat" ]; then
@@ -406,49 +460,54 @@ if [ $(($overlaysizemb + $homesizemb + $livesize + $swapsizemb)) -gt $(($free +
   exitclean
 fi
 
-if [ -d $USBMNT/LiveOS -a -z "$force" ]; then
-    echo "Already set up as live image."  
-    if [ -z "$keephome" -a -e $USBMNT/LiveOS/$HOMEFILE ]; then
-      echo "WARNING: Persistent /home will be deleted!!!"
-      echo "Press Enter to continue or ctrl-c to abort"
-      read
-    else
-      echo "Deleting old OS in fifteen seconds..."
-      sleep 15
-
-      [ -e "$USBMNT/LiveOS/$HOMEFILE" -a -n "$keephome" ] && mv $USBMNT/LiveOS/$HOMEFILE $USBMNT/$HOMEFILE
-    fi
-
-    rm -rf $USBMNT/LiveOS
+if [ -z "$skipcopy" ];then
+  if [ -d $USBMNT/LiveOS -a -z "$force" ]; then
+      echo "Already set up as live image."  
+      if [ -z "$keephome" -a -e $USBMNT/LiveOS/$HOMEFILE ]; then
+        echo "WARNING: Persistent /home will be deleted!!!"
+        echo "Press Enter to continue or ctrl-c to abort"
+        read
+      else
+        echo "Deleting old OS in fifteen seconds..."
+        sleep 15
+
+        [ -e "$USBMNT/LiveOS/$HOMEFILE" -a -n "$keephome" ] && mv $USBMNT/LiveOS/$HOMEFILE $USBMNT/$HOMEFILE
+      fi
+
+      rm -rf $USBMNT/LiveOS
+  fi
 fi
 
-echo "Copying live image to USB stick"
-[ -z "$mactel" -a ! -d $USBMNT/$SYSLINUXPATH ] && mkdir -p $USBMNT/$SYSLINUXPATH
+# Bootloader is always reconfigured, so keep these out of the if skipcopy stuff.
+[ ! -d $USBMNT/$SYSLINUXPATH ] && mkdir -p $USBMNT/$SYSLINUXPATH
 [ -n "$mactel" -a ! -d $USBMNT/EFI/boot ] && mkdir -p $USBMNT/EFI/boot
-[ ! -d $USBMNT/LiveOS ] && mkdir $USBMNT/LiveOS
-[ -n "$keephome" -a -f "$USBMNT/$HOMEFILE" ] && mv $USBMNT/$HOMEFILE $USBMNT/LiveOS/$HOMEFILE
-# cases without /LiveOS are legacy detection, remove for F10
-if [ -n "$skipcompress" -a -f $CDMNT/LiveOS/squashfs.img ]; then
-    mount -o loop $CDMNT/LiveOS/squashfs.img $CDMNT
-    cp $CDMNT/LiveOS/ext3fs.img $USBMNT/LiveOS/ext3fs.img || (umount $CDMNT ; exitclean)
-    umount $CDMNT
-elif [ -f $CDMNT/LiveOS/squashfs.img ]; then
-    cp $CDMNT/LiveOS/squashfs.img $USBMNT/LiveOS/squashfs.img || exitclean
-elif [ -f $CDMNT/squashfs.img ]; then
-    cp $CDMNT/squashfs.img $USBMNT/LiveOS/squashfs.img || exitclean 
-elif [ -f $CDMNT/LiveOS/ext3fs.img ]; then
-    cp $CDMNT/LiveOS/ext3fs.img $USBMNT/LiveOS/ext3fs.img || exitclean
-elif [ -f $CDMNT/ext3fs.img ]; then
-    cp $CDMNT/ext3fs.img $USBMNT/LiveOS/ext3fs.img || exitclean 
-fi
-if [ -f $CDMNT/LiveOS/osmin.img ]; then
-    cp $CDMNT/LiveOS/osmin.img $USBMNT/LiveOS/osmin.img || exitclean
+
+if [ -z "$skipcopy" ];then
+  echo "Copying live image to USB stick"
+  [ ! -d $USBMNT/LiveOS ] && mkdir $USBMNT/LiveOS
+  [ -n "$keephome" -a -f "$USBMNT/$HOMEFILE" ] && mv $USBMNT/$HOMEFILE $USBMNT/LiveOS/$HOMEFILE
+  # cases without /LiveOS are legacy detection, remove for F10
+  if [ -n "$skipcompress" -a -f $CDMNT/LiveOS/squashfs.img ]; then
+      mount -o loop $CDMNT/LiveOS/squashfs.img $CDMNT
+      cp $CDMNT/LiveOS/ext3fs.img $USBMNT/LiveOS/ext3fs.img || (umount $CDMNT ; exitclean)
+      umount $CDMNT
+  elif [ -f $CDMNT/LiveOS/squashfs.img ]; then
+      cp $CDMNT/LiveOS/squashfs.img $USBMNT/LiveOS/squashfs.img || exitclean
+  elif [ -f $CDMNT/squashfs.img ]; then
+      cp $CDMNT/squashfs.img $USBMNT/LiveOS/squashfs.img || exitclean 
+  elif [ -f $CDMNT/LiveOS/ext3fs.img ]; then
+      cp $CDMNT/LiveOS/ext3fs.img $USBMNT/LiveOS/ext3fs.img || exitclean
+  elif [ -f $CDMNT/ext3fs.img ]; then
+      cp $CDMNT/ext3fs.img $USBMNT/LiveOS/ext3fs.img || exitclean 
+  fi
+  if [ -f $CDMNT/LiveOS/osmin.img ]; then
+      cp $CDMNT/LiveOS/osmin.img $USBMNT/LiveOS/osmin.img || exitclean
+  fi
 fi
 
-if [ -z "$mactel" ]; then
-  cp $CDMNT/isolinux/* $USBMNT/$SYSLINUXPATH
-  BOOTCONFIG=$USBMNT/$SYSLINUXPATH/isolinux.cfg
-else
+cp $CDMNT/isolinux/* $USBMNT/$SYSLINUXPATH
+BOOTCONFIG=$USBMNT/$SYSLINUXPATH/isolinux.cfg
+if [ -n "$mactel" ];then
   if [ -d $CDMNT/EFI/boot ]; then
     cp $CDMNT/EFI/boot/* $USBMNT/EFI/boot
   else
@@ -599,8 +658,9 @@ echo "Installing boot loader"
 if [ -n "$mactel" ]; then
     # replace the ia32 hack
     if [ -f "$USBMNT/EFI/boot/boot.conf" ]; then cp -f $USBMNT/EFI/boot/bootia32.conf $USBMNT/EFI/boot/boot.conf ; fi
-    cleanup
-elif [ "$USBFS" = "vfat" -o "$USBFS" = "msdos" ]; then
+fi
+
+if [ "$USBFS" = "vfat" -o "$USBFS" = "msdos" ]; then
     # syslinux expects the config to be named syslinux.cfg 
     # and has to run with the file system unmounted
     mv $USBMNT/$SYSLINUXPATH/isolinux.cfg $USBMNT/$SYSLINUXPATH/syslinux.cfg





More information about the Fedora-livecd-list mailing list