# set -e
# global variables
-GRML_LIVE_VERSION='0.15.1'
+GRML_LIVE_VERSION='0.16.1'
PN="$(basename $0)"
CMDLINE="$0 $@"
ADDONS_LIST_FILE='/boot/isolinux/addons_list.cfg'
BOOTSTRAP_ONLY=''
HOSTNAME=''
+# don't use colors/escape sequences
+if [ -r /lib/lsb/init-functions ] ; then
+ . /lib/lsb/init-functions
+ ! log_use_fancy_output && NOCOLORS=true
+fi
+
if [ -r /etc/grml/lsb-functions ] ; then
. /etc/grml/lsb-functions
else
trap umount_all EXIT
# }}}
-# log file stuff {{{
-[ -n "$LOGFILE" ] || LOGFILE=/var/log/grml-live.log
-touch $LOGFILE
-chown root:adm $LOGFILE
-chmod 664 $LOGFILE
-# }}}
-
# some important functions {{{
# log output:
echo -ne "\n"
}
-# Copy addonfile $1 from the TEMPLATE_DIRECTORY/compat (if exists),
-# or from $2 (the system path), or warn about the missing file.
+# Copy addonfile $1 from either
+# * the chroot (via $2, the system path),
+# * or from TEMPLATE_DIRECTORY/compat (if exists),
+# * or from the host system (again, using $2),
+# or warn about the missing file.
+#
# This is because:
+# * We assume that the chroot always has a "good" version of
+# the file. Also it makes sources handling easier.
# * On unstable, we Recommend the Debian packages containing
# these files. The user can override them by putting his
-# "better" version into TEMPLATE_DIRECTORY/compat.
+# "better" version into the chroot.
# * On stable, the Debian packages are probably not available,
# or outdated, so we look in TEMPLATE_DIRECTORY/compat first, where
# our grml-live-compat package installs current file versions.
copy_addon_file() {
- if [ ! -d "${BUILD_OUTPUT}/boot/$3/" ]; then
- mkdir -p "${BUILD_OUTPUT}/boot/$3"
+ DEST="${BUILD_OUTPUT}/boot/$3"
+ if [ ! -d "${DEST}/" ]; then
+ mkdir -p "${DEST}"
+ fi
+ if [ -e "$CHROOT_OUTPUT/$2/$1" ]; then
+ log "Copying $1 from chroot"
+ cp "$CHROOT_OUTPUT/$2/$1" "${DEST}/"
+ return $?
fi
if [ -e "${TEMPLATE_DIRECTORY}/compat/$3/$1" ]; then
- cp "${TEMPLATE_DIRECTORY}/compat/$3/$1" "${BUILD_OUTPUT}/boot/$3/"
+ log "Copying $1 from grml-live-compat"
+ cp "${TEMPLATE_DIRECTORY}/compat/$3/$1" "${DEST}/"
return $?
fi
if [ -e "$2/$1" ]; then
- echo "Copying $1 from system"
- cp "$2/$1" "${BUILD_OUTPUT}/boot/$3/"
+ log "Copying $1 from system"
+ cp "$2/$1" "${DEST}/"
return $?
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
- log "No $LOCAL_CONFIG found, not sourcing it"
LOCAL_CONFIG=''
fi
# }}}
fi
# }}}
+# create log file {{{
+[ -n "$LOGFILE" ] || LOGFILE=${OUTPUT}/grml_logs/grml-live.log
+mkdir -p $(dirname "${LOGFILE}")
+touch $LOGFILE
+chown root:adm $LOGFILE
+chmod 664 $LOGFILE
+# }}}
+
# clean/zero/remove logfiles {{{
if [ -n "$PRESERVE_LOGFILE" ] ; then
start_seconds=$(cut -d . -f 1 /proc/uptime)
log "------------------------------------------------------------------------------"
log "Starting grml-live [${GRML_LIVE_VERSION}] run on $(date)"
+if [ -n "$LOCAL_CONFIG" ]; then
+ log "Using local config file: $LOCAL_CONFIG"
+fi
log "Executed grml-live command line:"
log "$CMDLINE"
eend $?
fi
+ # move fai logs into grml_logs directory
+ mkdir -p "$OUTPUT"/grml_logs/fai/
+ cp -r "$CHROOT_OUTPUT"/var/log/fai/"$HOSTNAME"/last/* "$OUTPUT"/grml_logs/fai/
+ chown root:adm "$OUTPUT"/grml_logs/fai/*
+ chmod 664 "$OUTPUT"/grml_logs/fai/*
+ rm -rf "$CHROOT_OUTPUT"/var/log/fai
+
# Remove all FAI logs from chroot if class RELEASE is used:
- if [ -f "$CHROOT_OUTPUT"/etc/grml_fai_release ] ; then
- rm -rf "$CHROOT_OUTPUT"/var/log/fai/*
- rm -f "$CHROOT_OUTPUT"/var/log/install_packages.list
- fi
+ rm -f "$CHROOT_OUTPUT"/var/log/install_packages.list
umount_all
if [ -d "$TEMPLATE_DIRECTORY"/boot/addons/bsd4grml ] ; then
cp -a ${TEMPLATE_DIRECTORY}/boot/addons/bsd4grml "$BUILD_OUTPUT"/boot/addons/
else
- log "bsd4grml addon not found, skipping therefore."
- ewarn "bsd4grml addon not found, skipping therefore." ; eend 0
+ log "Missing addon file: bsd4grml"
+ ewarn "Missing addon file: bsd4grml" ; eend 0
fi
fi
if [ -e ${TEMPLATE_DIRECTORY}/compat/grub/linux.mod ]; then
cp "${TEMPLATE_DIRECTORY}"/compat/grub/* "${BUILD_OUTPUT}"/boot/grub/
else
- if ! [ -x /usr/bin/grub-mkimage ] ; then
+ if ! which "grub-mkimage" >/dev/null 2>&1 ; then
log "grub-mkimage not found, skipping Grub step therefore." ; eend 0
ewarn "grub-mkimage not found, skipping Grub step therefore."
- ewarn "Either install grub-common >= 1.98+20100804-14 or grub-pc." ; eend 0
+ ewarn "Please install grub-pc-bin or grub-common >= 1.98+20100804-14." ; eend 0
+ elif ! grub-mkimage --help | grep -q -- --format ; then
+ log "grub-mkimage does not support --format=i386-pc, skipping Grub step therefore." ; eend 0
+ ewarn "grub-mkimage does not support --format=i386-pc, skipping Grub step therefore."
+ ewarn "Please install grub-common >= 1.98+20100804-14 or grub-pc-bin." ; eend 0
else
- # copy system grub files if grml-live-compat is not
- # installed.
+ # copy system grub files if grml-live-compat is not installed
cp -a /usr/lib/grub/*-pc/*.mod "${BUILD_OUTPUT}"/boot/grub/
cp -a /usr/lib/grub/*-pc/*.o "${BUILD_OUTPUT}"/boot/grub/
cp -a /usr/lib/grub/*-pc/*.lst "${BUILD_OUTPUT}"/boot/grub/
cp -a /usr/share/grub/ascii.pf2 "${BUILD_OUTPUT}"/boot/grub/
- /usr/bin/grub-mkimage -d /usr/lib/grub/*-pc -o \
+ grub-mkimage -d /usr/lib/grub/*-pc -o \
"${BUILD_OUTPUT}/boot/grub/core.img" biosdisk iso9660 --format=i386-pc
fi
fi