grml-live-remaster: Slightly adjust check for running Grml session
[grml-live.git] / remaster / grml-live-remaster
index a340592..92ef074 100755 (executable)
@@ -21,16 +21,39 @@ fi
 
 set -e # exit on any error
 
-VERSION='0.0.2'
+VERSION='0.0.3'
 GRML_LIVE_EDITOR=${VISUAL:-${EDITOR:-vi}}
 
 # source core functions {{{
+if ! [ -r /etc/grml/lsb-functions ] || ! [ -r /etc/grml/script-functions ] ; then
+  echo "Error: could not read /etc/grml/lsb-functions and/or /etc/grml/script-functions." >&2
+  echo "Error: $0 can run only in Grml live session. Exiting." >&2
+  exit 1
+fi
+
 . /etc/grml/lsb-functions
 . /etc/grml/script-functions
 # }}}
 
+if ! isgrmlcd ; then
+  echo "Error: $0 can run only in Grml live session. Exiting." >&2
+  exit 1
+fi
+
 # make sure we have what we need {{{
-check4progs mkisofs mksquashfs stat || exit 1
+check4progs mkisofs stat || exit 1
+
+# allow overriding via environment:
+if [ -z "$MKSQUASHFS" ] ; then
+  if which mksquashfs-lzma >/dev/null 2>&1 ; then
+    MKSQUASHFS=mksquashfs-lzma
+  elif which mksquashfs >/dev/null 2>&1 ; then
+    MKSQUASHFS=mksquashfs
+  else
+    echo "Error: neither mksquashfs-lzma nor mksquashfs present. Exiting."
+    exit 1
+  fi
+fi
 check4root || exit 1
 # }}}
 
@@ -43,7 +66,7 @@ if [ x"$1" == x ]; then
    echo "  first, because grml-live-remaster will need a lot ot RAM."
    echo ""
    echo "Please report bugs and feature requests: http://grml.org/bugs/"
-   exit -1
+   exit 1
 fi
 
 if [ ! -d /remaster ]; then
@@ -107,7 +130,7 @@ sed 3,4d "${BOOTSTUFF}"/boot.msg \
 sed 1,2d /remaster/msg >>/remaster/iso/boot/isolinux/boot.msg
 
 mkdir /remaster/iso/live
-mksquashfs /remaster/chroot /remaster/iso/live/"$(basename $SQUASHFS_FILE)"
+$MKSQUASHFS /remaster/chroot /remaster/iso/live/"$(basename $SQUASHFS_FILE)"
 umount /remaster/chroot /remaster/cdrom
 
 if [ -f /remaster/iso/boot/isolinux/isolinux.bin ] ; then