Do not install package 'grml' via GRMLBASE; generate md5sum of ISO; update buildd/
[grml-live.git] / grml-live
index c3e8b53..d402757 100755 (executable)
--- a/grml-live
+++ b/grml-live
@@ -4,7 +4,7 @@
 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2 or any later version.
-# Latest change: Sun Nov 25 20:08:06 CET 2007 [mika]
+# Latest change: Sun Dec 09 18:18:27 CET 2007 [mika]
 ################################################################################
 
 # read configuration files, set some misc variables {{{
@@ -15,7 +15,7 @@ export LC_ALL=C
 # exit on any error:
 set -e
 
-GRML_LIVE_VERSION='0.0.10'
+GRML_LIVE_VERSION='0.0.12'
 CMDLINE="$0 $@"
 ISO_DATE="$(date +%Y-%m-%d)"
 
@@ -100,6 +100,8 @@ fi
 if [ -n "$ZERO_FAI_LOGFILE" ] ; then
    if [ -d /var/log/fai/"$HOSTNAME" ] ; then
       rm -rf /var/log/fai/"$HOSTNAME"/"$(readlink /var/log/fai/"$HOSTNAME"/last)"
+      rm -rf /var/log/fai/"$HOSTNAME"/"$(readlink /var/log/fai/"$HOSTNAME"/last-dirinstall)"
+      rm -rf /var/log/fai/"$HOSTNAME"/"$(readlink /var/log/fai/"$HOSTNAME"/last-softupdate)"
    fi
 fi
 
@@ -187,7 +189,7 @@ http://grml.org/bugs/
 
 # command line parsing {{{
 
-while getopts "a:C:c:g:i:o:r:s:t:v:FhuV" opt; do
+while getopts "a:C:c:g:i:o:r:s:t:v:FhuVz" opt; do
   case "$opt" in
     a) ARCH="$OPTARG" ;;
     c) CLASSES="$OPTARG" ;;
@@ -207,6 +209,7 @@ while getopts "a:C:c:g:i:o:r:s:t:v:FhuV" opt; do
     h) usage ; bailout 0 ;;
     u) UPDATE=1 ;;
     V) VERBOSE="-v" ;;
+    z) SQUASHFS_ZLIB="-nolzma" ;;
     ?) echo "invalid option -$OPTARG" >&2; bailout 1 ;;
   esac
 done
@@ -220,14 +223,26 @@ specify it on the command line using the -c option."
 specify it on the command line using the -o option."
 # }}}
 
+# read local (non-packaged) configuration {{{
+LOCAL_CONFIG=/etc/grml/grml-live.local
+if [ -r "$LOCAL_CONFIG" ] ; then
+   log "Sourcing $LOCAL_CONFIG"
+   . $LOCAL_CONFIG
+else
+   log "No $LOCAL_CONFIG found, not sourcing it"
+   LOCAL_CONFIG=''
+fi
+# }}}
+
 # ask user whether the setup is ok {{{
 if [ -z "$FORCE" ] ; then
    echo
    echo "${PN} [${GRML_LIVE_VERSION}]: check your configuration (or use -F to force execution):"
    echo
    echo "  FAI classes:       $CLASSES"
-   echo "  main directory:    $OUTPUT"
+   [ -r "$LOCAL_CONFIG" ]  && echo "  local config:      /etc/grml/grml-live.local"
    [ -n "$CONFIG" ]        && echo "  configuration:     $CONFIG"
+   echo "  main directory:    $OUTPUT"
    [ -n "$CHROOT_OUTPUT" ] && echo "  chroot target:     $CHROOT_OUTPUT"
    [ -n "$BUILD_OUTPUT" ]  && echo "  build target:      $BUILD_OUTPUT"
    [ -n "$ISO_OUTPUT" ]    && echo "  ISO target:        $ISO_OUTPUT"
@@ -241,6 +256,7 @@ if [ -z "$FORCE" ] ; then
    [ -n "$FAI_ARGS" ]      && echo "  additional arguments for FAI: $FAI_ARGS"
    [ -n "$LOGFILE" ]       && echo "  Logging to file:   $LOGFILE"
    [ -n "$VERBOSE" ]       && echo "  Using VERBOSE mode."
+   [ -n "$SQUASHFS_ZLIB" ] && echo "  Using ZLIB (instead od LZMA) compression."
    [ -n "$UPDATE" ]        && echo "  Executing UPDATE instead of fresh installation."
    echo
    echo -n "Is this ok for you? [y/N] "
@@ -251,15 +267,6 @@ if [ -z "$FORCE" ] ; then
    echo
 fi
 
