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
13477N/A# Determine whether to do debug or non-debug build.
13477N/A# On 'even' days of the week (Sun, Tues, Thur, Sat) to a debug build.
13477N/ADEBUG_BUILD=
13477N/ADEBUG_DIR=
13477N/ADOW=$[ $(date +"%w") % 2 ]
14020N/A#if [ $DOW -eq "0" ]; then
14020N/A# DEBUG_BUILD="--with-debug"
14020N/A# DEBUG_DIR=.dbg
14020N/A#fi
13477N/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
17777N/AGNOME_VER="2.30"
15204N/APRODNAME="G${GNOME_VER}"
10140N/A
10140N/A# directory to copy rpms/srpms to on the remote host
15204N/ARPMSDIR=/sgnome/pkgs/gnome${GNOME_VER}/S${OSrel}${OSarch}/nightly${DEBUG_DIR}
15204N/ALOCKFILE=/sgnome/pkgs/gnome${GNOME_VER}/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
15204N/AWEBDIR=build_reports/gnome${GNOME_VER}/nightly/S${OSrel}${OSarch}
10140N/ALOGDIR=$WEBDIR/$DIR_DATE
10140N/A
18713N/A# check which subversion should be used
18713N/Aif [ -x /usr/bin/svn ]; then
18713N/A svn_cmd=/usr/bin/svn
18713N/Aelse
18713N/A svn_cmd=svn
18713N/Afi
18713N/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
12789N/A# Uninstall and cleanup spec-files packages.
10140N/Acd $SPECDIR || fatal_error "$SPECDIR not found"
10140N/A
19827N/A# copy libsqlite3.so to make svn cmd worked
19827N/Aif [ -f /THIS_IS_JAIL_* -a \
19827N/A -f /home/gbuild/dave/$OSarch_full/libsqlite3.so ]; then
19827N/A pfexec cp /home/gbuild/dave/$OSarch_full/libsqlite3.so* /usr/lib/
19827N/Afi
19827N/A
10140N/A#revert any local changes
18713N/A$svn_cmd revert -R .
10140N/A
10140N/A# checkout-out SVN copy *MUST* be read-only, or "update" needs passwd
18713N/A$svn_cmd -q up > /dev/null 2>&1 || fatal_error "SVN update failed"
10140N/A
10140N/A# if the script changed during cvs update, restart with the updated script
14277N/Acd $SPECDIR
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
19822N/Apkgtool uninstall-pkgs --nonotify --with-svr4 --with-l10n --download --without-dt --with-indiana-branding --without-blueprint --define 'jds_version JDS4' --define 'support_level supported' specs/*.spec
18927N/A
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
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
18309N/Arm -r po-sun/po-sun-tarballs manpages*/sun-manpage-tarballs
18499N/A/usr/gnu/bin/make
12148N/A
10140N/Acd $SPECDIR
10140N/A
16527N/A#FIXME: The smf service could not run correctly in jail, hack the script here.
16527N/Aif [ -f /THIS_IS_JAIL_* ]; then
18703N/A # remove libsqlite.so* that are manually copied when jail is created.
18703N/A pfexec rm -f /usr/lib/libsqlite3.so*
18359N/A
18359N/A # build SUNWdesktop-cache.spec and SUNWsqlite3.spec at beginning
18654N/A egrep -v '^(Requires|BuildRequires):' specs/SUNWdesktop-cache.spec > specs/SUNWdesktop-cache.spec.tmp.$$
19822N/A pkgtool build --nonotify --with-l10n --with-svr4 ${DEBUG_BUILD} --define "nightly 1" --with-indiana-branding --define 'support_level supported' specs/SUNWdesktop-cache.spec.tmp.$$ specs/SUNWsqlite3.spec specs/SUNWgnome-xml.spec
18654N/A rm -f specs/SUNWdesktop-cache.spec.tmp.$$
18173N/A
18703N/A # upload log file
18703N/A cp /tmp/SUNWgnome-xml.log $WEBROOT/$LOGDIR/
18703N/A
18703N/A # build gnome-xml separately. It creates an smf manifest which generates some
18703N/A # docbook manifests. Generate them manually since this won't work in a jail.
18808N/A pfexec bash /usr/share/sgml/docbook/docbook-catalog-uninstall.sh
18808N/A pfexec bash /usr/share/sgml/docbook/docbook-catalog-install.sh
18703N/A
18359N/A #FIXME: The smf service could not run correctly in jail, hack desktop-cache smf script here.
18703N/A if (egrep -i "(Solaris Next|OpenSolaris)" /etc/release >/dev/null 2>&1); then
18173N/A printf "1a\n\nexit 0\n.\nw"| pfexec ed -s /usr/share/desktop-cache/restart_fmri
18173N/A else
18173N/A su<<EO_SU
18173N/A cat<<EOF>/usr/share/desktop-cache/restart_fmri
16527N/A#!/bin/ksh
16527N/A
16527N/Aexit 0
16527N/AEOF
16527N/AEO_SU
18173N/A fi
16527N/Afi
16527N/A
10140N/A# start the build
18654N/Apkgtool -v --nightly --date "$RELEASE_DATE" build specs/SUNWevolution-bdb-devel.spec specs/*.spec \
16841N/A --download \
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}" \
16293N/A --live --with-l10n ${DEBUG_BUILD} \
18014N/A --define "nightly 1" --with-indiana-branding \
19822N/A --with-svr4 --without-dt --without-blueprint \
18014N/A --define 'support_level supported' \
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
18929N/A#FIXME: Rebuild SUNWdesktop-cache a regular one at the end
16607N/Aif [ -f /THIS_IS_JAIL_* ]; then
19822N/A pkgtool build-only --nonotify --with-l10n --with-svr4 ${DEBUG_BUILD} --define "nightly 1" --with-indiana-branding --define 'support_level supported' specs/SUNWdesktop-cache.spec
16607N/Afi
16607N/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
13467N/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
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 .
13477N/Arm -rf /jds/dist/nightly-
10140N/A
13035N/A# Send output of make-jds-dist.pl to GNOME RE for review.
13467N/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 | \
13035N/A mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} nightly build: make-jds-dist.pl output" "gnome-re@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>"; \
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