buildd/functions.sh: use mutt instead of nail again.
authorMichael Prokop <mika@grml.org>
Fri, 18 Mar 2011 13:03:02 +0000 (14:03 +0100)
committerMichael Prokop <mika@grml.org>
Fri, 18 Mar 2011 13:09:49 +0000 (14:09 +0100)
In git commit bbc4b9db068e7ed536161680c84fbed328ddb3af
back in january 2010 we had to switch from mutt to nail
because of an annoying behaviour change in attachment
handling. Now having mutt 1.5.20 in the relevant Debian
suites available let's turn back to mutt, because
nail sucks at attachment handling even more.

buildd/functions.sh
debian/control
docs/grml-live.txt
grml-live
scripts/release_helper.sh

index c05a6ae..1db5a41 100755 (executable)
@@ -13,7 +13,7 @@ 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."
@@ -26,15 +26,17 @@ which nail >/dev/null 2>&1 || die "nail binary not found. Exiting."
 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)"
+MUTT_HEADERS="$(mktemp)"
 [ -n "$TMP_DIR" ]      || die "Could not create \$TMP_DIR. Exiting."
+[ -n "$MUTT_HEADERS" ] || die "Could not create $\MUTT_HEADERS. Exiting."
 
 # 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"
@@ -43,6 +45,7 @@ else
 fi
 
 [ -n "$FAI_LOGFILES" ]  || FAI_LOGFILES=/var/log/fai/grml/last
+echo "my_hdr From: grml-live autobuild daemon <$FROM>" > $MUTT_HEADERS
 
 # execute grml-live:
 grml_live_run() {
@@ -68,7 +71,7 @@ grml_live_run() {
 
   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 \
+             >/var/log/grml-buildd.stdout \
             2>/var/log/grml-buildd.stderr ; RC=$?
 
   if [ "$RC" = "0" ] ; then
@@ -81,7 +84,7 @@ 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 zcf $ATTACHMENT $FAI_LOGFILES /var/log/grml-buildd.stderr /var/log/grml-buildd.stdout $GRML_LOGFILE >/dev/null )
 }
 
 # store logs on remote server:
@@ -105,6 +108,9 @@ send_mail() {
   # create logs if using 'send_mail -e'
   [ "$1" = "-e" ] && create_logs
 
+  # attach logs only if we have some:
+  [ -r "$ATTACHMENT" ] && MUTT_ATTACH="-a $ATTACHMENT" || MUTT_ATTACH=''
+
   echo -en "Automatically generated mail by $SCRIPTNAME
 
 $ISO_DETAILS
@@ -132,10 +138,10 @@ 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
+/var/log/grml-buildd.stderr $ATTACHMENT
 
 EOF" | \
-  nail -r "grml-live autobuild daemon <$FROM>" -s "$SCRIPTNAME [${DATE}] - $RC_INFO" -a /var/log/grml-buildd.stderr $ATTACHMENT "$RECIPIENT"
+  mutt -s "$SCRIPTNAME [${DATE}] - $RC_INFO" -a /var/log/grml-buildd.stderr $MUTT_ATTACH -- "$RECIPIENT"
 }
 
 # make sure we store the final iso:
@@ -155,9 +161,9 @@ store_iso() {
 # allow clean exit:
 bailout() {
   if [ "$RC" = "0" ] ; then
-     rm -rf "$ATTACHMENT" "$TMP_DIR" "$OUTPUT_DIR"
+     rm -rf "$ATTACHMENT" "$TMP_DIR" "$OUTPUT_DIR" "$MUTT_HEADERS"
   else
-     rm -f "$ATTACHMENT"
+     rm -f "$ATTACHMENT" "$MUTT_HEADERS"
      echo "building ISO failed, keeping build files [${OUTPUT_DIR} / ${TMP_DIR}]">&2
   fi
 
index 12686c3..6437f0c 100644 (file)
@@ -40,7 +40,7 @@ Description: log package build information of grml-live to database
 
 Package: grml-live-buildd
 Architecture: all
-Depends: ${misc:Depends}, grml-live, heirloom-mailx
+Depends: ${misc:Depends}, grml-live, mutt (>= 1.5.20), sudo
 Description: autobuild daemon for grml-live
  This package provides example scripts for a simple autobuild
  daemon for the grml-live framework. Those scripts are used
index 3809075..f1add06 100644 (file)
@@ -868,7 +868,7 @@ to get the ratio between the different options):
 * 1 minute and 40 seconds with ZLIB
 
 [[install-local-files]]
-How to I install further files into the chroot/ISO?
+How do I install further files into the chroot/ISO?
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 Just point the configuration variable CHROOT_INSTALL to the directory which
@@ -1047,7 +1047,7 @@ syslinux) then just execute:
   % isohybrid grml.iso
 
 [[basetgz]]
