cron-script.sh revision 18501
10139N/A#!/bin/bash
10139N/A
10139N/A# Sample usage in crontab:
12144N/A# Run, Mon-Fri at 1:30am. Add to build user's crontab.
10139N/A# 30 1 * * 1-5 . /jds/cbe/bin/env.sh; cd /jds/spec-files; I_KNOW_WHAT_IM_DOING=yes ./cron-script.sh
10139N/A#
10139N/A# The same with a jail. Add to root's crontab. Example assumes 'gbuild' is the
10139N/A# build user
10139N/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"
10139N/A#
10139N/A# $Id$
10139N/A
12197N/A
10139N/A# Determine whether to do debug or non-debug build.
10139N/A# On 'even' days of the week (Sun, Tues, Thur, Sat) to a debug build.
10139N/ADEBUG_BUILD=
10139N/ADEBUG_DIR=
11819N/ADOW=$[ $(date +"%w") % 2 ]
12265N/A#if [ $DOW -eq "0" ]; then
12108N/A# DEBUG_BUILD="--with-debug"
10139N/A# DEBUG_DIR=.dbg
10139N/A#fi
10139N/A
10139N/AOSrel=`uname -r | cut -f2 -d.`
10139N/AOSarch_full=`uname -p`
10139N/Aif [ "x$OSarch_full" = "xsparc" ]; then
10139N/A OSarch=s
10139N/Aelse
10139N/A OSarch_full=x86
10139N/A OSarch=x
10139N/Afi
10139N/A
10139N/AGNOME_VER="2.30"
10139N/APRODNAME="G${GNOME_VER}"
10139N/A
10139N/A# directory to copy rpms/srpms to on the remote host
10139N/ARPMSDIR=/sgnome/pkgs/gnome${GNOME_VER}/S${OSrel}${OSarch}/nightly${DEBUG_DIR}
10139N/ALOCKFILE=/sgnome/pkgs/gnome${GNOME_VER}/S${OSrel}${OSarch}/.build.lock
10139N/A
10139N/A# reply-to/to address to send the build log as/to
10139N/AREPLY_TO=laszlo.peter@sun.com
10139N/AEMAIL_ADDR=gnome-re@sun.com
12108N/A
10139N/A# date format appended to the Release tag in the spec files
10139N/A# (passed to the date command on the cmd line)
10139N/ARELEASE_DATE_FMT="%y%m%d"
10139N/A
10139N/A# date format used for naming the directories
10139N/ADIR_DATE_FMT="%Y-%m-%d"
10139N/A
10139N/ARELEASE_DATE=`date +$RELEASE_DATE_FMT`
10139N/ADIR_DATE=`date +$DIR_DATE_FMT`
10139N/A
10139N/A# document root of the web server
10139N/AWEBROOT=/net/jdsserv.ireland/webroots/jds.ireland/htdocs
10139N/A
10139N/A# subdir to keep logs and reports on the webserver
10139N/AWEBDIR=build_reports/gnome${GNOME_VER}/nightly/S${OSrel}${OSarch}
10139N/ALOGDIR=$WEBDIR/$DIR_DATE
10778N/A
10778N/A# ------------ nothing to configure below this line --------------
10139N/A
10139N/Aif [ "x$I_KNOW_WHAT_IM_DOING" != xyes ]; then
10139N/A echo " ,---------------------------------------------------------------."
10139N/A echo "| This script is intended to be run from cron for producing |"
10139N/A echo "| official nightly builds. It will mail responsible engineers |"
10139N/A echo "| if any build failure occurs, sends build reports to v"
10139N/A echo "| RE and update web pages."
10139N/A echo "|"
10139N/A echo "| Don't run it unless you know what you are doing. Thanks."
11370N/A echo "|"
12150N/A echo "| Mail gnome-re@sun.com if you need more info."
12108N/A echo "\`------> +"
12108N/A exit 1
12144N/Afi
12144N/A
11142N/AMYNAME="$0"
10139N/AMYDIR=$(cd `dirname $0`; pwd)
10139N/A
10139N/Aif [ "x$1" != x ]; then
10139N/A SPECDIR="$1"
10139N/Aelse
10139N/A SPECDIR="$MYDIR"
10139N/Afi
10139N/A
10139N/A# remove temporary files on exit
10139N/Aclean_up () {
10139N/A case "$MYNAME" in
10139N/A /tmp/cron-script.copy.* )
10424N/A rm -f $MYNAME
10139N/A ;;
10139N/A esac
10139N/A exit
10139N/A}
10139N/A
10139N/Atrap clean_up HUP INT TERM QUIT EXIT
10139N/A
10139N/A# make a copy of the cron script in /tmp and execute that in order to
10139N/A# avoid disasters caused by cvs update.
10139N/Acase "$MYNAME" in
10139N/A /tmp/cron-script.copy.* )
10139N/A ;;
10139N/A *)
10139N/A cp $MYNAME /tmp/cron-script.copy.$$
10139N/A chmod 755 /tmp/cron-script.copy.$$
10139N/A cd /tmp
10139N/A exec /tmp/cron-script.copy.$$ "$MYDIR"
10139N/A ;;
10139N/Aesac
10139N/A
10139N/Afatal_error () {
10139N/A echo "ERROR: $*"
10139N/A exit 1
10139N/A}
10139N/A
10139N/A# Update spec-files-other files and uninstall packages.
10139N/Acd $SPECDIR/../spec-files-other
10139N/A
10139N/A# Revert any local changes
10139N/A/usr/bin/svn revert -R .
10139N/A
10139N/A# checkout-out SVN copy *MUST* be read-only, or "update" needs passwd
10139N/A/usr/bin/svn -q up > /dev/null 2>&1 || fatal_error "SVN update of spec-files-other failed"
10139N/A
10139N/A# Uninstall the spec-files-other packages.
10139N/Apkgtool uninstall-pkgs --with-l10n --with-indiana-branding core/*.spec experimental/*.spec l10n/*.spec
10139N/A
10139N/A# Uninstall and cleanup spec-files packages.
10139N/Acd $SPECDIR || fatal_error "$SPECDIR not found"
10139N/A
10139N/A#revert any local changes
10139N/A/usr/bin/svn revert -R .
10139N/A
10139N/A# checkout-out SVN copy *MUST* be read-only, or "update" needs passwd
10139N/A/usr/bin/svn -q up > /dev/null 2>&1 || fatal_error "SVN update failed"
10139N/A
10139N/A# if the script changed during cvs update, restart with the updated script
10139N/Acd $SPECDIR
10139N/Aif ! /usr/bin/cmp -s ./cron-script.sh $MYNAME; then exec ./cron-script.sh; fi
10139N/A
10139N/A# uninstall all pkgs left behind by a previous build
10139N/Apkgtool uninstall-pkgs --with-l10n --with-indiana-branding --define 'support_level supported' closed/*.spec *.spec indiana/*.spec >/dev/null
10139N/A# remove-gnome will now remove anything left from uninstall-pkgs in case
10139N/A# or a packaging change for example
10139N/A$SPECDIR/scripts/remove-gnome --version jds -q -f --no_extras > /dev/null 2>&1
10139N/A
10139N/A
10139N/Arm -rf /jds/packages/PKGS/*
10139N/Arm -rf /jds/packages/SPKGS/*
12197N/Arm -rf /jds/packages/BUILD/*
12197N/Arm -rf /var/tmp/pkgbuild-*/*
12171N/A
12171N/A# if the log directory exists, open a new one with numbered suffix
12171N/ANEW_LOGDIR=$LOGDIR
12145N/AN=1
12145N/Awhile [ -d $WEBROOT/$NEW_LOGDIR ]; do
12144N/A NEW_LOGDIR=$LOGDIR.$N
12144N/A N=`expr $N + 1`
12108N/Adone
12108N/A
12108N/ALOGDIR=$NEW_LOGDIR
12071N/Amkdir -p $WEBROOT/$LOGDIR || exit 5
12071N/A
12022N/Amkdir -p $RPMSDIR
12022N/Atouch $LOCKFILE
11922N/A
11922N/A# Rebuild the manpage tarballs
11819N/Acd $SPECDIR
11819N/Arm -r po-sun/po-sun-tarballs manpages*/sun-manpage-tarballs
11416N/A/usr/gnu/bin/make
11416N/Acd $SPECDIR/../spec-files-other
11370N/Arm -r po-sun/po-sun-tarballs manpages/sun-manpage-tarballs
11370N/A/usr/gnu/bin/make
11370N/A
11256N/Acd $SPECDIR
11256N/A
11172N/A#FIXME: The smf service could not run correctly in jail, hack the script here.
11175N/Aif [ -f /THIS_IS_JAIL_* ]; then
11136N/A # make sure there is no libsqlite3.so because it will be built out later on
11136N/A rm -f /usr/lib/libsqlite3.so*
11123N/A
11123N/A # build SUNWdesktop-cache.spec and SUNWsqlite3.spec at beginning
11083N/A egrep -v '^(Requires|BuildRequires):' SUNWdesktop-cache.spec > SUNWdesktop-cache.spec.tmp.$$
11083N/A pkgtool build --nonotify --with-l10n ${DEBUG_BUILD} --define "nightly 1" --with-indiana-branding --define 'support_level supported' SUNWdesktop-cache.spec.tmp.$$ SUNWsqlite3.spec
11083N/A rm -f SUNWdesktop-cache.spec.tmp.$$
11066N/A
11071N/A #FIXME: The smf service could not run correctly in jail, hack desktop-cache smf script here.
11071N/A grep -i "Solaris Next" /etc/release >/dev/null 2>&1
11066N/A if [ $? -eq 0 ]; then
10972N/A printf "1a\n\nexit 0\n.\nw"| pfexec ed -s /usr/share/desktop-cache/restart_fmri
10972N/A else
10972N/A su<<EO_SU
10820N/A cat<<EOF>/usr/share/desktop-cache/restart_fmri
10820N/A#!/bin/ksh
10778N/A
10778N/Aexit 0
10778N/AEOF
10778N/AEO_SU
10774N/A fi
10774N/Afi
10748N/A
10748N/A# build gnome-xml separately. It creates an smf manifest which generates some
10666N/A# docbook manifests. Generate them manually since this won't work in a jail.
10666N/A
10650N/Aif [ -f /THIS_IS_JAIL_* ]; then
10650N/A pkgtool build --no-notify --with-l10n ${DEBUG_BUILD} --define "nightly 1" \
10596N/A --with-indiana-branding --define 'support_level supported' SUNWgnome-xml.spec
10596N/A pfexec /usr/share/sgml/docbook/docbook-catalog-uninstall.sh
10580N/A pfexec /usr/share/sgml/docbook/docbook-catalog-install.sh
10580N/Afi
10473N/A
10473N/A# start the build
10424N/Apkgtool -v --nightly --date "$RELEASE_DATE" build closed/SUNWevolution-bdb-devel.spec closed/*.spec *.spec indiana/*.spec \
10424N/A --download \
10424N/A --logdir=$WEBROOT/$LOGDIR \
10346N/A --logdir-url=http://jds.ireland/$LOGDIR \
10346N/A --mail-errors-to=gnome-2-10-build-reports@sun.com \
10285N/A --prodname="${PRODNAME}/s${OSrel}${OSarch}" \
10285N/A --live --with-l10n ${DEBUG_BUILD} \
10179N/A --define "nightly 1" --with-indiana-branding \
10187N/A --without-dt --without-blueprint \
10139N/A --define 'support_level supported' \
10139N/A --summary-log=$WEBROOT/$LOGDIR.html \
10139N/A --summary-title="${PRODNAME} S${OSrel}/${OSarch_full} Nightly Build Report `date +'%d %B %Y'`" \
10139N/A --rpm-url=file:///net/jdsserv.ireland/$RPMSDIR/all_pkgs \
10139N/A > /tmp/build.log.$$ 2>&1
10139N/A
10139N/A# the number of failed pkgs is returned
10139N/AFAILED=$?
10139N/A
10139N/A# Build spec-files-other
10139N/Acd $SPECDIR/../spec-files-other
10139N/A
10139N/Apkgtool -v --nightly --date "$RELEASE_DATE" build core/*.spec experimental/*.spec l10n/*.spec \
10139N/A --download \
10139N/A --logdir=$WEBROOT/$LOGDIR \
10139N/A --logdir-url=http://jds.ireland/$LOGDIR \
10139N/A --mail-errors-to=gnome-2-10-build-reports@sun.com \
10139N/A --prodname="${PRODNAME}/s${OSrel}${OSarch}" \
10139N/A --live --with-l10n ${DEBUG_BUILD} \
10139N/A --define "nightly 1" --with-indiana-branding \
10139N/A --without-dt --without-blueprint \
10139N/A --define 'support_level supported' \
10139N/A --summary-log=$WEBROOT/$LOGDIR-other.html \
10139N/A --summary-title="${PRODNAME} S${OSrel}/${OSarch_full} SFO Nightly Build Report `date +'%d %B %Y'`" \
10139N/A --rpm-url=file:///net/jdsserv.ireland/$RPMSDIR/all_pkgs \
10139N/A >> /tmp/build.log.$$ 2>&1
10139N/A
10139N/A# The number of failed pkgs is returned
10139N/AFAILED_OTHER=$?
10139N/A# End spec-files-other build.
10139N/A
10139N/A#FIXME: Removed the hacked package SUNWdesktop-cache and build a regular one at the end
10139N/Aif [ -f /THIS_IS_JAIL_* ]; then
10139N/A pkgtool uninstall-pkgs --nonotify --with-l10n SUNWdesktop-cache.spec
10139N/A pkgtool build-only --nonotify --with-l10n ${DEBUG_BUILD} --define "nightly 1" --with-indiana-branding --define 'support_level supported' SUNWdesktop-cache.spec
10139N/Afi
10139N/A
10139N/A# rotate rpms dir
10139N/Arm -rf $RPMSDIR.prev
10139N/Amv $RPMSDIR $RPMSDIR.prev; mkdir -p $RPMSDIR
10139N/A
10139N/A# make dist
10139N/A/sgnome/tools/re-scripts/jds-build/make-jds-dist.pl -l /sgnome/tools/re-scripts/jds-build/vermillion-devel.lst --nightly /jds/packages/PKGS /jds/dist nightly- > /dev/null 2>&1
10139N/Acp -r /jds/dist/nightly-/${OSarch_full}/* /jds/dist/nightly-/${OSarch_full}/.??* $RPMSDIR
10139N/Achmod a+x $RPMSDIR/install-jds
10139N/Amkdir -p $RPMSDIR/all_pkgs
10139N/Acd $RPMSDIR/all_pkgs
10139N/Aln -s ../*/*.tar.gz .
10139N/Arm -rf /jds/dist/nightly-
10139N/A
10139N/A# Send output of make-jds-dist.pl to GNOME RE for review.
10139N/A/sgnome/tools/re-scripts/jds-build/make-jds-dist.pl -l /sgnome/tools/re-scripts/jds-build/vermillion-devel.lst --nightly /jds/packages/PKGS /jds/dist nightly- -dryrun 2>&1 | \
10139N/A mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} nightly build: make-jds-dist.pl output" "gnome-re@sun.com"
10139N/A
10139N/AALL_REPORTS=$WEBROOT/$WEBDIR/all_reports.html
10139N/Atouch $ALL_REPORTS
10139N/A
10139N/Acp $ALL_REPORTS $ALL_REPORTS.old
10139N/Aexport FAILED FAILED_OTHER ALL_REPORTS
10139N/A
10139N/A# update web page
10139N/A( echo "<tr><td><a href=/$LOGDIR.html>$DIR_DATE</a></td>"; \
10139N/A echo " <td>$FAILED package(s) failed</td></tr>"; \
10139N/A echo "<tr><td><a href=/$LOGDIR-other.html>$DIR_DATE</a></td>"; \
10139N/A echo " <td>$FAILED_OTHER SFO package(s) failed</td></tr>"; \
10139N/A cat $ALL_REPORTS.old ) > $ALL_REPORTS
10139N/A
10139N/A# Report absolute symlinks. These are blockers for Solaris integration.
10139N/Agrep 'is an absolute symlink' $WEBROOT/$LOGDIR/*.log >>/tmp/build.log.$$
10139N/A
10139N/A# Count the number of local patches.
10139N/Apatch_count=`ls $SPECDIR/patches/*.diff | wc -l`
10139N/Aecho "PATCH COUNT: $patch_count local patches used in this build.">>/tmp/build.log.$$
10139N/A
10139N/A# send warnings, errors and summary in email
10139N/Agrep -v '^INFO:' /tmp/build.log.$$ | \
10139N/A mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} nightly build: $FAILED pkgs failed" $EMAIL_ADDR
10139N/A
10139N/Arm -f /tmp/build.log.$$
10139N/A
10139N/A# Email Beijing team to begin downloading packages.
10139N/A/usr/bin/echo "*Date: `date '+%Y-%m-%d'`*\n${PRODNAME} S${OSrel} ${OSarch_full} Development nightly build finished: jdsserv.ireland:${RPMSDIR}/download" |
10139N/A mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} Development nightly build: $FAILED pkgs failed" "sunop@triathlon.prc.sun.com,sunop@mhw.prc.sun.com"
10139N/A
10139N/A
10139N/Arm $LOCKFILE
10139N/A
10139N/A# find any differences from the prototype files saved after the
10139N/A# last milestone build
10139N/Acd /jds/spec-files/prototypes/${OSarch_full}
10139N/Afor f in *.proto; do
10139N/A test -f /jds/packages/PKGMAPS/proto/$f || continue
10139N/A cmp -s $f /jds/packages/PKGMAPS/proto/$f && continue
10139N/A echo $f:
10139N/A diff $f /jds/packages/PKGMAPS/proto/$f
10139N/A echo
10139N/Adone > /tmp/proto-changes.$$
10139N/A
10139N/A# if any diffs found mail the result to RE
10139N/Atest -s /tmp/proto-changes.$$ && {
10139N/A ( echo "Prototype changes found since the last milestone build:"
10139N/A echo
10139N/A cat /tmp/proto-changes.$$ ) | \
10139N/A mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} prototype changes" \
10139N/A $EMAIL_ADDR
10139N/A}
10139N/A
10139N/Arm -f /tmp/proto-changes.$$
10139N/A
10139N/Aexit 0
10139N/A