X-Git-Url: https://git.grml.org/?p=grml-live.git;a=blobdiff_plain;f=grml-live;h=12596ee45d40dd7ac52d4eafab356a0368ab39f9;hp=2fa022acbf5c99b1842539517d4e027dd20dc356;hb=a5f8527557ae9bdceb1227de4e023fa6a353234a;hpb=e990fb62a869846139a7d01261283552c57c14b8 diff --git a/grml-live b/grml-live index 2fa022a..12596ee 100755 --- a/grml-live +++ b/grml-live @@ -123,6 +123,8 @@ else eerror() { echo " [!] $*">&2 ;} ewarn() { echo " [x] $*" ;} eend() { return 0 ;} + eindent() { return 0 ;} + eoutdent() { return 0 ;} fi # source main configuration file: @@ -287,8 +289,20 @@ ISO_OUTPUT="$OUTPUT/grml_isos" # }}} # clean/zero grml-live logfile {{{ -if [ -n "$ZERO_LOGFILE" ] ; then - echo -n > $LOGFILE + +# keep for backwards compability reasons (default behaviour until grml-live 0.9.34) +if [ -n "$ZERO_LOGFILE" -a -z "$PRESERVE_LOGFILE" ] ; then + echo -n > $LOGFILE + einfo "Zeroing logfile $LOGFILE as requested via \$ZERO_LOGFILE." + ewarn "Please consider disabling the \$ZERO_LOGFILE option as grml-live clears..." + ewarn "... the logfile $LOGFILE by default (unless \$PRESERVE_LOGFILE is set) nowadays." + eend 0 +fi + +if [ -n "$PRESERVE_LOGFILE" ] ; then + echo "Preserving logfile $LOGFILE as requested via \$PRESERVE_LOGFILE" +else + echo -n > $LOGFILE fi # }}} @@ -966,7 +980,6 @@ else eerror "|-> Make sure to install either squashfs-tools and/or squashfs-lzma-tools." eerror "\`-> Visit http://grml.org/grml-live/#current_state for further details." eend 1 - package bailout fi @@ -1119,10 +1132,56 @@ else fi # }}} +# log build information to database if grml-live-db is installed and enabled {{{ +dpkg_to_db() { +if [ -d /usr/share/grml-live-db ] ; then + + # safe defaults + DPKG_LIST="/var/log/fai/$HOSTNAME/last/dpkg.list" # the dpkg --list output of the chroot: + [ -n "$DPKG_DATABASE" ] || DPKG_DATABASE=/var/log/grml-live.db + [ -n "$DPKG_DBSCRIPT" ] || DPKG_DBSCRIPT=/usr/share/grml-live-db/scripts/dpkg-to-db + [ -n "$DPKG_DBOPTIONS" ] || DPKG_DBOPTIONS="-d $DPKG_DATABASE --logfile $LOGFILE --flavour $GRML_NAME < $DPKG_LIST" + + if ! [ -x "$DPKG_DBSCRIPT" ] ; then + eerror "Error: $DPKG_DBSCRIPT is not executable, can not log dpkg information." ; eend 1 + bailout 14 + fi + + # disable by default for now, not sure whether really everyone is using a local db file + #if ! touch "$DPKG_DATABASE" ; then + # eerror "Error: can not write to ${DPKG_DATABASE}, can not log dpkg information." ; eend 1 + # bailout 14 + #fi + + if ! [ -r "$DPKG_LIST" ] ; then + eerror "Error reading $DPKG_LIST - can not provide information to $DPKG_DBSCRIPT" ; eend 1 + bailout 14 + else + einfo "Logging $DPKG_LIST to database $DPKG_DATABASE" + eindent + + if DB_INFO=$("$DPKG_DBSCRIPT" $DPKG_DBOPTIONS 2>&1) ; then + einfo "$DB_INFO" + eend 0 + else + eerror "$DB_INFO" + eend 1 + fi + + eoutdent + fi + +fi +} +# }}} + # finalize {{{ [ -n "$start_seconds" ] && SECONDS="$[$(cut -d . -f 1 /proc/uptime)-$start_seconds]" || SECONDS="unknown" -einfo "Successfully finished execution of $PN [$(date) - running ${SECONDS} seconds]" ; eend 0 log "Successfully finished execution of $PN [$(date) - running ${SECONDS} seconds]" + +dpkg_to_db # make sure we catch the last log line as well, therefore execute between log + einfo + +einfo "Successfully finished execution of $PN [$(date) - running ${SECONDS} seconds]" ; eend 0 bailout 0 # }}}