New option -b for build-only
authorMichael Prokop <devnull@localhost>
Sun, 16 Dec 2007 11:42:24 +0000 (12:42 +0100)
committerMichael Prokop <devnull@localhost>
Sun, 16 Dec 2007 11:42:24 +0000 (12:42 +0100)
debian/changelog
debian/rules
docs/grml-live.txt
grml-live
patches/fai_chroot_update.patch [new file with mode: 0644]

index 18915d7..9efa9e2 100644 (file)
@@ -1,5 +1,7 @@
 grml-live (0.0.13) unstable; urgency=low
 
 grml-live (0.0.13) unstable; urgency=low
 
+  * New option '-b' for "build-only", requires FAI patch
+    /usr/share/grml-live/patches/fai_chroot_update.patch
   * Replace mailx with bsd-mailx in GRML_FULL.
     http://packages.qa.debian.org/b/bsd-mailx/news/20071209T135336Z.html
   * Document grml2ram bootoption in grml-cheatcodes.txt
   * Replace mailx with bsd-mailx in GRML_FULL.
     http://packages.qa.debian.org/b/bsd-mailx/news/20071209T135336Z.html
   * Document grml2ram bootoption in grml-cheatcodes.txt
index 971a44a..b6f13d9 100755 (executable)
@@ -38,6 +38,7 @@ install: build
        cp -a examples    debian/grml-live/usr/share/doc/grml-live/
        cp -a templates   debian/grml-live/usr/share/grml-live/
        cp -a scripts     debian/grml-live/usr/share/grml-live/
        cp -a examples    debian/grml-live/usr/share/doc/grml-live/
        cp -a templates   debian/grml-live/usr/share/grml-live/
        cp -a scripts     debian/grml-live/usr/share/grml-live/
