Ensure that grub-pc/install_devices is pointing to the requested device
[grml-debootstrap.git] / chroot-script
index b283991..978eea3 100755 (executable)
@@ -36,9 +36,9 @@ if [ -x /usr/bin/aptitude ] ; then
       APTUPGRADE="aptitude -y safe-upgrade $DPKG_OPTIONS"
    fi
 else
       APTUPGRADE="aptitude -y safe-upgrade $DPKG_OPTIONS"
    fi
 else
-   APTINSTALL="apt-get --force-yes -y --no-install-recommends install $DPKG_OPTIONS"
+   APTINSTALL="apt-get -y --no-install-recommends install $DPKG_OPTIONS"
    APTUPDATE="apt-get update $DPKG_OPTIONS"
    APTUPDATE="apt-get update $DPKG_OPTIONS"
-   APTUPGRADE="apt-get --force-yes -y upgrade $DPKG_OPTIONS"
+   APTUPGRADE="apt-get -y upgrade $DPKG_OPTIONS"
 fi
 
 if [ -z "$STAGES" ] ; then
 fi
 
 if [ -z "$STAGES" ] ; then
@@ -78,7 +78,7 @@ chrootmirror() {
   fi
 
   if [ -z "$COMPONENTS" ] ; then
   fi
 
   if [ -z "$COMPONENTS" ] ; then
-    COMPONENTS='main contrib non-free'
+    COMPONENTS='main'
   fi
   echo "Using repository components $COMPONENTS"
 
   fi
   echo "Using repository components $COMPONENTS"
 
@@ -569,6 +569,11 @@ grub_install() {
     return 0
   fi
 
     return 0
   fi
 
+  # make sure this is pre-defined so we have sane settings for automated
+  # upgrades, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=711019
+  echo "Setting grub-pc debconf configuration for install device to $GRUB"
+  echo "grub-pc grub-pc/install_devices multiselect $GRUB" | debconf-set-selections
+
   if ! dpkg --list grub-pc 2>/dev/null | grep -q '^ii' ; then
     echo "Notice: grub option set but no grub-pc package, installing it therefore."
     DEBIAN_FRONTEND=$DEBIAN_FRONTEND $APTINSTALL grub-pc
   if ! dpkg --list grub-pc 2>/dev/null | grep -q '^ii' ; then
     echo "Notice: grub option set but no grub-pc package, installing it therefore."
     DEBIAN_FRONTEND=$DEBIAN_FRONTEND $APTINSTALL grub-pc
@@ -585,11 +590,13 @@ grub_install() {
         echo "Installing grub on ${GRUB}:"
         grub-install --no-floppy "$GRUB"
      done
         echo "Installing grub on ${GRUB}:"
         grub-install --no-floppy "$GRUB"
      done
+     rm -f /boot/grub/device.map
   else
      echo "Installing grub on ${GRUB}:"
      case "$RELEASE" in
        lenny|squeeze|wheezy)
          grub-install --no-floppy "$(readlink -f "${GRUB}")"
   else
      echo "Installing grub on ${GRUB}:"
      case "$RELEASE" in
        lenny|squeeze|wheezy)
          grub-install --no-floppy "$(readlink -f "${GRUB}")"
+         rm -f /boot/grub/device.map
          ;;
        *)
          echo "(hd0) ${GRUB}" > /boot/grub/device.map
          ;;
        *)
          echo "(hd0) ${GRUB}" > /boot/grub/device.map