Ensure that grub-pc is installed in VMs even when using --nopackages
authorMichael Prokop <mika@grml.org>
Thu, 4 Jun 2015 11:40:12 +0000 (13:40 +0200)
committerMichael Prokop <mika@grml.org>
Thu, 4 Jun 2015 11:41:55 +0000 (13:41 +0200)
We're always setting up GRUB as bootloader when installing a VM.
If the --nopackages options is present the grub-pc package is
missing inside the VM. Therefore ensure that the grub-pc is still
present.

Fixes #40 @ github

grml-debootstrap

index 104f454..7fd52a2 100755 (executable)
@@ -1158,6 +1158,12 @@ finalize_vm() {
 # chroot-script skips installation for unset ${GRUB}
 if [[ -z "${GRUB}" ]] || ! dd if="${GRUB}" bs=512 count=1 2>/dev/null | cat -v | fgrep -q GRUB; then
   einfo "Installing Grub as bootloader."
+
+  if ! chroot "${MNTPOINT}" dpkg --list grub-pc 2>/dev/null | grep -q '^ii' ; then
+    echo "Notice: grub-pc package not present yet, installing it therefore."
+    DEBIAN_FRONTEND=$DEBIAN_FRONTEND chroot "$MNTPOINT" apt-get -y install $DPKG_OPTIONS grub-pc
+  fi
+
   mkdir -p "${MNTPOINT}/boot/grub"
   if ! [ -d "${MNTPOINT}"/usr/lib/grub/i386-pc/ ] ; then
      eerror "Error: grub not installed inside Virtual Machine. Can not install bootloader." ; eend 1