-# read local (non-packaged) configuration:
-LOCAL_CONFIG=/etc/grml/grml-live.local
-if [ -r "$LOCAL_CONFIG" ] ; then
-   log "Sourcing $LOCAL_CONFIG"
-   . $LOCAL_CONFIG
-else
-   LOCAL_CONFIG=''
-fi
-
 if [ -n "$CONFIG" ] ; then
    if ! [ -f "$CONFIG" ] ; then
       log "Sorry, $CONFIG could not be read. Exiting. [$(date)]"
@@ -349,8 +356,8 @@ fi
 
 if [ -n "$UPDATE" ] ; then
    if ! [ -r "$CHROOT_OUTPUT/etc/grml_version" ] ; then
-      log "Error: It does not look like you have a working chroot system. Updating not possible."
-      eerror "Error: It does not look like you have a working chroot system. Updating not possible."
+      log "Error: does not look like you have a working chroot. Updating not possible."
+      eerror "Error: does not look like you have a working chroot. Updating not possible. (Drop -u option?)"
       eend 1
       bailout 20
    fi
@@ -448,11 +455,6 @@ if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then
          bailout 11
       fi
 
-      cp /usr/lib/syslinux/chain.c32     "$BUILD_OUTPUT"/boot/isolinux/
-      cp /usr/lib/syslinux/isolinux.bin  "$BUILD_OUTPUT"/boot/isolinux/
-      cp /usr/lib/syslinux/memdisk       "$BUILD_OUTPUT"/boot/isolinux/
-      cp /usr/lib/syslinux/menu.c32      "$BUILD_OUTPUT"/boot/isolinux/
-
       [ -n "$TEMPLATE_DIRECTORY" ] || TEMPLATE_DIRECTORY='/usr/share/grml-live/templates'
       if ! [ -d "${TEMPLATE_DIRECTORY}"/boot ] ; then
          log "${TEMPLATE_DIRECTORY}/boot does not exist. Exiting."
@@ -531,7 +533,12 @@ if [ -f "$BUILD_OUTPUT"/live/grml.squashfs -a -z "$UPDATE" ] ; then
    ewarn "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs'" ; eend 0
 else
    [ -d "$BUILD_OUTPUT"/live ] || mkdir "$BUILD_OUTPUT"/live
-   mksquashfs $CHROOT_OUTPUT/* $BUILD_OUTPUT/live/grml.squashfs -noappend
+   # make sure we don't leave (even an empty) base.tgz:
+   [ -f "$CHROOT_OUTPUT/base.tgz" ] && rm -f "$CHROOT_OUTPUT/base.tgz"
+
+   # execute squashfs:
+   log "mksquashfs $CHROOT_OUTPUT/* $BUILD_OUTPUT/live/grml.squashfs -noappend"
+   mksquashfs $CHROOT_OUTPUT/* $BUILD_OUTPUT/live/grml.squashfs -noappend $SQUASHFS_OPTIONS $SQUASHFS_ZLIB
    log "Finished execution of stage 'squashfs' [$(date)]"
    einfo "Finished execution of stage 'squashfs'" ; eend 0
 fi
@@ -556,13 +563,27 @@ if [ -f "${ISO_OUTPUT}/${ISO_NAME}" -a -z "$UPDATE" ] ; then
    ewarn "$ISO_OUTPUT exists already, skipping stage 'iso build'" ; eend 0
 else
    mkdir -p "$ISO_OUTPUT" || bailout 6 "Problem with creating $ISO_OUTPUT for stage 'iso build'"
+
    CURRENT_DIR=$(pwd)
-   cd "$BUILD_OUTPUT" &&
-   mkisofs -V "grml $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}" . ; RC=$?
-   cd $CURRENT_DIR
+   if cd "$BUILD_OUTPUT" ; then
+      log "mkisofs -V grml '$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 $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}" . ; RC=$?
+
+      # generate md5sum of ISO if we are using class 'RELEASE':
+      case $CLASSES in *RELEASES*)
+         [ "$RC" = 0 ] && \
+         ( cd $ISO_OUTPUT && \
+         md5sum ${ISO_NAME} > ${ISO_NAME}.md5 && \
+         touch -r ${ISO_NAME} ${ISO_NAME}.md5 )
+         ;;
+      esac
+
+      cd $CURRENT_DIR
+   fi
+
    if [ "$RC" = 0 ] ; then
       log "Finished execution of stage 'iso build' [$(date)]"
       einfo "Finished execution of stage 'iso build'" ; eend 0