Honor GRUB_DISABLE_LINUX_UUID=true for all Debian releases
[grml-debootstrap.git] / grml-debootstrap
index 9a67754..61dab37 100755 (executable)
@@ -794,7 +794,7 @@ efi_support() {
     return 0
   fi
 
     return 0
   fi
 
-  if modprobe efivars ; then
+  if modprobe efivars &>/dev/null ; then
     einfo "EFI support enabled now." ; eend 0
     return 0
   fi
     einfo "EFI support enabled now." ; eend 0
     return 0
   fi
@@ -1055,6 +1055,24 @@ mkfs() {
         einfo "Enabling force option (-F) for mkfs.ext* tool as requested via --force switch."
         MKFS_OPTS="$MKFS_OPTS -F"
         eend 0
         einfo "Enabling force option (-F) for mkfs.ext* tool as requested via --force switch."
         MKFS_OPTS="$MKFS_OPTS -F"
         eend 0
+
+        ;;
+    esac
+  fi
+
+  # starting with e2fsprogs 1.43~WIP.2015.05.18-1 mkfs.ext4 enables the metadata_csum feature
+  # by default, which requires a recent version of tune2fs on the target system then,
+  # so disable this feature for older Debian releases where it's known to be unsupported
+  if [ -n "$MKFS" ] && [ "$MKFS" = "mkfs.ext4" ] ; then
+    case "$RELEASE" in
+      lenny|squeeze|wheezy|jessie)
+        # assume a more recent version if we can't identify the version via dpkg-query
+        local e2fsprogs_version="$(dpkg-query --show --showformat='${Version}' e2fsprogs 2>/dev/null || echo 1.44)"
+        if [ -n "$e2fsprogs_version" ] && dpkg --compare-versions "$e2fsprogs_version" ge '1.43~WIP.2015.05.18-1' ; then
+          einfo "Disabling metadata_csum feature for $MKFS as $RELEASE doesn't support it."
+          MKFS_OPTS="$MKFS_OPTS -O ^metadata_csum"
+          eend 0
+        fi
         ;;
     esac
   fi
         ;;
     esac
   fi
@@ -1270,17 +1288,13 @@ fi
       ;;
   esac
 
       ;;
   esac
 
-  case "$RELEASE" in
-    lenny|squeeze|wheezy)
-      if grep -q '^GRUB_DISABLE_LINUX_UUID=.*true' "${MNTPOINT}"/etc/default/grub 2>/dev/null ; then
-        ewarn "GRUB_DISABLE_LINUX_UUID is set to true in /etc/default/grub, not adjusting root= in grub.cfg."
-        ewarn "Please note that your system might NOT be able to properly boot."
-      else
-        einfo "Adjusting grub.cfg for successful boot sequence."
-        sed -i "s;root=[^ ]\+;root=UUID=$TARGET_UUID;" "${MNTPOINT}"/boot/grub/grub.cfg
-      fi
-      ;;
-  esac
+  if grep -q '^GRUB_DISABLE_LINUX_UUID=.*true' "${MNTPOINT}"/etc/default/grub 2>/dev/null ; then
+    ewarn "GRUB_DISABLE_LINUX_UUID is set to true in /etc/default/grub, not adjusting root= in grub.cfg."
+    ewarn "Please note that your system might NOT be able to properly boot."
+  else
+    einfo "Adjusting grub.cfg for successful boot sequence."
+    sed -i "s;root=[^ ]\+;root=UUID=$TARGET_UUID;" "${MNTPOINT}"/boot/grub/grub.cfg
+  fi
 
   umount "${MNTPOINT}"/proc
   umount "${MNTPOINT}"/sys
 
   umount "${MNTPOINT}"/proc
   umount "${MNTPOINT}"/sys
@@ -1512,8 +1526,9 @@ execute_pre_scripts() {
 
 # execute all scripts in /etc/debootstrap/post-scripts/ {{{
 execute_post_scripts() {
 
 # execute all scripts in /etc/debootstrap/post-scripts/ {{{
 execute_post_scripts() {
-  # make sure we have $MNTPOINT available for our scripts
+  # make sure we have $MNTPOINT and HOSTNAME available for our scripts
   export MNTPOINT
   export MNTPOINT
+  export TARGET_HOSTNAME=$HOSTNAME
 
   if [ -d "$_opt_scripts" ] || [ "$SCRIPTS" = 'yes' ] ; then
     # legacy support for /etc/debootstrap/scripts/
 
   if [ -d "$_opt_scripts" ] || [ "$SCRIPTS" = 'yes' ] ; then
     # legacy support for /etc/debootstrap/scripts/