1
0
mirror of synced 2026-04-26 04:16:54 +00:00

Factor out legacy grub menu.lst generation

This commit is contained in:
Axel Beckert
2013-01-22 02:49:50 +01:00
parent 1de424a69d
commit 57c7d13c48
6 changed files with 146 additions and 65 deletions

4
debian/changelog vendored
View 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

View File

@@ -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

View File

@@ -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
generateDebianGrubMenuLst "${prefix}" "$DOMU_ISSUE" "$DOMU_KERNEL" "$DOMU_RAMDISK"
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
else
logMessage pygrub not set, skipping kernel install

View File

@@ -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

View File

@@ -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

View File

@@ -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
#
# Generate a menu.lst for pygrub
#
title $DOMU_ISSUE
root (hd0,0)
kernel /boot/$DOMU_KERNEL root=/dev/xvda2 ro elevator=noop
initrd /boot/$DOMU_RAMDISK
generateDebianGrubMenuLst "${prefix}" "$DOMU_ISSUE" "$DOMU_KERNEL" "$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
else
logMessage "Package '${linux_kernel_package}' is not available"