X-Git-Url: https://git.grml.org/?a=blobdiff_plain;f=buildd%2Ffunctions.sh;h=89eb38f27c077266dbebca8a96c30a3c3132f5ee;hb=d3526f6ba1fb68ea4f2a1cc57fbd187c719c520a;hp=c05a6aee8b85b7262ff507b94ea3a7e05668064b;hpb=f96dfbfc04c41274fc0f2ec94a2951382eef4081;p=grml-live.git diff --git a/buildd/functions.sh b/buildd/functions.sh index c05a6ae..89eb38f 100755 --- a/buildd/functions.sh +++ b/buildd/functions.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Filename: /usr/share/grml-live/buildd/functions.sh # Purpose: main function file for grml-live buildd # Authors: grml-team (grml.org), (c) Michael Prokop @@ -13,28 +13,29 @@ die() { . /etc/grml/grml-buildd.conf || die "Could not source /etc/grml/grml-buildd.conf. Exiting." -which nail >/dev/null 2>&1 || die "nail binary not found. Exiting." +which mutt >/dev/null 2>&1 || die "mutt binary not found. Exiting." # exit if important variables aren't set: [ -n "$STORAGE" ] || die "\$STORAGE is not set. Exiting." [ -n "$SUITE" ] || die "\$SUITE is not set. Exiting." [ -n "$CLASSES" ] || die "\$CLASSES is not set. Exiting." [ -n "$NAME" ] || die "\$NAME is not set. Exiting." -[ -n "$ISO_NAME" ] || die "\$ISO_NAME is not set. Exiting." +[ -n "$PRODUCT_NAME" ] || die "\$PRODUCT_NAME is not set. Exiting." # some defaults: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11 DATE=$(date +'%Y%m%d_%H%M%S') TMP_DIR="$(mktemp -d)" [ -n "$TMP_DIR" ] || die "Could not create \$TMP_DIR. Exiting." +ISO_NAME="${PRODUCT_NAME}.iso" # make sure we have same safe defaults: [ -n "$OUTPUT_DIR" ] || OUTPUT_DIR="${STORAGE}/grml-live_${DATE}.$$" [ -n "$ISO_DIR" ] || ISO_DIR=$STORAGE/grml-isos [ -n "$RECIPIENT" ] || RECIPIENT=root@localhost -[ -n "$ATTACHMENT" ] || ATTACHMENT="$TMP_DIR/grml-live-logs_$DATE.tar.gz" [ -n "$FROM" ] || FROM=root@localhost [ -n "$ARCH" ] || ARCH="$(dpkg --print-architecture)" +ATTACHMENT="$TMP_DIR/grml-live-logs_$DATE.tar.gz" if [ -n "$LOGFILE" ] ; then GRML_LOGFILE="$LOGFILE" @@ -66,10 +67,12 @@ grml_live_run() { grml_name="$NAME-daily-$CODENAME" shortdate="$(date +%y%m%d)" + TIME_START=$(date +%s) grml-live -F $* -a $ARCH -s $SUITE -c $CLASSES -o $OUTPUT_DIR \ -g "$grml_name" -v "$shortdate" -r grml-live-autobuild -i $ISO_NAME \ - 1>/var/log/grml-buildd.stdout \ - 2>/var/log/grml-buildd.stderr ; RC=$? + >/var/log/grml-buildd.log 2>&1 ; RC=$? + TIME_END=$(date +%s) + WALLTIME=$(($TIME_END-$TIME_START)) if [ "$RC" = "0" ] ; then RC_INFO=success @@ -81,13 +84,13 @@ grml_live_run() { # create log archive: create_logs() { - ( cd / && tar zcf $ATTACHMENT $FAI_LOGFILES /var/log/grml-buildd.stderr /var/log/grml-buildd.stdout $GRML_LOGFILE 1>/dev/null ) + ( cd / && tar zcfh $ATTACHMENT $FAI_LOGFILES /var/log/grml-buildd.log $GRML_LOGFILE >/dev/null ) } # store logs on remote server: upload_logs() { [ -n "$RSYNC_MIRROR" ] || return 1 - rsync --exclude dmesg.log --times --partial --copy-links -rltDz --quiet /var/log/grml-buildd.* \ + rsync --exclude dmesg.log --times --partial --copy-links -rltDz --quiet /var/log/grml-buildd.log \ $FAI_LOGFILES $GRML_LOGFILE $RSYNC_MIRROR/logs/"${NAME}_${DATE}"/ } @@ -105,11 +108,15 @@ send_mail() { # create logs if using 'send_mail -e' [ "$1" = "-e" ] && create_logs - echo -en "Automatically generated mail by $SCRIPTNAME + # attach logs only if we have some: + [ -r "$ATTACHMENT" ] && MUTT_ATTACH="-a $ATTACHMENT" || MUTT_ATTACH='' + + echo "Automatically generated mail by $SCRIPTNAME $ISO_DETAILS -Return code of grml-live run was: $RC +Return code of grml-live was: $RC +Time: $WALLTIME $(grep -A2 'Executed grml-live' $GRML_LOGFILE || echo "* executed grml-live command line not available") @@ -117,11 +124,15 @@ $(grep -A2 'Executed FAI' $GRML_LOGFILE || echo "* executed FAI command line not The following errors have been noticed (several might be warnings only): -$(grep -i error $FAI_LOGFILES/* /var/log/grml-buildd.std* | grep -ve liberror -ve libgpg-error || echo "* nothing") +$(grep -i error $FAI_LOGFILES/*.log /var/log/grml-buildd.log | grep -ve liberror -ve libgpg-error -ve libcomerr -ve 'no errors found' || echo "* nothing") + +The following errors have been noticed in FAI scripts: + +$(grep -B2 "FAILED with exit code" $FAI_LOGFILES/* | echo "* nothing") The following warnings have been noticed: -$(grep -i warn $FAI_LOGFILES/* /var/log/grml-buildd.std* || echo "* nothing") +$(grep -i warn $FAI_LOGFILES/* /var/log/grml-buildd.log || echo "* nothing") There following dependency problems have been noticed: @@ -131,11 +142,11 @@ The following packages could not be installed: $(grep -i "Couldn't find.*package" $FAI_LOGFILES/software.log | sed 's/\(.*\)"\(.*\)"\(.*\)/\2/' | sort -u || echo "* nothing") -See attached files: -/var/log/grml-buildd.stderr /var/log/grml-buildd.stdout $ATTACHMENT +See attached files for further details. EOF" | \ - nail -r "grml-live autobuild daemon <$FROM>" -s "$SCRIPTNAME [${DATE}] - $RC_INFO" -a /var/log/grml-buildd.stderr $ATTACHMENT "$RECIPIENT" + mutt -e "my_hdr From: grml-live autobuild daemon <$FROM>" -s "$SCRIPTNAME [${DATE}] - $RC_INFO" \ + -a /var/log/grml-buildd.log $MUTT_ATTACH -- "$RECIPIENT" } # make sure we store the final iso: