fix grub2 installation on Debian Wheezy

--target has been introduced in grub2. This patch ensure we use
the minimal version before adding the --target XXX flag.

Debian Wheezy and Precise share the same limitation regarding the
root device.

Change-Id: I5b3ad42b9fb536d13fb65d84339bc15bc23d99a3
This commit is contained in:
Gonéri Le Bouder 2014-03-27 17:57:18 +01:00
parent f49e8a42c4
commit 341d7aaff7

View File

@ -88,7 +88,7 @@ function install_grub2 {
# - --target=i386-pc is invalid for non-i386/amd64 architectures # - --target=i386-pc is invalid for non-i386/amd64 architectures
# - and for UEFI too. # - and for UEFI too.
# GRUB_OPTS="$GRUB_OPTS --target=i386-pc" # GRUB_OPTS="$GRUB_OPTS --target=i386-pc"
if [[ ! $GRUB_OPTS == *--target* ]]; then if [[ ! $GRUB_OPTS == *--target* ]] && [[ $($GRUBNAME --version) =~ ' 2.' ]]; then
# /sys/ comes from the host machine. If the host machine is using EFI # /sys/ comes from the host machine. If the host machine is using EFI
# but the image being built doesn't have EFI boot-images installed we # but the image being built doesn't have EFI boot-images installed we
# should set the --target to use a BIOS-based boot-image. # should set the --target to use a BIOS-based boot-image.
@ -153,9 +153,7 @@ function install_grub2 {
[ -n "$RELEASE" ] [ -n "$RELEASE" ]
# grub-mkconfig generates a config with the device in it, # grub-mkconfig generates a config with the device in it,
# This shouldn't be needed, but old code has bugs # This shouldn't be needed, but old code has bugs
if [ $RELEASE = 'precise' ] ; then if [ $RELEASE = 'precise' ] || [ $RELEASE = 'wheezy' ]; then
# Replace the search attempt with a hardcoded root as the Ubuntu reference
# images use.
sed -i "s%search --no.*%%" $GRUB_CFG sed -i "s%search --no.*%%" $GRUB_CFG
sed -i "s%set root=.*%set root=(hd0,1)%" $GRUB_CFG sed -i "s%set root=.*%set root=(hd0,1)%" $GRUB_CFG
fi fi