Fix the "--backportrepos" feature
[grml-debootstrap.git] / chroot-script
index 751eac3..5b9e518 100755 (executable)
@@ -167,14 +167,22 @@ EOF
 
 # check available backports release version {{{
 checkbackports() {
-  wget -q -O/dev/null http://backports.debian.org/debian-backports/dists/${1}-backports/Release
+  wget -q -O/dev/null http://${BACKPORTSMIRROR}/dists/${RELEASE}-backports/Release
 }
 # }}}
 
 # feature to provide Debian backports repos {{{
 backportrepos() {
+    case "$RELEASE" in
+        squeeze)
+            BACKPORTSMIRROR="backports.debian.org/debian-backports"
+            ;;
+        *)
+            BACKPORTSMIRROR="http.debian.net/debian"
+            ;;
+    esac
     if [ -n "$BACKPORTREPOS" ] ; then
-        if ! checkbackports $RELEASE ; then
+        if ! checkbackports  ; then
             echo "Backports for ${RELEASE} are not available." >&2
             exit 1
         else
@@ -182,8 +190,8 @@ backportrepos() {
             if ! grep -q backports /etc/apt/sources.list.d/backports.list 2>/dev/null ; then
                 cat >> /etc/apt/sources.list.d/backports.list << EOF
 # debian backports: ${RELEASE}-backports repository:
-deb     http://backports.debian.org/debian-backports ${RELEASE}-backports main
-deb-src http://backports.debian.org/debian-backports ${RELEASE}-backports main
+deb     http://${BACKPORTSMIRROR} ${RELEASE}-backports main
+deb-src http://${BACKPORTSMIRROR} ${RELEASE}-backports main
 EOF
             fi
         fi
@@ -292,7 +300,7 @@ get_kernel_version() {
   fi
 
   case $ARCH in
-    i386)   KARCH=i686  ;;
+    i386)   KARCH=686   ;;
     amd64)  KARCH=amd64 ;;
     *)
       echo "Only i386 and amd64 are currently supported" >&2
@@ -317,6 +325,8 @@ kernel() {
      # note: install busybox to be able to debug initramfs
      KERNELPACKAGES="linux-image-$KVER linux-headers-$KVER busybox firmware-linux-free firmware-linux"
      DEBIAN_FRONTEND=$DEBIAN_FRONTEND $APTINSTALL $KERNELPACKAGES
+  else
+     echo "Warning: Could not find a kernel for your system. Your system won't be able to boot itself!"
   fi
 }
 # }}}