eerror() { echo " [!] $*">&2 ;}
ewarn() { echo " [x] $*" ;}
eend() { return 0 ;}
+ eindent() { return 0 ;}
+ eoutdent() { return 0 ;}
fi
# source main configuration file:
# }}}
# clean/zero grml-live logfile {{{
-if [ -n "$ZERO_LOGFILE" ] ; then
+if [ -n "$PRESERVE_LOGFILE" ] ; then
+ echo "Preserving logfile $LOGFILE as requested via \$PRESERVE_LOGFILE"
+else
echo -n > $LOGFILE
fi
# }}}
if ! [[ "$ARCH" == "i386" ]] ; then
log "Error: You specified the I386 class but are trying to build something else (AMD64?)."
eerror "Error: You specified the I386 class but are trying to build something else (AMD64?)."
- eerror "Tip: Either invoke grml-live with '-i i386' or adjust the architecture class. Exiting."
+ eerror "Tip: Either invoke grml-live with '-a i386' or adjust the architecture class. Exiting."
eend 1
bailout
fi
if ! [[ "$ARCH" == "amd64" ]] ; then
log "Error: You specified the AMD64 class but are trying to build something else (I386?)."
eerror "Error: You specified the AMD64 class but are trying to build something else (I386?)."
- eerror "Tip: Either invoke grml-live with '-i amd64' or adjust the architecture class. Exiting."
+ eerror "Tip: Either invoke grml-live with '-a amd64' or adjust the architecture class. Exiting."
eend 1
bailout
fi
einfo "Skipping installation boot addons requested via \$NO_ADDONS."
eend 0
else
- if ! [ -d /usr/share/grml-live/templates/boot/addons/bsd4grml ] ; then
+ if ! [ -d "$TEMPLATE_DIRECTORY"/boot/addons/bsd4grml ] ; then
ewarn "Boot addons not found, skipping therefore. (Consider installing package grml-live-addons)" ; eend 0
else
# copy only files so we can handle bsd4grml on its own
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
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
# }}}