Add genext2fs to GRML_FULL and GRML_MEDIUM
[grml-live.git] / grml-live
index 2694a25..21eea56 100755 (executable)
--- a/grml-live
+++ b/grml-live
@@ -14,7 +14,7 @@ export LC_ALL=C
 # exit on any error:
 set -e
 
-GRML_LIVE_VERSION='0.9.4'
+GRML_LIVE_VERSION='0.9.7'
 PN="$(basename $0)"
 CMDLINE="$0 $@"
 ISO_DATE="$(date +%Y-%m-%d)"
@@ -36,6 +36,7 @@ Usage: $PN [options, see as follows]
    -h                      display short usage information and exit
    -i <iso_name>           name of ISO
    -o <output_directory>   main output directory of the build process
+   -q                      skip mksquashfs
    -r                      release name
    -s <suite>              Debian suite; values: etch, lenny, sid
    -t <template_directory> place of the templates
@@ -112,16 +113,15 @@ LIVE_CONF=/etc/grml/grml-live.conf
 
 # clean exit {{{
 bailout() {
-  [ -n "$MIRROR_DIRECTORY" ] && umount "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
   rm -f /var/run/fai/fai_softupdate_is_running \
         /var/run/fai/FAI_INSTALLATION_IN_PROGRESS
+  [ -n "$MIRROR_DIRECTORY" ] && umount "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
   [ -n "$1" ] && EXIT="$1" || EXIT="1"
   [ -n "$2" ] && eerror "$2">&2
   log "------------------------------------------------------------------------------"
   exit "$EXIT"
 }
-# trap bailout 1 2 3 6 9 14 15
-trap bailout 1 2 3 15
+trap bailout 1 2 3 3 6 9 14 15
 # }}}
 
 # check for important variables {{{
@@ -209,7 +209,7 @@ fi
 # }}}
 
 # command line parsing {{{
-while getopts "a:C:c:g:i:o:r:s:t:v:bFhuVz" opt; do
+while getopts "a:C:c:g:i:o:r:s:t:v:bFuqVz" opt; do
   case "$opt" in
     a) ARCH="$OPTARG" ;;
     b) BUILD_ONLY=1 ;;
@@ -222,12 +222,12 @@ while getopts "a:C:c:g:i:o:r:s:t:v:bFhuVz" opt; do
        BUILD_OUTPUT="$OUTPUT/grml_cd"
        ISO_OUTPUT="$OUTPUT/grml_isos"
        ;;
+    q) SKIP_MKSQUASHFS=1 ;;
     r) RELEASENAME="$OPTARG" ;;
     s) SUITE="$OPTARG" ;;
     t) TEMPLATE_DIRECTORY="$OPTARG";;
     v) VERSION="$OPTARG" ;;
     F) FORCE=1 ;;
-    h) usage ; bailout 0 ;;
     u) UPDATE=1 ;;
     V) VERBOSE="-v" ;;
     z) SQUASHFS_ZLIB="-nolzma" ;;
@@ -296,6 +296,7 @@ if [ -z "$FORCE" ] ; then
    [ -n "$SQUASHFS_OPTIONS" ] && echo "  Using SQUASHFS_OPTIONS ${SQUASHFS_OPTIONS}"
    [ -n "$VERBOSE" ]       && echo "  Using VERBOSE mode."
    [ -n "$UPDATE" ]        && echo "  Executing UPDATE instead of fresh installation."
+   [ -n "$SKIP_MKSQUASHFS" ] && echo "  Skipping creation of SQUASHFS file."
    [ -n "$BUILD_ONLY" ]    && echo "  Executing BUILD_ONLY instead of fresh installation or UPDATE."
    echo
    echo -n "Is this ok for you? [y/N] "
@@ -431,13 +432,6 @@ else
       # make sure new /etc/grml_version reaches the initramfs:
       chroot $CHROOT_OUTPUT update-initramfs -u -t
       eend $?
-      # get rid of unnecessary files when building grml-small:
-      if echo "$CLASSES" | grep -q GRML_SMALL ; then
-         einfo "Removing initrd and vmlinuz files in $CHROOT_OUTPUT/boot"
-         rm -f "$CHROOT_OUTPUT"/boot/initrd.img-*
-         rm -f "$CHROOT_OUTPUT"/boot/vmlinuz-*
-         eend $?
-      fi
    fi
 
    # Remove all FAI logs from chroot if class RELEASE is used:
@@ -445,8 +439,12 @@ else
       rm -rf "$CHROOT_OUTPUT"/var/log/fai/*
    fi
 
+   # make sure we don't leave any mounts - FAI doesn't remove them always
    umount $CHROOT_OUTPUT/proc 2>/dev/null || /bin/true
    umount $CHROOT_OUTPUT/sys  2>/dev/null || /bin/true
+   umount $CHROOT_OUTPUT/dev/pts 2>/dev/null || /bin/true
+   umount $CHROOT_OUTPUT/dev 2>/dev/null || /bin/true
+
    [ -n "$MIRROR_DIRECTORY" ] && umount "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
 
    # notice: 'fai dirinstall' does not seem to exit appropriate, so:
@@ -609,6 +607,9 @@ fi
 if [ -f "$BUILD_OUTPUT"/live/${GRML_NAME}.squashfs -a -z "$UPDATE" -a -z "$BUILD_ONLY" ] ; then
    log "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs'"
    ewarn "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs'" ; eend 0
+elif [ -f "$BUILD_OUTPUT"/live/${GRML_NAME}.squashfs -a -n "$SKIP_MKSQUASHFS" ] ; then
+   log "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs' as requested"
+   ewarn "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs' as requested" ; eend 0
 else
    [ -d "$BUILD_OUTPUT"/live ] || mkdir "$BUILD_OUTPUT"/live
    # make sure we don't leave (even an empty) base.tgz:
@@ -635,6 +636,16 @@ else
       fi
    fi
 
+   # support exclusion of files via exclude-file:
+   if [ -n "$SQUASHFS_EXCLUDES_FILE" -a "$SQUASHFS_EXCLUDES_FILE" ] ; then
+      SQUASHFS_OPTIONS="$SQUASHFS_OPTIONS -ef $SQUASHFS_EXCLUDES_FILE"
+   fi
+
+   # get rid of unnecessary files when building grml-small for final release:
+   if echo "$CLASSES" | grep -q GRML_SMALL ; then
+      SQUASHFS_OPTIONS="$SQUASHFS_OUTPUT -e initrd.img* vmlinuz*"
+   fi
+
    SQUASHFS_OUTPUT="$(mktemp -t grml-live.XXXXXX)"
    log "mksquashfs $CHROOT_OUTPUT/* $BUILD_OUTPUT/live/${GRML_NAME}.squashfs -noappend $SQUASHFS_OPTIONS $SQUASHFS_ZLIB"
    if mksquashfs $CHROOT_OUTPUT/* $BUILD_OUTPUT/live/"${GRML_NAME}".squashfs \
@@ -676,8 +687,8 @@ else
 
    CURRENT_DIR=$(pwd)
    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' \
+      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 \
               -o "${ISO_OUTPUT}/${ISO_NAME}" . ; RC=$?