#!/bin/bash [ -f ~/.d-i_manual_daily ] || exit 1 . ~/.d-i_manual_daily if [ "$DI_BUILDING_FROM_MAIN" ]; then mainlog=$logdir/main.log else mainlog=/dev/stdout fi ALIOTH_DEVREF_PATH=/srv/alioth.debian.org/chroot/home/groups/d-i/htdocs/doc/internals usage() { if [ "$@" ]; then echo "Error: $@" echo fi echo "Usage: $(basename $0)" exit 1 } ## Function to check result of executed programs and exit on error checkfatal() { if [ ! "$1" = "0" ]; then echo "Unexpected error $1 while $2" >>$mainlog touch $ROOT/do_not_build echo "!!!! Autobuilding has been disabled !!!!" >>$mainlog rm -f $ROOT/lockfile exit 999 fi } is_updated() { if egrep "^[UA].[[:space:]]" $logdir/svn_up_devref.log | \ grep -qv "^At revision"; then return 0 fi return 1 } update_from_svn() { echo >>$mainlog echo "Performing SVN update..." >>$mainlog svn --non-interactive up >>$logdir/svn_up_devref.log 2>&1 RESULT=$? if [ ! $RESULT = 0 ]; then echo "SVN update failed with code $RESULT" >>$mainlog echo >>$mainlog cat $logdir/svn_up_devref.log >>$mainlog rm -f $ROOT/lockfile exit 1 fi if svn st 2>/dev/null | grep -q "^C"; then checkfatal "C" "checking for conflicts after 'svn up'" fi } # We want the developer reference files group writable umask 0002 RETRY="" while true; do case $1 in "") break ;; -*) usage "unrecognized option '$1'" ;; *) usage "invalid parameter '$1'" ;; esac shift done [ -f $ROOT/lockfile ] && exit 1 || touch $ROOT/lockfile [ -e "$devref" ] && cd $devref || exit 1 ## Create directories [ -e "$logdir" ] || mkdir -p "$logdir" if [ "$DI_BUILDING_FROM_MAIN" ]; then echo >>$mainlog echo >>$mainlog fi if [ "$DI_BUILDING_FROM_MAIN" ] && [ "$DI_BUILD_DEVREF" != 1 ]; then echo "Not building D-I Internals (as per configuration settings)" >>$mainlog echo >>$mainlog rm -f $ROOT/lockfile exit 0 else : >$logdir/svn_up_devref.log echo "Starting D-I Internals build -- $(date -u)" >>$mainlog fi update_from_svn NR_BUILDS=0 # Build the developers reference if is_updated; then make >>$mainlog 2>&1 checkfatal "$?" "building D-I Internals" if [ "$DI_LOCAL_BUILD" = 1 ]; then echo "Local build! No changes have been uploaded." >>$mainlog else ## Copy the created files to alioth.debian.org echo "rsyncing files to alioth..." >>$mainlog rsync -qzr --perms *.html *.css alioth.debian.org:$ALIOTH_DEVREF_PATH/ >>$mainlog 2>&1 checkfatal "$?" "rsyncing D-I Internals" fi else echo "No changes." >>$mainlog fi echo >>$mainlog echo "Done -- $(date -u)" >>$mainlog rm -f $ROOT/lockfile exit 0