Update MirOS bsd4grml to 20090812
[grml-live.git] / grml-live
index 17222ba..40f3ceb 100755 (executable)
--- a/grml-live
+++ b/grml-live
@@ -23,7 +23,7 @@ fi
 # exit on any error:
 set -e
 
-GRML_LIVE_VERSION='0.9.18'
+GRML_LIVE_VERSION='0.9.20'
 PN="$(basename $0)"
 CMDLINE="$0 $@"
 ISO_DATE="$(date +%Y-%m-%d)"
@@ -230,11 +230,7 @@ while getopts "a:C:c:g:i:o:r:s:t:v:bBFuqVz" opt; do
     C) CONFIG="$OPTARG" ;;
     g) GRML_NAME="$OPTARG" ;;
     i) ISO_NAME="$OPTARG" ;;
-    o) OUTPUT="$OPTARG"
-       CHROOT_OUTPUT="$OUTPUT/grml_chroot"
-       BUILD_OUTPUT="$OUTPUT/grml_cd"
-       ISO_OUTPUT="$OUTPUT/grml_isos"
-       ;;
+    o) OUTPUT="$OPTARG" ;;
     q) SKIP_MKSQUASHFS=1 ;;
     r) RELEASENAME="$OPTARG" ;;
     s) SUITE="$OPTARG" ;;
@@ -256,6 +252,11 @@ specify it on the command line using the -c option."
 [ -n "$OUTPUT" ] || bailout 1 "Error: \$OUTPUT unset, please set it in $LIVE_CONF or
 specify it on the command line using the -o option."
 
+# set subdirectories according to $OUTPUT:
+CHROOT_OUTPUT="$OUTPUT/grml_chroot"
+BUILD_OUTPUT="$OUTPUT/grml_cd"
+ISO_OUTPUT="$OUTPUT/grml_isos"
+
 # trim characters that are known to cause problems inside $GRML_NAME;
 # for example isolinux does not like '-' inside the directory name
 [ -n "$GRML_NAME" ] && export SHORT_GRML_NAME="$(echo $GRML_NAME | tr -d ',./;\- ')"
@@ -378,6 +379,15 @@ if [ -n "$SUITE" ] ; then
    # /usr/share/debootstrap/scripts/unstable does not exist, instead use 'sid':
    case $SUITE in
       unstable) SUITE='sid' ;;
+      # make sure that we *NEVER* write any broken suite name to sources.list,
+      # otherwise we won't be able to adjust it one next (correct) execution
+      stable)   ;;
+      testing)  ;;
+      etch)     ;;
+      lenny)    ;;
+      squeeze)  ;;
+      sid)      ;;
+      *) echo "Sorry, $SUITE is not a valid Debian suite, exiting.">&2; bailout 1 ;;
    esac
 
    DIST=" etch\| stable\| lenny\| squeeze\| testing\| sid\| unstable"
@@ -406,6 +416,22 @@ if [ -n "$SUITE" ] ; then
    done
 fi
 
+# validate whether the specified architecture class matches the
+# architecture (option), otherwise installation of kernel will fail
+if echo $CLASSES | grep -qi i386 ; then
+   if ! [[ "$ARCH" == "i386" ]] ; then
+      eerror "You specified the I386 class but are trying to build something else (AMD64?)."
+      eerror "-> Either invoke grml-live with '-i i386' or adjust the architecture class. Exiting."
+      bailout
+   fi
+elif echo $CLASSES | grep -qi amd64 ; then
+   if ! [[ "$ARCH" == "amd64" ]] ; then
+      eerror "You specified the AMD64 class but are trying to build something else (I386?)."
+      eerror "-> Either invoke grml-live with '-i amd64' or adjust the architecture class. Exiting."
+      bailout
+   fi
+fi
+
 # set $ARCH
 [ -n "$ARCH" ] || ARCH="$(dpkg --print-architecture)"
 if grep -q -- 'FAI_DEBOOTSTRAP_OPTS.*--arch' "$NFSROOT_CONF" ; then
@@ -421,6 +447,12 @@ if [ -n "$BUILD_DIRTY" ]; then
 else
    [ -n "$CHROOT_OUTPUT" ] || CHROOT_OUTPUT="$OUTPUT/grml_chroot"
 
+   # provide inform fai about the ISO we build
+   [ -d "$CHROOT_OUTPUT/etc/" ] || mkdir -p "$CHROOT_OUTPUT/etc/"
+   echo '# This file has been generated by grml-live.' > "$CHROOT_OUTPUT/etc/grml_live_version"
+   [ -n "$GRML_LIVE_VERSION" ] && echo "GRML_LIVE_VERSION=$GRML_LIVE_VERSION" >> "$CHROOT_OUTPUT/etc/grml_live_version"
+   [ -n "$SUITE" ] && echo "SUITE=$SUITE" >> "$CHROOT_OUTPUT/etc/grml_live_version"
+
    if [ -n "$UPDATE" -o -n "$BUILD_ONLY" ] ; then
       FAI_ACTION=softupdate
    else
@@ -760,10 +792,21 @@ if [ -f "${ISO_OUTPUT}/${ISO_NAME}" -a -z "$UPDATE" -a -z "$BUILD_ONLY" -a -z "$
 else
    mkdir -p "$ISO_OUTPUT" || bailout 6 "Problem with creating $ISO_OUTPUT for stage 'iso build'"
 
+   # support mkisofs as well as genisoimage
+   if which mkisofs >/dev/null 2>&1; then
+      MKISOFS='mkisofs'
+   elif which genisoimage >/dev/null 2>&1; then
+      MKISOFS='genisoimage'
+   else
+      log "Sorry, neither mkisofs nor genisoimage available - can not create ISO."
+      eerror "Sorry, neither mkisofs nor genisoimage available - can not create ISO." ; eend 1
+      bailout
+   fi
+
    CURRENT_DIR=$(pwd)
    if cd "$BUILD_OUTPUT" ; then
-      log "mkisofs -V '${GRML_NAME} ${VERSION}' -publisher 'grml-live | grml.org' -l -r -J -no-emul-boot -boot-load-size 4 -boot-info-table -b $BOOT_FILE -o ${ISO_OUTPUT}/${ISO_NAME} ."
-      mkisofs -V "${GRML_NAME} ${VERSION}" -publisher 'grml-live | grml.org' \
+      log "$MKISOFS -V '${GRML_NAME} ${VERSION}' -publisher 'grml-live | grml.org' -l -r -J -no-emul-boot -boot-load-size 4 -boot-info-table -b $BOOT_FILE -o ${ISO_OUTPUT}/${ISO_NAME} ."
+      "$MKISOFS" -V "${GRML_NAME} ${VERSION}" -publisher 'grml-live | grml.org' \
               -l -r -J -no-emul-boot -boot-load-size 4 -boot-info-table    \
               -b $BOOT_FILE -no-pad \
               -o "${ISO_OUTPUT}/${ISO_NAME}" . ; RC=$?
@@ -835,8 +878,8 @@ fi
 
 # finalize {{{
 [ -n "$start_seconds" ] && SECONDS="$[$(cut -d . -f 1 /proc/uptime)-$start_seconds]" || SECONDS="unknown"
-einfo "Sucessfully finished execution of $PN [running ${SECONDS} seconds]" ; eend 0
-log "Sucessfully finished execution of $PN [running ${SECONDS} seconds]"
+einfo "Successfully finished execution of $PN [running ${SECONDS} seconds]" ; eend 0
+log "Successfully finished execution of $PN [running ${SECONDS} seconds]"
 bailout 0
 # }}}