]> xenbits.xensource.com Git - people/dariof/xen-tools.git/commitdiff
Factor out legacy grub menu.lst generation
authorAxel Beckert <abe@deuxchevaux.org>
Tue, 22 Jan 2013 01:49:50 +0000 (02:49 +0100)
committerAxel Beckert <abe@deuxchevaux.org>
Thu, 24 Jan 2013 22:06:53 +0000 (23:06 +0100)
debian/changelog
hooks/common.sh
hooks/debian/80-install-kernel
hooks/edgy/80-install-kernel
hooks/intrepid/80-install-kernel
hooks/karmic/80-install-kernel

index 0e93aba7ecb3ddd757d818903dc6f1c378556c69..80b990fb0f30775055afb52c573e19804e193e82 100644 (file)
@@ -28,8 +28,8 @@ xen-tools (4.4~dev-1) UNRELEASED; urgency=low
       initrds also suitable for DomU usage. Trigger update-initramfs.
     - By default install linux-image-virtual instead of linux-image-server
       on Ubuntu Intrepid and newer (Hopefully closes: #640099, LP #839492)
-    - Installs a legacy grub in all pygrub based DomUs to be able to
-      update the menu.list automatically.
+    - Installs a legacy grub in all pygrub based Debian/Ubuntu DomUs to be
+      able to update the menu.list automatically.
     - hooks/common.sh: Rename installCentOS4Package to installRPMPackage.
       Add installCentOS4Package wrapper for backward compatibility.
     - Fix filesystem tools installation in 91-install-fs-tools (which was
index 9796c530500a1ce2bdbc1de2b9468b851e8a4296..59c587f91c053766a56668e1ddef0e3afe950cc9 100755 (executable)
@@ -113,6 +113,143 @@ installDebianPackage ()
 }
 
 
+#
+#  Generate a Debian-/Ubuntu-compliant menu.lst for legacy GRUB
+#
+generateDebianGrubMenuLst ()
+{
+    prefix="$1"
+    DOMU_ISSUE="$2"
+    DOMU_KERNEL="$3"
+    DOMU_RAMDISK="$4"
+
+    #
+    # Log our options
+    #
+    logMessage "Generating a legacy GRUB menu.lst into prefix ${prefix}"
+
+    #
+    #  We require at least 3 parameters
+    #
+    assert "$LINENO" "${prefix}"
+    assert "$LINENO" "${DOMU_ISSUE}"
+    assert "$LINENO" "${DOMU_KERNEL}"
+
+    #
+    # Prefix must be a directory, kernel a file
+    #
+    assert "$LINENO" -d ${prefix}
+    assert "$LINENO" -f "${prefix}/boot/${DOMU_KERNEL}"
+
+    #
+    # Generate a menu.lst for pygrub
+    #
+
+    mkdir -p ${prefix}/boot/grub
+    cat << E_O_MENU > ${prefix}/boot/grub/menu.lst
+default         0
+timeout         2
+
+### BEGIN AUTOMAGIC KERNELS LIST
+## lines between the AUTOMAGIC KERNELS LIST markers will be modified
+## by the debian update-grub script except for the default options below
+
+## DO NOT UNCOMMENT THEM, Just edit them to your needs
+
+## ## Start Default Options ##
+## default kernel options
+## default kernel options for automagic boot options
+## If you want special options for specific kernels use kopt_x_y_z
+## where x.y.z is kernel version. Minor versions can be omitted.
+## e.g. kopt=root=/dev/hda1 ro
+##      kopt_2_6_8=root=/dev/hdc1 ro
+##      kopt_2_6_8_2_686=root=/dev/hdc2 ro
+# kopt=root=/dev/xvda2 ro elevator=noop
+
+## default grub root device
+## e.g. groot=(hd0,0)
+# groot=(hd0,0)
+
+## should update-grub create alternative automagic boot options
+## e.g. alternative=true
+##      alternative=false
+# alternative=true
+
+## should update-grub lock alternative automagic boot options
+## e.g. lockalternative=true
+##      lockalternative=false
+# lockalternative=false
+
+## additional options to use with the default boot option, but not with the
+## alternatives
+## e.g. defoptions=vga=791 resume=/dev/hda5
+# defoptions=
+
+## should update-grub lock old automagic boot options
+## e.g. lockold=false
+##      lockold=true
+# lockold=false
+
+## altoption boot targets option
+## multiple altoptions lines are allowed
+## e.g. altoptions=(extra menu suffix) extra boot options
+##      altoptions=(single-user) single
+# altoptions=(single-user mode) single
+
+## controls how many kernels should be put into the menu.lst
+## only counts the first occurence of a kernel, not the
+## alternative kernel options
+## e.g. howmany=all
+##      howmany=7
+# howmany=all
+
+## should update-grub create memtest86 boot option
+## e.g. memtest86=true
+##      memtest86=false
+# memtest86=false
+
+## should update-grub adjust the value of the default booted system
+## can be true or false
+# updatedefaultentry=false
+
+## should update-grub add savedefault to the default options
+## can be true or false
+# savedefault=false
+
+## ## End Default Options ##
+
+### END DEBIAN AUTOMAGIC KERNELS LIST
+
+# Entries statically generated bu xen-tools upon installation. Maybe
+# removed manually if the entries above (generated by update-grub)
+# seem to work fine.
+
+title           $DOMU_ISSUE
+root            (hd0,0)
+kernel          /boot/$DOMU_KERNEL root=/dev/xvda2 ro elevator=noop
+initrd          /boot/$DOMU_RAMDISK
+
+title           $DOMU_ISSUE (Single-User)
+root            (hd0,0)
+kernel          /boot/$DOMU_KERNEL root=/dev/xvda2 ro single elevator=noop
+initrd          /boot/$DOMU_RAMDISK
+
+title           $DOMU_ISSUE (Default Kernel)
+root            (hd0,0)
+kernel          /vmlinuz root=/dev/xvda2 ro elevator=noop
+initrd          /initrd.img
+
+title           $DOMU_ISSUE (Default Kernel, Single-User)
+root            (hd0,0)
+kernel          /vmlinuz root=/dev/xvda2 ro single elevator=noop
+initrd          /initrd.img
+
+E_O_MENU
+
+
+}
+
+
 
 #
 # Disable the start-stop-daemon
index 5533f556ac9ea6664d7e0c290754c5f349bad813..6a950fef5fada9c2d55dd3bfd8120954fb110496 100755 (executable)
@@ -103,22 +103,8 @@ fi
 # Generate a menu.lst for pygrub
 #
 
-mkdir -p ${prefix}/boot/grub
-cat << E_O_MENU > ${prefix}/boot/grub/menu.lst
-default         0
-timeout         2
-
-title           $DOMU_ISSUE
-root            (hd0,0)
-kernel          /boot/$DOMU_KERNEL root=/dev/xvda2 ro elevator=noop
-initrd          /boot/$DOMU_RAMDISK
-
-title           $DOMU_ISSUE (Single-User)
-root            (hd0,0)
-kernel          /boot/$DOMU_KERNEL root=/dev/xvda2 ro single elevator=noop
-initrd          /boot/$DOMU_RAMDISK
-
-E_O_MENU
+generateDebianGrubMenuLst "${prefix}" "$DOMU_ISSUE" "$DOMU_KERNEL" "$DOMU_RAMDISK"
+
 
 else
     logMessage pygrub not set, skipping kernel install
index 7b047bf1acc2d1be408cb27da4c2d4dc294c8389..8dbee40aaa4b867e9d8c1b1204399f9c78d491e0 100755 (executable)
@@ -78,22 +78,7 @@ fi
 # Generate a menu.lst for pygrub
 #
 
-mkdir -p ${prefix}/boot/grub
-cat << E_O_MENU > ${prefix}/boot/grub/menu.lst
-default         0
-timeout         2
-
-title           $DOMU_ISSUE
-root            (hd0,0)
-kernel          /boot/$DOMU_KERNEL root=/dev/xvda2 ro elevator=noop
-initrd          /boot/$DOMU_RAMDISK
-
-title           $DOMU_ISSUE (Single-User)
-root            (hd0,0)
-kernel          /boot/$DOMU_KERNEL root=/dev/xvda2 ro single elevator=noop
-initrd          /boot/$DOMU_RAMDISK
-
-E_O_MENU
+generateDebianGrubMenuLst "${prefix}" "$DOMU_ISSUE" "$DOMU_KERNEL" "$DOMU_RAMDISK"
 
 
 else
index 0cbb82160641a887245b530261d74046f1067344..eda34fcfba22f2e5c6d99158eee28733d82e7ceb 100755 (executable)
@@ -68,24 +68,7 @@ fi
 # Generate a menu.lst for pygrub
 #
 
-mkdir -p ${prefix}/boot/grub
-cat << E_O_MENU > ${prefix}/boot/grub/menu.lst
-default         0
-timeout         2
-
-title           $DOMU_ISSUE
-root            (hd0,0)
-kernel          /boot/$DOMU_KERNEL root=/dev/xvda2 ro elevator=noop
-initrd          /boot/$DOMU_RAMDISK
-
-title           $DOMU_ISSUE (Single-User)
-root            (hd0,0)
-kernel          /boot/$DOMU_KERNEL root=/dev/xvda2 ro single elevator=noop
-initrd          /boot/$DOMU_RAMDISK
-
-E_O_MENU
-
-
+generateDebianGrubMenuLst "${prefix}" "$DOMU_ISSUE" "$DOMU_KERNEL" "$DOMU_RAMDISK"
 
 else
     logMessage pygrub not set, skipping kernel install
index 7269a58ae7d82526609a9b2b789d01e00fec3f69..d1147c63403d2e7c65ebef2a7ef47576c200d113 100755 (executable)
@@ -54,22 +54,12 @@ DOMU_KERNEL=$(basename $(ls -1 ${prefix}/boot/vmlinuz* | tail -n 1))
 DOMU_RAMDISK=$(basename $(ls -1 ${prefix}/boot/initrd*|tail -n 1))
 DOMU_ISSUE=$(head -n 1 ${prefix}/etc/issue | awk -F '\' '{ print $1 }' | sed 's/[ \t]*$//')
 
-mkdir -p ${prefix}/boot/grub
-cat << E_O_MENU > ${prefix}/boot/grub/menu.lst
-default         0
-timeout         2
-
-title           $DOMU_ISSUE
-root            (hd0,0)
-kernel          /boot/$DOMU_KERNEL root=/dev/xvda2 ro elevator=noop
-initrd          /boot/$DOMU_RAMDISK
-
-title           $DOMU_ISSUE (Single-User)
-root            (hd0,0)
-kernel          /boot/$DOMU_KERNEL root=/dev/xvda2 ro single elevator=noop
-initrd          /boot/$DOMU_RAMDISK
-
-E_O_MENU
+#
+# Generate a menu.lst for pygrub
+#
+
+generateDebianGrubMenuLst "${prefix}" "$DOMU_ISSUE" "$DOMU_KERNEL" "$DOMU_RAMDISK"
+
 
 else
     logMessage "Package '${linux_kernel_package}' is not available"