2005-01-24 07:18:33 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# INDEX build tinderbox script. Build an INDEX for all supported FreeBSD branches
|
|
|
|
# using the latest value of OSVERSION according to the src trees. If the build
|
2005-09-08 17:57:37 +00:00
|
|
|
# fails, yowl about it on ${REPORT_ADDRESS} If not, copy the index to www.freebsd.org so
|
2005-01-24 07:18:33 +00:00
|
|
|
# that 'make fetchindex' sees it.
|
|
|
|
#
|
|
|
|
# When INDEX is broken, assemble the list of committers who touched files
|
2012-10-20 10:36:27 +00:00
|
|
|
# on the most recent 'svn update', and put those committers "on the hook".
|
2005-01-24 07:18:33 +00:00
|
|
|
# These committers all stay on the hook until INDEX is buildable again.
|
2006-11-23 12:16:59 +00:00
|
|
|
#
|
|
|
|
# MAINTAINER= erwin@FreeBSD.org
|
|
|
|
#
|
2005-01-24 07:18:33 +00:00
|
|
|
|
2005-09-08 17:57:37 +00:00
|
|
|
# --------------------------------------------------------
|
|
|
|
# Change these!
|
|
|
|
|
2012-10-20 10:36:27 +00:00
|
|
|
SVN=/usr/local/bin/svn
|
|
|
|
|
2005-09-08 17:57:37 +00:00
|
|
|
# Address for success/failure reports
|
|
|
|
REPORT_ADDRESS=root@localhost
|
|
|
|
|
|
|
|
# Address for script errors
|
|
|
|
ERROR_ADDRESS=root@localhost
|
|
|
|
|
|
|
|
# Where to scp the resulting indexes after build
|
2006-06-19 15:44:16 +00:00
|
|
|
SCP_DEST_HOST=root@localhost
|
2012-10-20 10:36:27 +00:00
|
|
|
SCP_DEST_TMP=/usr/local/www/ports/tmp
|
|
|
|
SCP_DEST_DIR=/usr/local/www/ports/
|
2005-09-08 17:57:37 +00:00
|
|
|
|
|
|
|
# Location of ports tree and source trees
|
2012-10-20 10:36:27 +00:00
|
|
|
export BASEDIR=/a/tindex
|
2006-01-22 20:45:11 +00:00
|
|
|
export PORTSDIR=${BASEDIR}/ports
|
2007-10-25 21:51:07 +00:00
|
|
|
export SRCDIR8=${BASEDIR}/src.8
|
2009-08-23 10:47:02 +00:00
|
|
|
export SRCDIR9=${BASEDIR}/src.9
|
2011-09-27 06:29:35 +00:00
|
|
|
export SRCDIR10=${BASEDIR}/src.10
|
2006-01-22 20:45:11 +00:00
|
|
|
|
2007-06-12 15:14:29 +00:00
|
|
|
# Target architecture if not set in the environment
|
|
|
|
if [ "${ARCH}" = "" ]; then
|
|
|
|
export ARCH=i386
|
|
|
|
fi
|
2007-06-11 21:18:46 +00:00
|
|
|
|
2006-01-22 20:45:11 +00:00
|
|
|
# SSH key to use for copying INDEXes to www host (if non-default)
|
|
|
|
export SSHKEY="-i /home/kris/.ssh/id_dsa-index"
|
2005-09-08 17:57:37 +00:00
|
|
|
|
|
|
|
# --------------------------------------------------------
|
|
|
|
|
2005-01-24 07:18:33 +00:00
|
|
|
blame() {
|
|
|
|
# Find out who is responsible for current version of file $1
|
|
|
|
|
2012-10-20 10:36:27 +00:00
|
|
|
# Fastest way to extract is from svn info
|
|
|
|
who=$(${SVN} info $1 2>/dev/null | grep '^Last Changed Author' | awk '{print $4}')
|
|
|
|
|
|
|
|
echo $who
|
2005-01-24 07:18:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
indexfail() {
|
|
|
|
BRANCH=$1
|
|
|
|
|
|
|
|
# Leave a cookie behind so that we know when the index is fixed
|
2012-10-20 10:36:27 +00:00
|
|
|
touch ${PORTSDIR}/broken.${BRANCH}
|
2005-01-24 07:18:33 +00:00
|
|
|
|
|
|
|
(
|
|
|
|
echo "INDEX build failed with errors:";
|
|
|
|
len=$(wc -l index.out | awk '{print $1}')
|
|
|
|
if [ "$len" -gt "40" ]; then
|
|
|
|
head -20 index.out
|
|
|
|
echo "[...]"
|
|
|
|
tail -20 index.out
|
|
|
|
else
|
|
|
|
cat index.out
|
|
|
|
fi
|
|
|
|
|
|
|
|
len=$(wc -l index.err | awk '{print $1}')
|
|
|
|
if [ "$len" -gt "40" ]; then
|
|
|
|
head -20 index.err
|
|
|
|
echo "[...]"
|
|
|
|
tail -20 index.err
|
|
|
|
else
|
|
|
|
cat index.err
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Find out which committers are on the hook
|
|
|
|
|
2012-10-20 10:36:27 +00:00
|
|
|
commits=$(grep ^U ${PORTSDIR}/svn.log | grep -v INDEX | awk '{print $2}')
|
2005-01-24 07:18:33 +00:00
|
|
|
for i in ${commits}; do
|
2012-10-20 10:36:27 +00:00
|
|
|
blame $i >> ${PORTSDIR}/hook
|
2005-01-24 07:18:33 +00:00
|
|
|
done
|
|
|
|
sort -u ${PORTSDIR}/hook > ${PORTSDIR}/hook.new
|
|
|
|
mv ${PORTSDIR}/hook.new ${PORTSDIR}/hook
|
|
|
|
echo
|
|
|
|
echo "Committers on the hook:"
|
|
|
|
tr -s '\n' ' ' < ${PORTSDIR}/hook
|
|
|
|
echo
|
|
|
|
echo
|
2012-10-20 10:36:27 +00:00
|
|
|
echo "Most recent SVN update was:";
|
|
|
|
grep -v '/work$' svn.log | grep -v '^\?'
|
2005-09-08 17:57:37 +00:00
|
|
|
) | mail -s "INDEX build failed for ${BRANCH}" ${REPORT_ADDRESS}
|
2005-01-24 07:18:33 +00:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
checkfixed() {
|
|
|
|
BRANCH=$1
|
|
|
|
|
|
|
|
# If the cookie exists that means that this is the first build for which the
|
|
|
|
# INDEX succeeded, so announce this.
|
2012-10-20 10:36:27 +00:00
|
|
|
if [ -e ${PORTSDIR}/broken.${BRANCH} ]; then
|
|
|
|
rm -f ${PORTSDIR}/broken.${BRANCH}
|
2005-09-08 17:57:37 +00:00
|
|
|
mail -s "INDEX now builds successfully on ${BRANCH}" ${REPORT_ADDRESS} < /dev/null
|
2005-01-24 07:18:33 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2006-06-19 15:44:16 +00:00
|
|
|
createtmpdir() {
|
2006-06-22 18:52:57 +00:00
|
|
|
TMPDIR=`ssh ${SCP_DEST_HOST} "mktemp -qd ${SCP_DEST_TMP}/tindex.XXXXXX"`
|
2006-06-19 15:44:16 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "$0: Can't create temp file, exiting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2005-01-24 07:18:33 +00:00
|
|
|
# Sanitize the environment so that the indexes aren't customized by the
|
|
|
|
# local machine settinge
|
|
|
|
export __MAKE_CONF=/dev/null
|
|
|
|
export PORT_DBDIR=/nonexistent
|
|
|
|
export PKG_DBDIR=/nonexistent
|
2009-07-14 07:58:50 +00:00
|
|
|
export LOCALBASE=/nonexistent
|
2006-01-22 20:45:11 +00:00
|
|
|
export INDEX_PRISTINE=1
|
2012-10-20 10:36:27 +00:00
|
|
|
export INDEX_JOBS=3
|
2006-01-22 20:45:11 +00:00
|
|
|
export INDEX_QUIET=1
|
2005-01-24 07:18:33 +00:00
|
|
|
|
|
|
|
# First update the source trees to get current OSVERSION
|
2012-10-21 11:46:00 +00:00
|
|
|
${SVN} -q up ${SRCDIR8}/sys/sys
|
2007-10-25 21:51:07 +00:00
|
|
|
OSVERSION8=$(awk '/^#define[[:blank:]]__FreeBSD_version/ {print $3}' < ${SRCDIR8}/sys/sys/param.h)
|
|
|
|
|
2012-10-21 11:46:00 +00:00
|
|
|
${SVN} -q up ${SRCDIR9}/sys/sys
|
2009-08-23 10:47:02 +00:00
|
|
|
OSVERSION9=$(awk '/^#define[[:blank:]]__FreeBSD_version/ {print $3}' < ${SRCDIR9}/sys/sys/param.h)
|
|
|
|
|
2012-10-21 11:46:00 +00:00
|
|
|
${SVN} -q up ${SRCDIR10}/sys/sys
|
2011-09-27 06:29:35 +00:00
|
|
|
OSVERSION10=$(awk '/^#define[[:blank:]]__FreeBSD_version/ {print $3}' < ${SRCDIR10}/sys/sys/param.h)
|
2006-01-22 20:45:11 +00:00
|
|
|
|
2012-10-20 10:36:27 +00:00
|
|
|
|
2005-01-24 07:18:33 +00:00
|
|
|
cd ${PORTSDIR}
|
2013-03-07 14:19:12 +00:00
|
|
|
rm -f INDEX-8 INDEX-8.bz2 INDEX-9 INDEX-9.bz2 INDEX-10 INDEX-10.bz2
|
2012-10-20 10:36:27 +00:00
|
|
|
(${SVN} up 2>1 ) > svn.log
|
|
|
|
if grep -q ^C svn.log ; then
|
|
|
|
(echo "svn update failed with conflicts:";
|
|
|
|
grep ^C svn.log) | mail -s "Ports svn up failed" ${ERROR_ADDRESS}
|
|
|
|
exit 1
|
|
|
|
fi
|
2005-01-24 07:18:33 +00:00
|
|
|
|
2013-03-07 14:19:12 +00:00
|
|
|
for branch in 8.x 9.x 10.x; do
|
2008-12-27 21:24:30 +00:00
|
|
|
release=$(echo $branch | sed -e 's,.x,,')
|
2006-01-22 20:45:11 +00:00
|
|
|
|
2008-12-27 21:24:30 +00:00
|
|
|
eval _osver=\$OSVERSION${release}
|
|
|
|
export OSVERSION=${_osver}
|
2005-01-24 07:18:33 +00:00
|
|
|
|
2008-12-27 21:24:30 +00:00
|
|
|
echo "Building INDEX for ${branch} with OSVERSION=${OSVERSION}"
|
|
|
|
cd ${PORTSDIR}
|
|
|
|
((make index 2> index.err) > index.out) || indexfail ${branch}
|
|
|
|
if [ -s index.err ]; then
|
|
|
|
indexfail ${branch}
|
|
|
|
fi
|
|
|
|
checkfixed ${branch}
|
2007-10-25 21:51:07 +00:00
|
|
|
|
2008-12-27 21:24:30 +00:00
|
|
|
createtmpdir
|
|
|
|
bzip2 -kf ${PORTSDIR}/INDEX-${release}
|
|
|
|
scp -q ${SSHKEY} ${PORTSDIR}/INDEX-${release} ${PORTSDIR}/INDEX-${release}.bz2 ${SCP_DEST_HOST}:${TMPDIR} || mail -s "Cannot copy INDEX-${release} to temp dir" ${ERROR_ADDRESS}
|
|
|
|
ssh ${SCP_DEST_HOST} "/bin/mv ${TMPDIR}/INDEX-${release} ${SCP_DEST_DIR}; /bin/mv ${TMPDIR}/INDEX-${release}.bz2 ${SCP_DEST_DIR}; rmdir ${TMPDIR}" || mail -s "Cannot move INDEX-${release} to final dir" ${ERROR_ADDRESS}
|
|
|
|
done
|
2007-10-25 21:51:07 +00:00
|
|
|
|
2012-10-20 10:36:27 +00:00
|
|
|
# All indexes built successfully, clear the hook
|
|
|
|
rm -f ${PORTSDIR}/hook
|