Support installation of local files through $CHROOT_INSTALL
[grml-live.git] / grml-live
index ce61ca7..9197b3e 100755 (executable)
--- a/grml-live
+++ b/grml-live
@@ -47,6 +47,8 @@ Usage: $PN [options, see as follows]
    -g <grml_name>]         set the grml flavour name
    -h                      display short usage information and exit
    -i <iso_name>           name of ISO
    -g <grml_name>]         set the grml flavour name
    -h                      display short usage information and exit
    -i <iso_name>           name of ISO
+   -I <src_directory>      directory which provides files that should become
+                           part of the chroot/ISO
    -o <output_directory>   main output directory of the build process
    -q                      skip mksquashfs
    -r <release_name<       release name
    -o <output_directory>   main output directory of the build process
    -q                      skip mksquashfs
    -r <release_name<       release name
@@ -207,7 +209,7 @@ fi
 # }}}
 
 # command line parsing {{{
 # }}}
 
 # command line parsing {{{
-while getopts "a:C:c:g:i:o:r:s:t:v:bBFuqVz" opt; do
+while getopts "a:C:c:g:i:I:o:r:s:t:v:bBFuqVz" opt; do
   case "$opt" in
     a) ARCH="$OPTARG" ;;
     b) BUILD_ONLY=1 ;;
   case "$opt" in
     a) ARCH="$OPTARG" ;;
     b) BUILD_ONLY=1 ;;
@@ -216,6 +218,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" ;;
     C) CONFIG="$OPTARG" ;;
     g) GRML_NAME="$OPTARG" ;;
     i) ISO_NAME="$OPTARG" ;;
+    I) CHROOT_INSTALL="$OPTARG" ;;
     o) OUTPUT="$OPTARG" ;;
     q) SKIP_MKSQUASHFS=1 ;;
     r) RELEASENAME="$OPTARG" ;;
     o) OUTPUT="$OPTARG" ;;
     q) SKIP_MKSQUASHFS=1 ;;
     r) RELEASENAME="$OPTARG" ;;
@@ -233,20 +236,28 @@ shift $(($OPTIND - 1))  # set ARGV to the first not parsed commandline parameter
 # }}}
 
 # assume sane defaults (if not set already) {{{
 # }}}
 
 # assume sane defaults (if not set already) {{{
