#!/bin/sh ########################################################################## # # build-non-ia32-distros-when-asked # # - scans $SUBDISTROSPATH for non-ia32 distros # - watches those dirs for 'delegate' file to appear # - pulls latest Mondo and Mindi sources from CVS # - downloads relevant HTML files (docs, contrib-default.html) from website # - builds new packages (RPMs, SRPMS, tgz's) from CVS sources, # incorporating website's documentation in these packages # - modifies contrib-default.html to point to new packages; # saves as contribute.html # - publish packages and the modified contribute.html on the website # ########################################################################## # # CHANGES:- # # 04/11 # - first incarnation # ########################################################################## LOGFILE=/var/log/`basename $0`.log LOCKFILE=/var/lock/`basename $0`.lck STUFFDIR=/mnt/mondostuff [ ! -d "$STUFFDIR" ] && STUFFDIR=/home/mondostuff SUBDISTROSPATH=$STUFFDIR/distros; # where the sub-distros were installed if [ "$STUFFDIR" = "/home/mondostuff" ] ; then TMPPATH=$STUFFDIR/tmp/build-mandm-tmp else TMPPATH=/tmp/build-mandm-tmp fi ########################################################################## LogIt() { echo "[`date +%H:%M:%S`] $1" >> $LOGFILE } trapped_here() { rm -f $LOCKFILE LogIt "------------------------finishing------------------"; exit 0 } trap trapped_here SIGHUP SIGINT SIGQUIT SIGTRAP SIGABRT SIGPIPE SIGALRM SIGSTOP SIGIO echo "$$ `uname -a`" > $LOCKFILE MY_CPU=amd64 ; # Set this to your CPU type my_distros=`find $SUBDISTROSPATH -type d -maxdepth 2 | grep -x ".*\.$MY_CPU"` LogIt "------------------------starting-------------------" LogIt "my_distros=$my_distros" while [ "1" ] ; do sleep 5 for dir in $my_distros ; do # LogIt "Scanning $dir" if [ -f "$dir/delegate.sh" ] ; then LogIt "$dir is requesting a build" echo "`date`" > $dir/delegating LogIt "Acknowledged. Script reads......." cat $dir/delegate.sh >> $LOGFILE LogIt "(Script ends)" LogIt "Running script..." logf=$dir/delegating.log > $logf cp -f $dir/delegate.sh /tmp chroot $dir /delegate.sh >> $logf 2>> $logf res=$? echo $res > $dir/delegated cat $logf >> $LOGFILE LogIt "Completed. Result=$res. Waiting for result to be recorded." i=0 while [ -e "$dir/delegated" ] && [ "$i" -le "20" ] ; do sleep 1 i=$(($i+1)) done rm -f $dir/delegated LogIt "Event recorded. Let's move on." fi done done # Should never get here exit 0