-How to I create a base tar.gz (I386.tar.gz or AMD64.tar.gz)
+How do I create a base tar.gz (I386.tar.gz or AMD64.tar.gz)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 Execute the following commands (requires root):
@@ -1063,6 +1063,49 @@ And finally place the generated tarball in /etc/grml/fai/config/basefiles/ (note
 that it needs to be uppercase letters matching the class names, so: AMD64.tar.gz
 for amd64 and I386.tar.gz for i386).
 
+[[autobuild]]
+How do I set up an autobuild environment?
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+If you want to set up a system like link:http://daily.grml.org/[daily.grml.org]
+the Debian package grml-live-buildd provides all you need to start. Start with
+figuring out the cron job script /usr/share/grml-live/buildd/cronjob.sh.
+
+If you want to automatically update the grml-live Debian package on your build
+system based on the git tree of grml-live (so you get bleeding edge of
+development which might is interesting for services like daily.grml.org) the
+provided release_helper.sh script provides everything you need. Execute as root:
+
+  echo "deb file:/home/grml-live-git/grml-live.build-area/ ./" >> /etc/apt/sources.list.d/grml-live.list
+  adduser --disabled-login --disabled-password grml-live-git
+
+Execute 'visudo' to update sudo configuration and add the following line:
+
+  grml-live-git ALL=NOPASSWD: /usr/bin/apt-get
+
+Switch to user grml-live-git and configure the rest:
+
+  su - grml-live-git
+  mkdir grml-live.build-area
+  git clone git://git.grml.org/grml-live.git
+  git config --global user.name "Grml-Live Git Autobuild"
+  git config --global user.email "grml-live-git@$(hostname)"
+
+Finally install a cron job (as user grml-live-git) like:
+
+  30 00 * * * cd /home/grml-live-git/grml-live.git/ && env AUTOBUILD=1 scripts/release_helper.sh >/home/grml-live-git/grml-live-build.log
+
+Tip: To find out the build date of the installed grml-live package just execute:
+
+  % apt-cache policy grml-live | grep 'Installed.*autobuild'
+   Installed: 0.13.1~autobuild1300450381
+
+and run "date -ud @$STRING" where $STRING is the number behind the "autobuild",
+like:
+
+  % date -ud @1300450081
+  Fri Mar 18 12:08:01 UTC 2011
+
 [[question]]
 I've a question which isn't answered by this document
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
index 37806dd..8188afb 100755 (executable)
--- a/grml-live
+++ b/grml-live
@@ -424,6 +424,7 @@ case $SUITE in
    etch)     ;;
    lenny)    ;;
    squeeze)  ;;
+   wheezy)   ;;
    sid)      ;;
    *) echo "Sorry, $SUITE is not a valid Debian suite, exiting.">&2; bailout 1 ;;
 esac
index b5cd99d..cb32c51 100755 (executable)
@@ -5,31 +5,6 @@
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2 or any later version.
 ################################################################################
-## How to set up autobuild (for automatically updating grml-live.git and
-## build packages out of git tree and install them, e.g. for usage on
-## daily.grml.org):
-# echo "deb file:/home/grml-live-git/grml-live.build-area/ ./" >> /etc/apt/sources.list.d/grml-live.list
-# adduser --disabled-login --disabled-password grml-live-git
-# visudo -> add "grml-live-git ALL=NOPASSWD: /usr/bin/apt-get"
-# su - grml-live-git
-# mkdir /home/grml-live-git/grml-live.build-area
-# git clone git://git.grml.org/grml-live.git
-# git config --global user.name "Grml-Live Git Autobuild"
-# git config --global user.email "grml-live-git@$(hostname)"
-#
-# Finally install a cron job (as user grml-live-git) like:
-# 30 00 * * * cd /home/grml-live-git/grml-live.git/ && env AUTOBUILD=1 scripts/release_helper.sh >/home/grml-live-git/grml-live-build.log
-#
-# Tip: To find out the build date of the installed grml-live package just run:
-#
-# % apt-cache policy grml-live | grep 'Installed.*autobuild'
-#  Installed: 0.13.1~autobuild1300450381
-#
-# and run "date -ud @$STRING" where $STRING is the number
-# behind the "autobuild", like:
-# % date -ud @1300450081
-# Fri Mar 18 12:08:01 UTC 2011
-################################################################################
 
 set -e
 set -u