-[ -n "$ARCH" ]            || ARCH="$(dpkg --print-architecture)"
-[ -n "$BOOT_METHOD" ]     || BOOT_METHOD='isolinux'
-[ -n "$CLASSES" ]         || CLASSES='GRML,I386'
-[ -n "$DISTRI_INFO" ]     || DISTRI_INFO='Grml - Live Linux for system administrators   '
-[ -n "$DISTRI_NAME" ]     || DISTRI_NAME="grml"
-[ -n "$DISTRI_SPLASH" ]   || DISTRI_SPLASH='grml.png'
-[ -n "$GRML_FAI_CONFIG" ] || GRML_FAI_CONFIG='/etc/grml/fai'
-[ -n "$GRML_NAME" ]       || GRML_NAME='grml'
-[ -n "$HOSTNAME" ]        || HOSTNAME='grml'
-[ -n "$NFSROOT_CONF" ]    || NFSROOT_CONF='/etc/grml/fai/make-fai-nfsroot.conf'
-[ -n "$RELEASENAME" ]     || RELEASENAME='grml-live rocks'
-[ -n "$SUITE" ]           || SUITE='stable'
-[ -n "$USERNAME" ]        || USERNAME='grml'
-[ -n "$VERSION" ]         || VERSION='0.0.1'
+[ -n "$ARCH" ]             || ARCH="$(dpkg --print-architecture)"
+[ -n "$BOOT_METHOD" ]      || BOOT_METHOD='isolinux'
+[ -n "$BUILD_OUTPUT" ]     || BUILD_OUTPUT="$OUTPUT/grml_cd"
+[ -n "$CHROOT_OUTPUT" ]    || CHROOT_OUTPUT="$OUTPUT/grml_chroot"
+[ -n "$CLASSES" ]          || CLASSES="GRMLBASE,GRML_MEDIUM,I386"
+[ -n "$DISTRI_INFO" ]      || DISTRI_INFO='Grml - Live Linux for system administrators   '
+[ -n "$DISTRI_NAME" ]      || DISTRI_NAME="grml"
+[ -n "$DISTRI_SPLASH" ]    || DISTRI_SPLASH='grml.png'
+[ -n "$GRML_FAI_CONFIG" ]  || GRML_FAI_CONFIG='/etc/grml/fai'
+[ -n "$GRML_NAME" ]        || GRML_NAME='grml'
+[ -n "$HOSTNAME" ]         || HOSTNAME='grml'
+[ -n "$ISOLINUX_METHOD" ]  || ISOLINUX_METHOD='console'
+[ -n "$ISO_OUTPUT" ]       || ISO_OUTPUT="$OUTPUT/grml_isos"
+[ -n "$NFSROOT_CONF" ]     || NFSROOT_CONF='/etc/grml/fai/make-fai-nfsroot.conf'
+[ -n "$OUTPUT" ]           || OUTPUT='/grml/grml-live'
+[ -n "$RELEASENAME" ]      || RELEASENAME='grml-live rocks'
+[ -n "$SQUASHFS_EXCLUDES_FILE " ] || SQUASHFS_EXCLUDES_FILE='/etc/grml/fai/squashfs-excludes'
+[ -n "$SUITE" ]            || SUITE='stable'
+[ -n "$TEMPLATE_DIRECTORY" ] || TEMPLATE_DIRECTORY='/usr/share/grml-live/templates'
+[ -n "$USERNAME" ]         || USERNAME='grml'
+[ -n "$VERSION" ]          || VERSION='0.0.1'
+[ -n "$WINDOWS_BINARIES" ] || WINDOWS_BINARIES='http://the.earth.li/~sgtatham/putty/latest/x86/'
 # }}}
 
 # some misc checks before executing FAI {{{
 # }}}
 
 # some misc checks before executing FAI {{{
@@ -307,6 +318,7 @@ if [ -z "$FORCE" ] ; then
    [ -n "$ARCH" ]               && echo "  Architecture:      $ARCH"
    [ -n "$BOOT_METHOD" ]        && echo "  Boot method:       $BOOT_METHOD"
    [ -n "$TEMPLATE_DIRECTORY" ] && echo "  Template files:    $TEMPLATE_DIRECTORY"
    [ -n "$ARCH" ]               && echo "  Architecture:      $ARCH"
    [ -n "$BOOT_METHOD" ]        && echo "  Boot method:       $BOOT_METHOD"
    [ -n "$TEMPLATE_DIRECTORY" ] && echo "  Template files:    $TEMPLATE_DIRECTORY"
+   [ -n "$CHROOT_INSTALL" ]     && echo "  Install files from directory to chroot:  $CHROOT_INSTALL"
    [ -n "$FAI_ARGS" ]           && echo "  additional arguments for FAI: $FAI_ARGS"
    [ -n "$LOGFILE" ]            && echo "  Logging to file:   $LOGFILE"
    [ -n "$SQUASHFS_ZLIB" ]      && echo "  Using ZLIB (instead of LZMA) compression."
    [ -n "$FAI_ARGS" ]           && echo "  additional arguments for FAI: $FAI_ARGS"
    [ -n "$LOGFILE" ]            && echo "  Logging to file:   $LOGFILE"
    [ -n "$SQUASHFS_ZLIB" ]      && echo "  Using ZLIB (instead of LZMA) compression."