+       cp -a patches     debian/grml-live/usr/share/grml-live/
        cp -a buildd/*.sh debian/grml-live/usr/share/grml-live/buildd/
        install -o root -m 640 buildd/grml-buildd.conf debian/grml-live/etc/grml/grml-buildd.conf
        install -o root -m 755 grml-live debian/grml-live/usr/sbin/grml-live
        cp -a buildd/*.sh debian/grml-live/usr/share/grml-live/buildd/
        install -o root -m 640 buildd/grml-buildd.conf debian/grml-live/etc/grml/grml-buildd.conf
        install -o root -m 755 grml-live debian/grml-live/usr/sbin/grml-live
index 61c7562..94a22d4 100644 (file)
@@ -12,12 +12,12 @@ Synopsis
 
 grml-live [-a <architecture>] [-c <classe[s]>] [-g <grml_name>] [-i <iso_name> ]
 [-o <output_directory>] [-r <release_name>] [-s <suite>] [-t
 
 grml-live [-a <architecture>] [-c <classe[s]>] [-g <grml_name>] [-i <iso_name> ]
 [-o <output_directory>] [-r <release_name>] [-s <suite>] [-t
-<template_directory>] [-v <version_number>] [-FVhuz]
+<template_directory>] [-v <version_number>] [-bFVhuz]
 
 *******************************************************************************
 Important! This document is growing as requested. If you have questions which
 aren't answered by this document yet please let me know: <mika@grml.org>!
 
 *******************************************************************************
 Important! This document is growing as requested. If you have questions which
 aren't answered by this document yet please let me know: <mika@grml.org>!
-This document currently applies to grml-live version 0.0.12.
+This document currently applies to grml-live version 0.0.13.
 *******************************************************************************
 
 Description
 *******************************************************************************
 
 Description
@@ -62,6 +62,14 @@ allows building a 32bit system on a 64bit host. Please notice that real
 crosscompiling (like building a ppc system on x86) isn't possible due to the
 nature and the need of working in a chroot.
 
 crosscompiling (like building a ppc system on x86) isn't possible due to the
 nature and the need of working in a chroot.
 
+  -b::
+
+Build the ISO without updating the chroot via FAI. This option is useful for
+example when working on stable releases: if you have a working base
+system/chroot and do not want to execute any further updates (via "-u" option)
+but intend to only build the ISO. (Notice: This option requires a feature within
+FAI which is not yet part of the official FAI release yet.)
+
   -c **CLASSES**::
 
 Specify the CLASSES to be used for building the ISO via FAI.  By default only
   -c **CLASSES**::
 
 Specify the CLASSES to be used for building the ISO via FAI.  By default only
index e063a4a..dff9efd 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.
 # 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 Dec 09 18:18:27 CET 2007 [mika]
+# Latest change: Sun Dec 16 12:39:04 CET 2007 [mika]
 ################################################################################
 
 # read configuration files, set some misc variables {{{
 ################################################################################
 
 # read configuration files, set some misc variables {{{
@@ -15,7 +15,7 @@ export LC_ALL=C
 # exit on any error:
 set -e
 
 # exit on any error:
 set -e
 
-GRML_LIVE_VERSION='0.0.12'
+GRML_LIVE_VERSION='0.0.13'
 CMDLINE="$0 $@"
 ISO_DATE="$(date +%Y-%m-%d)"
 
 CMDLINE="$0 $@"
 ISO_DATE="$(date +%Y-%m-%d)"
 
@@ -38,10 +38,17 @@ if [ -r /var/run/fai/fai_softupdate_is_running ] ; then
    exit 1
 fi
 
    exit 1
 fi
 
+if [ -r /var/run/fai/fai_chrootupdate_is_running ] ; then
+   echo "/usr/sbin/fai chrootupdate already running or was aborted before.">&2
+   echo "You may remove /var/run/fai/fai_chrootupdate_is_running and try again.">&2
+   exit 1
+fi
+
 # make sure they are not set by default
 VERBOSE=''
 FORCE=''
 UPDATE=''
 # make sure they are not set by default
 VERBOSE=''
 FORCE=''
 UPDATE=''
+BUILD_ONLY=''
 
 if [ -r /etc/grml/lsb-functions ] ; then
    . /etc/grml/lsb-functions
 
 if [ -r /etc/grml/lsb-functions ] ; then
    . /etc/grml/lsb-functions
@@ -62,7 +69,9 @@ PN=$(basename $0)
 # clean exit {{{
 bailout() {
   [ -n "$MIRROR_DIRECTORY" ] && umount "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
 # 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
+  rm -f /var/run/fai/fai_softupdate_is_running \
+        /var/run/fai/fai_chrootupdate_is_running \
+        /var/run/fai/FAI_INSTALLATION_IN_PROGRESS
   [ -n "$1" ] && EXIT="$1" || EXIT="1"
   [ -n "$2" ] && eerror "$2">&2
   log "------------------------------------------------------------------------------"
   [ -n "$1" ] && EXIT="$1" || EXIT="1"
   [ -n "$2" ] && eerror "$2">&2
   log "------------------------------------------------------------------------------"
@@ -154,7 +163,7 @@ $PN - build process script for generating a (grml based) Linux Live-ISO
 Usage: $PN [-a <architecture>] [-c <classe[s]>] [-g <grml_name>] \\
                  [-i <iso_name> ] [-o <output_directory>] [-s <suite>] \\
                  [-t <template_directory>] [-s <suite>] \\
 Usage: $PN [-a <architecture>] [-c <classe[s]>] [-g <grml_name>] \\
                  [-i <iso_name> ] [-o <output_directory>] [-s <suite>] \\
                  [-t <template_directory>] [-s <suite>] \\
-                 [-v <version_number>] [-FVhu]
+                 [-v <version_number>] [-bFVhu]
 
 Usage examples:
 
 
 Usage examples:
 
@@ -176,9 +185,10 @@ http://grml.org/bugs/
 
 # command line parsing {{{
 
 
 # command line parsing {{{
 
-while getopts "a:C:c:g:i:o:r:s:t:v:FhuVz" opt; do
+while getopts "a:C:c:g:i:o:r:s:t:v:bFhuVz" opt; do
   case "$opt" in
     a) ARCH="$OPTARG" ;;
   case "$opt" in
     a) ARCH="$OPTARG" ;;
+    b) BUILD_ONLY=1 ;;
     c) CLASSES="$OPTARG" ;;
     C) CONFIG="$OPTARG" ;;
     g) GRML_NAME="$OPTARG" ;;
     c) CLASSES="$OPTARG" ;;
     C) CONFIG="$OPTARG" ;;
     g) GRML_NAME="$OPTARG" ;;
@@ -231,8 +241,10 @@ if [ -n "$ZERO_FAI_LOGFILE" ] ; 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)"
       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)"
+      rm -rf /var/log/fai/"$HOSTNAME"/"$(readlink /var/log/fai/"$HOSTNAME"/last-chrootupdate)"
       rm -f /var/log/fai/"$HOSTNAME"/last \
             /var/log/fai/"$HOSTNAME"/last-dirinstall \
       rm -f /var/log/fai/"$HOSTNAME"/last \
             /var/log/fai/"$HOSTNAME"/last-dirinstall \
+            /var/log/fai/"$HOSTNAME"/last-chrootupdate \
             /var/log/fai/"$HOSTNAME"/last-softupdate
    fi
 fi
             /var/log/fai/"$HOSTNAME"/last-softupdate
    fi
 fi
@@ -263,6 +275,7 @@ if [ -z "$FORCE" ] ; then
    [ -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."
    [ -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."
+   [ -n "$BUILD_ONLY" ]    && echo "  Executing BUILD_ONLY instead of fresh installation or UPDATE."
    echo
    echo -n "Is this ok for you? [y/N] "
    read a
    echo
    echo -n "Is this ok for you? [y/N] "
    read a
@@ -355,20 +368,22 @@ fi
 
 if [ -n "$UPDATE" ] ; then
    FAI_ACTION=softupdate
 
 if [ -n "$UPDATE" ] ; then
    FAI_ACTION=softupdate
+elif [ -n "$BUILD_ONLY" ] ; then
+   FAI_ACTION=chrootupdate
 else
    FAI_ACTION=dirinstall
 fi
 
 else
    FAI_ACTION=dirinstall
 fi
 
-if [ -n "$UPDATE" ] ; then
+if [ -n "$UPDATE" -o -n "$BUILD_ONLY" ] ; then
    if ! [ -r "$CHROOT_OUTPUT/etc/grml_version" ] ; then
    if ! [ -r "$CHROOT_OUTPUT/etc/grml_version" ] ; then
-      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?)"
+      log "Error: does not look like you have a working chroot. Updating/building not possible."
+      eerror "Error: does not look like you have a working chroot. Updating/building not possible. (Drop -u/-b option?)"
       eend 1
       bailout 20
    fi
 fi
 
       eend 1
       bailout 20
    fi
 fi
 
-if [ -d "$CHROOT_OUTPUT/bin" -a -z "$UPDATE" ] ; then
+if [ -d "$CHROOT_OUTPUT/bin" -a -z "$UPDATE" -a -z "$BUILD_ONLY" ] ; then
    log "$CHROOT_OUTPUT exists already, skipping stage 'fai dirinstall'"
    ewarn "$CHROOT_OUTPUT exists already, skipping stage 'fai dirinstall'" ; eend 0
 else
    log "$CHROOT_OUTPUT exists already, skipping stage 'fai dirinstall'"
    ewarn "$CHROOT_OUTPUT exists already, skipping stage 'fai dirinstall'" ; eend 0
 else
@@ -431,7 +446,7 @@ mkdir -p "$BUILD_OUTPUT" || bailout 6 "Problem with creating $BUILD_OUTPUT for s
 
 # i386:
 if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then
 
 # i386:
 if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then
-   if [ -d "$BUILD_OUTPUT"/boot -a -z "$UPDATE" ] ; then
+   if [ -d "$BUILD_OUTPUT"/boot -a -z "$UPDATE" -a -z "$BUILD_ONLY" ] ; then
       log "$BUILD_OUTPUT/boot exists already, skipping stage 'boot'"
       ewarn "$BUILD_OUTPUT/boot exists already, skipping stage 'boot'" ; eend 0
    else
       log "$BUILD_OUTPUT/boot exists already, skipping stage 'boot'"
       ewarn "$BUILD_OUTPUT/boot exists already, skipping stage 'boot'" ; eend 0
    else
@@ -533,7 +548,7 @@ else
    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
 
-if [ -f "$BUILD_OUTPUT"/live/grml.squashfs -a -z "$UPDATE" ] ; then
+if [ -f "$BUILD_OUTPUT"/live/grml.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
 else
    log "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs'"
    ewarn "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs'" ; eend 0
 else
@@ -563,7 +578,7 @@ elif [ "$BOOT_METHOD" = "grub" ] ; then
    BOOT_FILE="boot/grub/stage2_eltorito"
 fi
 
    BOOT_FILE="boot/grub/stage2_eltorito"
 fi
 
-if [ -f "${ISO_OUTPUT}/${ISO_NAME}" -a -z "$UPDATE" ] ; then
+if [ -f "${ISO_OUTPUT}/${ISO_NAME}" -a -z "$UPDATE" -a -z "$BUILD_ONLY" ] ; then
    log "$ISO_OUTPUT exists already, skipping stage 'iso build'"
    ewarn "$ISO_OUTPUT exists already, skipping stage 'iso build'" ; eend 0
 else
    log "$ISO_OUTPUT exists already, skipping stage 'iso build'"
    ewarn "$ISO_OUTPUT exists already, skipping stage 'iso build'" ; eend 0
 else
diff --git a/patches/fai_chroot_update.patch b/patches/fai_chroot_update.patch
new file mode 100644 (file)
index 0000000..350f613
--- /dev/null
@@ -0,0 +1,63 @@
+--- subroutines.orig   2007-12-16 11:20:12.000000000 +0000
++++ subroutines        2007-12-16 11:23:01.000000000 +0000
+@@ -294,6 +294,10 @@
+           echo Performing FAI system update. All data may be overwritten!
+           task softupdate
+           ;;
++      chrootupdate)
++          echo Performing FAI chroot update. All data may be overwritten!
++          task chrootupdate
++          ;;
+       sysinfo)
+           echo Showing system information.
+           task sysinfo
+@@ -568,6 +572,49 @@
+ }
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
++task_chrootupdate() {
++
++    local stamp=/var/run/fai/fai_chrootupdate_is_running
++
++    [ -f "$stamp" ] && die "Another fai chrootupdate is already running. Aborting."
++    echo $$ > $stamp
++    # if the system had been installed using fai < 3.0 disk_var.sh is found in /etc/fai
++    if [ ! -f /var/lib/fai/disk_var.sh -a -f /etc/fai/disk_var.sh ] ; then
++      mv /etc/fai/disk_var.sh /var/lib/fai/
++    fi
++    # the following copy operation is required to make $LOGDIR a reliable source
++    # for disk_var.sh
++    # use the last disk_var during update if available
++    [ -f /var/lib/fai/disk_var.sh ] && cp -p /var/lib/fai/disk_var.sh $LOGDIR 
++
++    defnop wait_for_jobs
++    save_dmesg
++
++    task mirror
++    task debconf
++    task configure
++    date
++    echo "The $FAI_ACTION took $[$(cut -d . -f 1 /proc/uptime)-$start_seconds] seconds."
++
++    rm -f $stamp
++    # save again, because new messages could be created
++    save_dmesg
++    task savelog
++
++    if [ -f $stamp ]; then
++      echo "Error while executing commands in subshell."
++      echo -n "$stamp was not removed. PID of running process: "
++      cat $stamp
++      sendmon "TASKERROR chrootupdate 21"
++      die "Please look at the log files in $LOGDIR for errors."
++    fi
++    echo $FAI_CONFIG_SRC | grep -q ^nfs://
++    if [ $? -eq 0 ]; then
++      grep -q ^$FAI /etc/mtab && umount $FAI
++    fi
++}
++# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
++
+ catnc() {
+     # cat but no comment lines
+     egrep -v "^#" $@