view icedtea/build.sh @ 1:c3adcbdf8b9d

Add old build.sh shell script for reference. This old shell script is also still running on builder.classpath.org. But please try to improve the buildbot master.cfg setup instead of adding more hacks to this script.
author Mark Wielaard <mark@klomp.org>
date Mon, 21 Feb 2011 10:09:31 +0100
parents
children c1b784e9bafc
line wrap: on
line source

#!/bin/bash

# Copyright (C) 2009, 2010, Mark J. Wielaard <mark@klomp.org>
# This IcedTea build script is free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
# http://www.gnu.org/copyleft/gpl.html

# OLD builder script. Being slowly replaced with buildbot setup.
# Please improve the master.cfg buildbot configuration instead of
# trying to improve this hacky shell script.
#
# Currently being run on builder.classpath.org with:
# while true; do time ./build.sh 6; date; sleep 600; \
#                time ./build.sh 7; date; sleep 600; done 2>&1 | tee build.log

# Where to send error reports, add committers later.
EMAIL="testresults@icedtea.classpath.org"

# Can we check somehow whether there is a build busy?
# http://www.davidpashley.com/articles/writing-robust-shell-scripts.html

if [ $# -ne 1 ]; then
 echo "build.sh takes one argument 6 or 7"
 exit -1;
elif [ "$1" != "6" -a "$1" != "7" ]; then
 echo "build.sh argument must be 6 or 7"
 exit -1;
fi

BASE_BUILD_DIR=/usr/local/build
ICEDTEA_DIR=$BASE_BUILD_DIR/icedtea$1
ICEDTEA_BUILD_DIR=$BASE_BUILD_DIR/icedtea$1-build

# Build artifacts, sources and test results will be stored here.
RESULTS_DIR=/usr/local/build/results/icedtea$1

echo "Building $ICEDTEA_DIR"
echo " in $ICEDTEA_BUILD_DIR"
echo " results into $RESULTS_DIR"

cd $ICEDTEA_DIR
HG_LAST_ID=$(hg id -i -r tip)
HG_LAST_REV=$(hg id -n -r tip)
echo "Last hg id: $HG_LAST_ID (local rev: $HG_LAST_REV)"

hg pull && hg update
HG_CURRENT_ID=$(hg id -i -r tip)
HG_CURRENT_REV=$(hg id -n -r tip)

if [ "$HG_LAST_ID" == "$HG_CURRENT_ID" ]; then
  echo "Nothing to do last id: $HG_LAST_ID, equals current id: $HG_CURRENT_ID"
  exit 1
fi

echo "Rebuilding: last id: $HG_LAST_ID, current id: $HG_CURRENT_ID"

# The range of changes (one past the last local rev)
HG_REV_RANGE="$(expr $HG_LAST_REV + 1):$HG_CURRENT_REV"

# Which people made changes between then and now?
# Qualify those users without a full email address as @icedtea.classpath.org.
AT_USERS=$(hg log -r$HG_REV_RANGE --template '{author|email}\n' \
	| sort -u | grep @)
NO_AT_USERS=$(hg log -r$HG_REV_RANGE --template '{author|email}\n' \
	| sort -u | grep -v @ | sed s/\$/\@icedtea.classpath.org/)
USERS="$AT_USERS $NO_AT_USERS"

CHANGES=$(hg log -r$HG_REV_RANGE --template \
  'rev:  {node|short}\nuser: {author}\ndate: {date|date}\n\n{desc|strip}\n\n')

# echo "Changes made by: $USERS"
# echo "Changes: $CHANGES"

# Warn everybody that made changes in case something went wrong.
EMAIL="$EMAIL $USERS"

# Announce the test build coming up.
#(echo -n "Doing a test build for IcedTea$1"; echo; echo "$CHANGES") \
#	| mail -s "IcedTea$1 build testing for $HG_CURRENT_ID" $EMAIL

# Remove both 6 and 7, there is only disk space for one build
#echo "Removing old builds $BASE_BUILD_DIR/icedtea6-build $BASE_BUILD_DIR/icedtea7-build..."
#rm -rf $BASE_BUILD_DIR/icedtea6-build $BASE_BUILD_DIR/icedtea7-build
echo removing old build in $ICEDTEA_BUILD_DIR
rm -rf $ICEDTEA_BUILD_DIR

mkdir $ICEDTEA_BUILD_DIR

# Might contain old tar.gz/bz2 sources so we don't need to redownload.
# Some are in the top level dir, others are in the drops subdir.
# Don't worry if cp fails, we will download fresh ones.
SOURCES_DIR=$RESULTS_DIR/src
cp -r $SOURCES_DIR/*.tar.* $SOURCES_DIR/drops $ICEDTEA_BUILD_DIR/

BUILD_LOG_FILE=$BASE_BUILD_DIR/build-icedtea$1.log
echo "Putting build log in $BUILD_LOG_FILE"

# Make sure a failure in any command in a pipe, fails the whole pipe command.
set -o pipefail

# Build in separate dir.
# Figure out a way to use local openjdk tar.gz files
# maybe just copy to to an archive dir before cleanup and then copy back.
# Keep logs of build, and check if it was successfull
(cd $ICEDTEA_DIR && ./autogen.sh \
	&& cd $ICEDTEA_BUILD_DIR \
	&& $ICEDTEA_DIR/configure \
		--enable-nss \
		--with-additional-vms=cacao,shark \
	&& make VERBOSE=true) 2>&1 | tee $BUILD_LOG_FILE
BUILD_RESULT=$?

echo "Build result: $BUILD_RESULT"

# store the full build log and config.log file
cp $ICEDTEA_BUILD_DIR/config.log $BUILD_LOG_FILE $RESULTS_DIR/

RESULTS_URL="http://builder.wildebeest.org/icedtea/icedtea$1/"

if [ $BUILD_RESULT -ne 0 ]; then
  (echo "The current IcedTea$i build fails."; \
   echo; \
   echo "More info at $RESULTS_URL"; \
   echo; \
   echo "Possibly, but not necessarily, because of one of these changes:"; \
   echo; \
   echo "$CHANGES"; \
   echo; echo; \
   echo "Last part of build log: "; echo; \
   tail -160 $BUILD_LOG_FILE) \
	| mail -s "IcedTea$1 build failed for $HG_CURRENT_ID" $EMAIL
  exit -1
fi

# Run tests under fake x-server so gui tests work "normally"
cd $ICEDTEA_BUILD_DIR && xvfb-run -e xvfb-errors -a -s -ac make check -k

# Old results are here, new results will be stored there.
TESTS_DIR=$RESULTS_DIR/test

cmp $ICEDTEA_BUILD_DIR/test/jtreg-summary.log $TESTS_DIR/jtreg-summary.log
TEST_RESULT=$?

echo "Test results compare: $TEST_RESULT"

if [ $TEST_RESULT -ne 0 ]; then
  (echo "The current IcedTea$i build test results changed."; \
   echo; \
   echo "Changed test results: "; echo; \
   diff -u $TESTS_DIR/jtreg-summary.log \
	   $ICEDTEA_BUILD_DIR/test/jtreg-summary.log; \
   echo; \
   echo "More info at $RESULTS_URL"; \
   echo; \
   echo "Possibly, but not necessarily, because of one of these changes:"; \
   echo; \
   echo "$CHANGES") \
	| mail -s "IcedTea$1 test results changed for $HG_CURRENT_ID" $EMAIL;
else
  (echo "The current IcedTea$i build succeeded, no changes in test results."; \
   echo; \
   echo "More info at $RESULTS_URL"; \
   echo; \
   echo "New changes since last time:"; \
   echo; \
   echo "$CHANGES") \
	| mail -s "IcedTea$1 build succeeded for $HG_CURRENT_ID" $EMAIL;
fi

# Need to fixup jtreg report html files.
# Escape paths for sed.
# From path is absolute build path on (chrooted) file system.
# To path is absolute (prefix) path on webserver.
FROM_PATH="\/usr\/local\/build\/icedtea$1-build\/test\/"
TO_PATH="\/icedtea\/icedtea$1\/test\/"
for i in `find $ICEDTEA_BUILD_DIR/test/*/JTreport -name \*.html`; do \
	 sed -i "s/$FROM_PATH/$TO_PATH/" $i; \
done

rm -rf $TESTS_DIR
mkdir $TESTS_DIR
cd $ICEDTEA_BUILD_DIR
cp -r test/*log test/jdk test/hotspot test/langtools $TESTS_DIR/

# Not enough room to keep the debuginfo, remove it for now.
#find $ICEDTEA_BUILD_DIR/openjdk/build/linux-i586/j2sdk-image/jre/lib \
#	-name \*.so \
#	| xargs strip --strip-debug --preserve-dates

# Package up the resulting j2sdk-image dir.
cd $ICEDTEA_BUILD_DIR/openjdk.build
tar zcf j2sdk-image.tar.gz j2sdk-image

mv j2sdk-image.tar.gz $RESULTS_DIR/

# Store old tar.gz/bz2 source bundles and drops, might be useful next time.
rm -rf $SOURCES_DIR
mkdir $SOURCES_DIR
cp -r $ICEDTEA_BUILD_DIR/*.tar.* $ICEDTEA_BUILD_DIR/drops $SOURCES_DIR/

# And the actual icedtea sources used.
rm -f $SOURCES_DIR/icedtea$1.tar.gz
cd $ICEDTEA_DIR && hg archive --type tgz $SOURCES_DIR/icedtea$1.tar.gz