Support and enable per default --keyring option. [Closes: issue746]
[grml-debootstrap.git] / grml-debootstrap
index c8075d8..99e71ac 100755 (executable)
@@ -11,7 +11,7 @@ set -e # exit on any error
 
 # variables {{{
 PN="$(basename $0)"
-VERSION='0.32'
+VERSION='0.33-pre1'
 MNTPOINT="/mnt/debootstrap.$$"
 
 # inside the chroot system locales might not be available, so use minimum:
@@ -49,6 +49,7 @@ Bootstrap options:
       --nodebootstrap    Skip debootstrap, only do configuration to the target.
       --grub <device>    Target for grub installation. Usage example: /dev/sda
       --arch <arch>      Architecture to use. Currently only i386 is supported.
+      --insecure         Do not download and check Release file signatures.
 
 Configuration options:
 
@@ -147,6 +148,7 @@ fi
 [ "$_opt_bootappend" ]          && BOOT_APPEND=$_opt_bootappend
 [ "$_opt_grub" ]                && GRUB=$_opt_grub
 [ "$_opt_arch" ]                && ARCH=$_opt_arch
+[ "$_opt_insecure" ]            && SECURE='false'
 [ "$_opt_verbose" ]             && VERBOSE="-v"
 
 [ "$_opt_help" ] && {
@@ -163,6 +165,21 @@ fi
 }
 # }}}
 
+# backwards compability checks {{{
+if [ -n "$GROOT" ] ; then
+   echo "Error: you seem to have \$GROOT configured." >&2
+   echo "This variable is no longer supported, please visit the" >&2
+   echo "grml-debootstrap documentation for details." >&2
+   exit 1
+fi
+
+if echo "$GRUB" | grep -q '^hd' ; then
+   echo "Error: this syntax for the grub configuration variable is no longer supported." >&2
+   echo "Please do not use hd... any longer but /dev/sdX instead." >&2
+   exit 1
+fi
+# }}}
+
 # welcome screen {{{
 welcome_dialog()
 {
@@ -237,7 +254,6 @@ prompt_for_bootmanager()
   GETMBR=$(dialog --stdout --title "$PN" --default-item mbr \
           --menu "Where do you want to install the bootmanager grub?" 0 0 0 \
             mbr       "install bootmanager into $MBRPART" \
-            partition "install bootmanager into partition $TARGET" \
             nowhere   "do not install bootmanager at all" \
           ${ADDITIONAL_PARAMS})
   [ $? -eq 0 ] || bailout 3
@@ -257,9 +273,6 @@ prompt_for_bootmanager()
         GRUB="$MBRDISK"
       fi
       ;;
-    partition)
-      GRUB="$TARGET"
-      ;;
     hda)
       GRUB="/dev/hda"
       ;;
@@ -580,6 +593,19 @@ else
 fi
 # }}}
 
+# keyring setupt {{{
+KEYRING=""
+if [ "$SECURE" = 'yes' ] ; then
+   if [ -e '/etc/apt/trusted.gpg' ] ; then
+      KEYRING="--keyring /etc/apt/trusted.gpg"
+   else
+      eerror "Could not find /etc/apt/trusted.gpg."
+   fi
+else
+   ewarn "Not checking Release signatures!"
+fi
+# }}}
+
 # make sure we have the right syntax when using an iso image {{{
 if [ -n "$ISO" ] ; then
    case $ISO in
@@ -724,9 +750,9 @@ debootstrap_system() {
   if grep -q "$MNTPOINT" /proc/mounts || [ -n "$DIRECTORY" ] ; then
      einfo "Running $DEBOOTSTRAP $DEBOOTSTRAP_OPT for release ${RELEASE}${ARCHINFO} using ${MIRROR}${ISO}"
      if [ -n "$MIRROR" ] ; then
-        $DEBOOTSTRAP $ARCHCMD $DEBOOTSTRAP_OPT $RELEASE $MNTPOINT $MIRROR
+        $DEBOOTSTRAP $ARCHCMD $KEYRING $DEBOOTSTRAP_OPT $RELEASE $MNTPOINT $MIRROR
      else
-        $DEBOOTSTRAP $ARCHCMD $DEBOOTSTRAP_OPT $RELEASE $MNTPOINT $ISO
+        $DEBOOTSTRAP $ARCHCMD $KEYRING $DEBOOTSTRAP_OPT $RELEASE $MNTPOINT $ISO
      fi
      eend $?
   else