1 #!/bin/bash 2 3 # host to rcp the rpms to 4 RHOST=blader 5 6 # user to rsh/rcp as (has to have root@<this host> in it's .rhosts file) 7 RUSER=gbuild 8 9 # directory to copy rpms/srpms to on the remote host 10 RPMSDIR=/sgnome/pkgs/gnome2.12/rpms/live 11 SRPMSDIR=/sgnome/pkgs/gnome2.12/srpms/live 12 13 # reply-to/to address to send the build log as/to 14 REPLY_TO=laszlo.peter@sun.com 15 EMAIL_ADDR=gnome-re@sun.com 16 17 # date format appended to the Release tag in the spec files 18 # (passed to the date command on the cmd line) 19 RELEASE_DATE_FMT="%y%m%d.%H" 20 21 # date format used for naming the directories 22 DIR_DATE_FMT="%Y-%m-%d" 23 24 # document root of the web server 25 WEBROOT=/scde/web/docs 26 27 # subdir to keep logs and reports on the webserver 28 WEBDIR=gnome/releng/jds/gnome2.12/live 29 LOGDIR=$WEBDIR/logs 30 31 # subdir where nightly builds go 32 NIGHTLY_DIR=$WEBROOT/gnome/releng/jds/gnome2.12/nightly 33 34 # ------------ nothing to configure below this line -------------- 35 36 #if [ "x$I_KNOW_WHAT_IM_DOING" != xyes ]; then 37 # echo " ,---------------------------------------------------------------." 38 # echo "| This script is intended to be run from cron for producing |" 39 # echo "| official nightly builds. It will mail responsible engineers |" 40 # echo "| if any build failure occurs, sends build reports to v" 41 # echo "| RE and update web pages." 42 # echo "|" 43 # echo "| Don't run it unless you know what you are doing. Thanks." 44 # echo "|" 45 # echo "| Mail gnome-re (at] sun.com if you need more info." 46 # echo "\`------> +" 47 # exit 1 48 #fi 49 50 MYNAME="$0" 51 MYDIR=$(cd `dirname $0`; pwd) 52 53 if [ "x$1" != x ]; then 54 SPECDIR="$1" 55 else 56 SPECDIR="$MYDIR" 57 fi 58 59 # remove temporary files on exit 60 clean_up () { 61 case "$MYNAME" in 62 /tmp/continuous_build.copy.* ) 63 rm -f $MYNAME 64 ;; 65 esac 66 exit 67 } 68 69 trap clean_up HUP INT TERM QUIT EXIT 70 71 # make a copy of this script in /tmp and execute that in order to 72 # avoid disasters caused by cvs update. 73 case "$MYNAME" in 74 /tmp/continuous_build.copy.* ) 75 ;; 76 *) 77 cp $MYNAME /tmp/continuous_build.copy.$$ 78 chmod 755 /tmp/continuous_build.copy.$$ 79 cd /tmp 80 exec /tmp/continuous_build.copy.$$ "$MYDIR" 81 ;; 82 esac 83 84 85 fatal_error () { 86 echo "ERROR: $*" 87 exit 1 88 } 89 90 cd $SPECDIR || fatal_error "$SPECDIR not found" 91 92 N=2 93 94 while true; do 95 96 DIR_DATE=`date +$DIR_DATE_FMT` 97 98 if [ ! -d $NIGHTLY_DIR/$DIR_DATE ]; then 99 ./cron-script.sh 100 fi 101 102 RELEASE_DATE=`date +$RELEASE_DATE_FMT` 103 104 # uninstall all pkgs left behind by a previous build 105 ./build-gnome2 -q uninstall-pkgs *.spec 106 107 cvs -q up -Pd > /dev/null 2>&1 || fatal_error "CVS update failed" 108 109 # if the script changed during cvs update, restart with the updated script 110 if ! /usr/bin/cmp -s ./continuous_build.sh $MYNAME; then 111 exec ./continuous_build.sh; 112 fi 113 114 rm -f /usr/src/packages/SRPMS/* /usr/src/packages/RPMS/*/* 115 116 # if the log directory exists, open a new one with numbered suffix 117 118 if [ "x$N" = x2 ]; then 119 N=1 120 else 121 N=2 122 fi 123 124 cp $WEBROOT/$WEBDIR/live.html $WEBROOT/$WEBDIR/live_prev.html 125 126 rm -rf $WEBROOT/$LOGDIR.$N 127 mkdir -p $WEBROOT/$LOGDIR.$N 128 129 # start the build 130 ./build-gnome2 -v --nightly --date "$RELEASE_DATE" build --target i586 *.spec \ 131 --logdir=$WEBROOT/$LOGDIR.$N \ 132 --logdir-url=http://gnome.ireland/$LOGDIR.$N \ 133 --mail-errors-file=MAINTAINERS \ 134 --mail-errors-cc=gnome-2-10-build-reports@sun.com \ 135 --prodname="G2.12/Linux" \ 136 --good-build-dir=/sgnome/pkgs/gnome2.12/rpms \ 137 --summary-log=$WEBROOT/$WEBDIR/live.html \ 138 --live-summary \ 139 --summary-title="Live Build Report `date +'%d %B %Y, %H:%M'`" \ 140 > /tmp/build.log.$$ 2>&1 141 142 # the number of failed pkgs is returned 143 FAILED=$? 144 145 if [ $FAILED -gt 50 ]; then 146 cat /tmp/build.log.$$ | \ 147 mail -s "WARNING: G2.12/Linux build STOPPED: $FAILED pkgs failed" \ 148 -R $REPLY_TO gnome-re@sun.com 149 rm -f /tmp/build.log.$$ 150 exit 1 151 fi 152 153 # remove old rpms 154 echo '' | rsh $RHOST -l $RUSER "rm -rf $RPMSDIR.prev; mv $RPMSDIR $RPMSDIR.prev; mkdir -p $RPMSDIR" 155 156 # copy new rpms 157 echo '' | rcp `./build-gnome2 --nightly --date "$RELEASE_DATE" install-order \ 158 --full-path --target i586\ 159 *.spec` $RUSER@$RHOST:$RPMSDIR 160 161 # remove old srpms 162 echo '' | rsh $RHOST -l $RUSER "rm -rf $SRPMSDIR.prev; mv $SRPMSDIR $SRPMSDIR.prev; mkdir -p $SRPMSDIR" 163 # copy new srpms 164 echo '' | rcp /usr/src/packages/SRPMS/*.*src.rpm \ 165 $RUSER@$RHOST:$SRPMSDIR 166 167 # send log by email 168 cat /tmp/build.log.$$ | \ 169 mail -s "G2.12/Linux continuous build: $FAILED pkgs failed" \ 170 -R $REPLY_TO $EMAIL_ADDR 171 172 rm -f /tmp/build.log.$$ 173 174 if [ -f /tmp/stop-continuous-build ]; then 175 rm /tmp/stop-continuous-build 176 exit 0 177 fi 178 179 done 180 181 exit 255 182