cron-script.sh revision 12737
10140N/A#!/bin/bash
10140N/A
10140N/A# Sample usage in crontab:
10140N/A# Run, Mon-Fri at 1:30am. Add to build user's crontab.
10143N/A# 30 1 * * 1-5 . /jds/cbe/bin/env.sh; cd /jds/spec-files; I_KNOW_WHAT_IM_DOING=yes ./cron-script.sh
10140N/A#
10140N/A# The same with a jail. Add to root's crontab. Example assumes 'gbuild' is the
10140N/A# build user
10143N/A# 30 1 * * 1-5 /usr/sbin/chroot /path/to/jail/root /usr/bin/su - gbuild -c ". /jds/cbe/bin/env.sh; cd /jds/spec-files; I_KNOW_WHAT_IM_DOING=yes ./cron-script.sh"
10140N/A#
10140N/A# $Id$
10140N/A
10140N/A
10140N/AOSrel=`uname -r | cut -f2 -d.`
10140N/AOSarch_full=`uname -p`
10140N/Aif [ "x$OSarch_full" = "xsparc" ]; then
10140N/A OSarch=s
10140N/Aelse
10140N/A OSarch_full=x86
10140N/A OSarch=x
10140N/Afi
10140N/A
11839N/APRODNAME="G2.22"
10140N/A
10140N/A# directory to copy rpms/srpms to on the remote host
11839N/ARPMSDIR=/sgnome/pkgs/gnome2.22/S${OSrel}${OSarch}/nightly
11839N/ALOCKFILE=/sgnome/pkgs/gnome2.22/S${OSrel}${OSarch}/.build.lock
10140N/A
10140N/A# reply-to/to address to send the build log as/to
10140N/AREPLY_TO=laszlo.peter@sun.com
10140N/AEMAIL_ADDR=gnome-re@sun.com
10140N/A
10140N/A# date format appended to the Release tag in the spec files
10140N/A# (passed to the date command on the cmd line)
10140N/ARELEASE_DATE_FMT="%y%m%d"
10140N/A
10140N/A# date format used for naming the directories
10140N/ADIR_DATE_FMT="%Y-%m-%d"
10140N/A
10140N/ARELEASE_DATE=`date +$RELEASE_DATE_FMT`
10140N/ADIR_DATE=`date +$DIR_DATE_FMT`
10140N/A
10140N/A# document root of the web server
10394N/AWEBROOT=/net/jdsserv.ireland/webroots/jds.ireland/htdocs
10140N/A
10140N/A# subdir to keep logs and reports on the webserver
11839N/AWEBDIR=build_reports/gnome2.22/nightly/S${OSrel}${OSarch}
10140N/ALOGDIR=$WEBDIR/$DIR_DATE
10140N/A
10140N/A# ------------ nothing to configure below this line --------------
10140N/A
10140N/Aif [ "x$I_KNOW_WHAT_IM_DOING" != xyes ]; then
10140N/A echo " ,---------------------------------------------------------------."
10140N/A echo "| This script is intended to be run from cron for producing |"
10140N/A echo "| official nightly builds. It will mail responsible engineers |"
10140N/A echo "| if any build failure occurs, sends build reports to v"
10140N/A echo "| RE and update web pages."
10140N/A echo "|"
10140N/A echo "| Don't run it unless you know what you are doing. Thanks."
10140N/A echo "|"
10140N/A echo "| Mail gnome-re@sun.com if you need more info."
10140N/A echo "\`------> +"
10140N/A exit 1
10140N/Afi
10140N/A
10140N/AMYNAME="$0"
10140N/AMYDIR=$(cd `dirname $0`; pwd)
10140N/A
10140N/Aif [ "x$1" != x ]; then
10140N/A SPECDIR="$1"
10140N/Aelse
10140N/A SPECDIR="$MYDIR"
10140N/Afi
10140N/A
10140N/A# remove temporary files on exit
10140N/Aclean_up () {
10140N/A case "$MYNAME" in
10140N/A /tmp/cron-script.copy.* )
10140N/A rm -f $MYNAME
10140N/A ;;
10140N/A esac
10140N/A exit
10140N/A}
10140N/A
10140N/Atrap clean_up HUP INT TERM QUIT EXIT
10140N/A
10140N/A# make a copy of the cron script in /tmp and execute that in order to
10140N/A# avoid disasters caused by cvs update.
10140N/Acase "$MYNAME" in
10140N/A /tmp/cron-script.copy.* )
10140N/A ;;
10140N/A *)
10140N/A cp $MYNAME /tmp/cron-script.copy.$$
10140N/A chmod 755 /tmp/cron-script.copy.$$
10140N/A cd /tmp
10140N/A exec /tmp/cron-script.copy.$$ "$MYDIR"
10140N/A ;;
10140N/Aesac
10140N/A
10140N/Afatal_error () {
10140N/A echo "ERROR: $*"
10140N/A exit 1
10140N/A}
10140N/A
10140N/Acd $SPECDIR || fatal_error "$SPECDIR not found"
10140N/A
10140N/A#revert any local changes
10140N/Asvn revert -R .
10140N/A
10140N/A# checkout-out SVN copy *MUST* be read-only, or "update" needs passwd
10140N/Asvn -q up > /dev/null 2>&1 || fatal_error "SVN update failed"
10140N/Acd $SPECDIR
10140N/A
10140N/A# if the script changed during cvs update, restart with the updated script
10140N/Aif ! /usr/bin/cmp -s ./cron-script.sh $MYNAME; then exec ./cron-script.sh; fi
10140N/A
10140N/A# uninstall all pkgs left behind by a previous build
12098N/Apkgtool uninstall-pkgs --with-l10n --with-tjds --with-moz-nss-nspr --with-sun-branding closed/*.spec *.spec >/dev/null
10140N/A# remove-gnome will now remove anything left from uninstall-pkgs in case
10140N/A# or a packaging change for example
10143N/A$SPECDIR/scripts/remove-gnome --version jds -q -f --no_extras > /dev/null 2>&1
10140N/A
12600N/A# Update spec-files-other files and uninstall packages.
12600N/Acd $SPECDIR/../spec-files-other
12600N/A
12600N/A# Revert any local changes
12600N/Asvn revert -R .
12600N/A
12600N/A# checkout-out SVN copy *MUST* be read-only, or "update" needs passwd
12600N/Asvn -q up > /dev/null 2>&1 || fatal_error "SVN update of spec-files-other failed"
12600N/A
12600N/A# Uninstall the spec-files-other packages.
12600N/Apkgtool uninstall-pkgs --with-l10n --with-tjds --with-moz-nss-nspr --with-sun-branding core/*.spec experimental/*.spec l10n/*.spec >/dev/null
12600N/A
10140N/Arm -rf /jds/packages/PKGS/*
10140N/Arm -rf /jds/packages/SPKGS/*
10140N/Arm -rf /jds/packages/BUILD/*
10143N/Arm -rf /var/tmp/pkgbuild-*/*
10140N/A
10140N/A# if the log directory exists, open a new one with numbered suffix
10140N/ANEW_LOGDIR=$LOGDIR
10140N/AN=1
10140N/Awhile [ -d $WEBROOT/$NEW_LOGDIR ]; do
10140N/A NEW_LOGDIR=$LOGDIR.$N
10140N/A N=`expr $N + 1`
10140N/Adone
10140N/A
10140N/ALOGDIR=$NEW_LOGDIR
10140N/Amkdir -p $WEBROOT/$LOGDIR || exit 5
10140N/A
10140N/Amkdir -p $RPMSDIR
10140N/Atouch $LOCKFILE
10140N/A
10140N/A# Rebuild the manpage tarballs
11325N/Acd $SPECDIR
11325N/Arm -r po-sun/po-sun-tarballs manpages/sun-manpage-tarballs
11325N/Amake
12148N/A
10140N/Acd $SPECDIR
10140N/A
10140N/A# start the build
10207N/Apkgtool -v --nightly --date "$RELEASE_DATE" build closed/SUNWevolution-bdb-devel.spec closed/*.spec *.spec \
10140N/A --logdir=$WEBROOT/$LOGDIR \
10394N/A --logdir-url=http://jds.ireland/$LOGDIR \
10140N/A --mail-errors-to=gnome-2-10-build-reports@sun.com \
10140N/A --prodname="${PRODNAME}/s${OSrel}${OSarch}" \
12103N/A --live --with-l10n --with-tjds --with-moz-nss-nspr \
11324N/A --define "nightly 1" --with-sun-branding \
10140N/A --summary-log=$WEBROOT/$LOGDIR.html \
10140N/A --summary-title="${PRODNAME} S${OSrel}/${OSarch_full} Nightly Build Report `date +'%d %B %Y'`" \
10390N/A --rpm-url=file:///net/jdsserv.ireland/$RPMSDIR/all_pkgs \
10140N/A > /tmp/build.log.$$ 2>&1
10140N/A
10140N/A# the number of failed pkgs is returned
10140N/AFAILED=$?
10140N/A
12540N/A# Build spec-files-other
12540N/Acd $SPECDIR/../spec-files-other
12540N/A
12540N/Apkgtool -v --nightly --date "$RELEASE_DATE" build core/*.spec experimental/*.spec l10n/*.spec \
12540N/A --logdir=$WEBROOT/$LOGDIR \
12540N/A --logdir-url=http://jds.ireland/$LOGDIR \
12540N/A --mail-errors-to=gnome-2-10-build-reports@sun.com \
12540N/A --prodname="${PRODNAME}/s${OSrel}${OSarch}" \
12540N/A --live --with-l10n --with-tjds --with-moz-nss-nspr \
12540N/A --define "nightly 1" --with-sun-branding \
12540N/A --summary-log=$WEBROOT/$LOGDIR-other.html \
12540N/A --summary-title="${PRODNAME} S${OSrel}/${OSarch_full} SFO Nightly Build Report `date +'%d %B %Y'`" \
12540N/A --rpm-url=file:///net/jdsserv.ireland/$RPMSDIR/all_pkgs \
12540N/A >> /tmp/build.log.$$ 2>&1
12551N/A
12551N/A# The number of failed pkgs is returned
12551N/AFAILED_OTHER=$?
12540N/A# End spec-files-other build.
12540N/A
10140N/A# rotate rpms dir
10140N/Arm -rf $RPMSDIR.prev
10140N/Amv $RPMSDIR $RPMSDIR.prev; mkdir -p $RPMSDIR
10140N/A
10140N/A# make dist
10140N/A/sgnome/tools/re-scripts/jds-build/make-jds-dist.pl -l /sgnome/tools/re-scripts/jds-build/vermillion-devel.lst /jds/packages/PKGS /jds/dist nightly- > /dev/null 2>&1
10140N/Acp -r /jds/dist/nightly-/${OSarch_full}/* /jds/dist/nightly-/${OSarch_full}/.??* $RPMSDIR
10140N/Achmod a+x $RPMSDIR/install-jds
10140N/Amkdir -p $RPMSDIR/all_pkgs
10140N/Acd $RPMSDIR/all_pkgs
10140N/Aln -s ../*/*.tar.gz .
10140N/A# Disable deletion of nightly- dir as network area often full - this is backup.
10140N/A#rm -rf /jds/dist/nightly-
10140N/A
12737N/A# Send output of make-jds-dist.pl to Damien for review.
12737N/A/sgnome/tools/re-scripts/jds-build/make-jds-dist.pl -l /sgnome/tools/re-scripts/jds-build/vermillion-devel.lst /jds/packages/PKGS /jds/dist nightly- -dryrun 2>&1 | \
12737N/A mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} nightly build: make-jds-dist.pl output" "damien.carbery@sun.com"
12737N/A
10140N/AALL_REPORTS=$WEBROOT/$WEBDIR/all_reports.html
10140N/Atouch $ALL_REPORTS
10140N/A
10140N/Acp $ALL_REPORTS $ALL_REPORTS.old
12551N/Aexport FAILED FAILED_OTHER ALL_REPORTS
10140N/A
10140N/A# update web page
12551N/A( echo "<tr><td><a href=/$LOGDIR.html>$DIR_DATE</a></td>"; \
12551N/A echo " <td>$FAILED package(s) failed</td></tr>"; \
12551N/A echo "<tr><td><a href=/$LOGDIR-other.html>$DIR_DATE</a></td>"; \
12551N/A echo " <td>$FAILED_OTHER SFO package(s) failed</td></tr>"; \
10140N/A cat $ALL_REPORTS.old ) > $ALL_REPORTS
10140N/A
10140N/A# Report absolute symlinks. These are blockers for Solaris integration.
10140N/Agrep 'is an absolute symlink' $WEBROOT/$LOGDIR/*.log >>/tmp/build.log.$$
10140N/A
10140N/A# Count the number of local patches.
10143N/Apatch_count=`ls $SPECDIR/patches/*.diff | wc -l`
10140N/Aecho "PATCH COUNT: $patch_count local patches used in this build.">>/tmp/build.log.$$
10140N/A
10140N/A# send warnings, errors and summary in email
10140N/Agrep -v '^INFO:' /tmp/build.log.$$ | \
10140N/A mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} nightly build: $FAILED pkgs failed" $EMAIL_ADDR
10140N/A
10140N/Arm -f /tmp/build.log.$$
10140N/A
10140N/A# Email Beijing team to begin downloading packages.
10390N/A/usr/bin/echo "*Date: `date '+%Y-%m-%d'`*\n${PRODNAME} S${OSrel} ${OSarch_full} Development nightly build finished: jdsserv.ireland:${RPMSDIR}/download" |
12051N/A mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} Development nightly build: $FAILED pkgs failed" "sunop@triathlon.prc.sun.com,sunop@mhw.prc.sun.com"
10140N/A
10140N/A
10140N/Arm $LOCKFILE
10140N/A
10140N/A# find any differences from the prototype files saved after the
10140N/A# last milestone build
10140N/Acd /jds/spec-files/prototypes/${OSarch_full}
10140N/Afor f in *.proto; do
10140N/A test -f /jds/packages/PKGMAPS/proto/$f || continue
10140N/A cmp -s $f /jds/packages/PKGMAPS/proto/$f && continue
10140N/A echo $f:
10140N/A diff $f /jds/packages/PKGMAPS/proto/$f
10140N/A echo
10140N/Adone > /tmp/proto-changes.$$
10140N/A
10140N/A# if any diffs found mail the result to RE
10140N/Atest -s /tmp/proto-changes.$$ && {
10140N/A ( echo "Prototype changes found since the last milestone build:"
10140N/A echo
10140N/A cat /tmp/proto-changes.$$ ) | \
10140N/A mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} prototype changes" \
10140N/A $EMAIL_ADDR
10140N/A}
10140N/A
10140N/Arm -f /tmp/proto-changes.$$
10140N/A
10140N/Aexit 0