b7bcbe6215
--target param is not supported in precise Change-Id: Ie369ed9d53dbb462cf253144251da4d5c463107c Fixes: bug #1175275
44 lines
1.5 KiB
Bash
Executable file
44 lines
1.5 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Configure grub. Note that the various conditionals here are to handle
|
|
# different distributions gracefully.
|
|
|
|
set -e
|
|
set -x
|
|
|
|
install-packages grub-pc
|
|
|
|
# XXX: grub-probe on the nbd0/loop0 device returns nothing - workaround, manually
|
|
# specify modules. https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1073731
|
|
GRUBNAME=`which grub-install` || echo "trying grub2-install"
|
|
if [ -z "$GRUBNAME" ]; then
|
|
GRUBNAME="bash -x `which grub2-install`"
|
|
fi
|
|
if [ -z "$GRUBNAME" ]; then
|
|
echo "NO grub-install or grub2-install found"
|
|
exit 1
|
|
fi
|
|
# FIXME:
|
|
[ -n "$IMAGE_BLOCK_DEVICE" ]
|
|
PART_DEV=$IMAGE_BLOCK_DEVICE
|
|
BOOT_DEV=$(echo $IMAGE_BLOCK_DEVICE | sed -e 's/p1//')
|
|
GRUB_OPTS=${GRUB_OPTS:---modules="biosdisk part_msdos"}
|
|
if [ $DIB_RELEASE != 'precise' ]; then
|
|
GRUB_OPTS="$GRUB_OPTS --target=i386-pc"
|
|
fi
|
|
$GRUBNAME $GRUB_OPTS $BOOT_DEV
|
|
# This might be better factored out into a per-distro 'install-bootblock'
|
|
# helper.
|
|
if [ -f "/boot/grub/grub.cfg" ] ; then
|
|
GRUB_CFG=/boot/grub/grub.cfg
|
|
elif [ -f "/boot/grub2/grub.cfg" ] ; then
|
|
GRUB_CFG=/boot/grub2/grub.cfg
|
|
fi
|
|
# grub-mkconfig generates a config with the device in it,
|
|
# force use of a LABEL:
|
|
# NOTE: Updating the grub config by hand once deployed should work, its just
|
|
# prepping it in a different environment that needs fiddling.
|
|
sed -i "s%$PART_DEV%LABEL=cloudimg-rootfs%" $GRUB_CFG
|
|
sed -i "s%search --no-floppy --fs-uuid --set=root .*$%search --no-floppy --set=root --label cloudimg-rootfs%" $GRUB_CFG
|
|
sed -i "s%root=UUID=[A-Za-z0-9\-]*%root=LABEL=cloudimg-rootfs%" $GRUB_CFG
|
|
|