@@ -590,7 +602,11 @@ if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then
 
       cp ${TEMPLATE_DIRECTORY}/boot/isolinux/*  "$BUILD_OUTPUT"/boot/isolinux/
 
 
       cp ${TEMPLATE_DIRECTORY}/boot/isolinux/*  "$BUILD_OUTPUT"/boot/isolinux/
 
-      if [ -z "$NO_ADDONS" ] ; then
+      if [ -n "$NO_ADDONS" ] ; then
+         log "Skipping installation boot addons requested via \$NO_ADDONS."
+         einfo "Skipping installation boot addons requested via \$NO_ADDONS."
+         eend 0
+      else
          if ! [ -d /usr/share/grml-live/templates/boot/addons/bsd4grml ] ; then
            ewarn "Boot addons not found, skipping therefore. (Consider installing package grml-live-addons)" ; eend 0
          else
          if ! [ -d /usr/share/grml-live/templates/boot/addons/bsd4grml ] ; then
            ewarn "Boot addons not found, skipping therefore. (Consider installing package grml-live-addons)" ; eend 0
          else
@@ -730,7 +746,11 @@ if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then
       fi
 
       # windows-binaries:
       fi
 
       # windows-binaries:
-      if [ -n "$WINDOWS_BINARIES" ] ; then
+      if [ -n "$NO_WINDOWS_BINARIES" ] ; then
+         log "Skipping download of windows binaries as requested via \$NO_WINDOWS_BINARIES."
+         einfo "Skipping download of windows binaries as requested via \$NO_WINDOWS_BINARIES."
+         eend 0
+      else
          if [ -f "$BUILD_OUTPUT"/windows/putty.exe ] ; then
             log "$BUILD_OUTPUT/windows exists already, skipping stage 'WINDOWS_BINARIES'"
             ewarn "$BUILD_OUTPUT/windows exists already, skipping stage 'WINDOWS_BINARIES'" ; eend 0
          if [ -f "$BUILD_OUTPUT"/windows/putty.exe ] ; then
             log "$BUILD_OUTPUT/windows exists already, skipping stage 'WINDOWS_BINARIES'"
             ewarn "$BUILD_OUTPUT/windows exists already, skipping stage 'WINDOWS_BINARIES'" ; eend 0
@@ -744,19 +764,30 @@ if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then
                  done )
             fi
          fi
                  done )
             fi
          fi
-      log "Finished execution of stage 'WINDOWS_BINARIES' [$(date)]"
-      einfo "Finished execution of stage 'WINDOWS_BINARIES'" ; eend 0
+         log "Finished execution of stage 'WINDOWS_BINARIES' [$(date)]"
+         einfo "Finished execution of stage 'WINDOWS_BINARIES'" ; eend 0
       fi
    einfo "Finished execution of stage 'boot'" ; eend 0
    fi
       fi
    einfo "Finished execution of stage 'boot'" ; eend 0
    fi
-# ppc:
-elif [ "$ARCH" = powerpc ] ; then
-    ewarn 'Warning: formorer, it is your turn. :)'>&2
-# unsuported:
 else
 else
+   log 'Error: Unsupported ARCH, sorry. Want to support it? Contribute!'
    eerror 'Error: Unsupported ARCH, sorry. Want to support it? Contribute!' ; eend 1
 fi
 
    eerror 'Error: Unsupported ARCH, sorry. Want to support it? Contribute!' ; eend 1
 fi
 
+# support installation of local files into the chroot/ISO
+if [ -n "$CHROOT_INSTALL" ] ; then
+  if ! [ -d "$CHROOT_INSTALL" ] ; then
+     log "Configuration variable \$CHROOT_INSTALL is set but not a directory; ignoring"
+     ewarn "Configuration variable \$CHROOT_INSTALL is set but not a directory; ignoring"
+  else
+     log "Copying local files to chroot as requested via \$CHROOT_INSTALL"
+     einfo "Copying local files to chroot as requested via \$CHROOT_INSTALL"
+     rsync -avz --inplace "$CHROOT_INSTALL"/ "$CHROOT_OUTPUT/"
+     eend $?
+     einfo "Make sure to run squashfs stage, otherwise your local files won't be part of the ISO."
+  fi
+fi
+
 if [ -f "$BUILD_OUTPUT"/live/${GRML_NAME}.squashfs -a -z "$UPDATE" -a -z "$BUILD_ONLY" -a -z "$BUILD_DIRTY" ] ; then
    log "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs'"
    ewarn "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs'" ; eend 0
 if [ -f "$BUILD_OUTPUT"/live/${GRML_NAME}.squashfs -a -z "$UPDATE" -a -z "$BUILD_ONLY" -a -z "$BUILD_DIRTY" ] ; then
    log "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs'"
    ewarn "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs'" ; eend 0