From 8a55380620f09298814051ebbaeb7807d74971a5 Mon Sep 17 00:00:00 2001 From: Jens Ayton Date: Sat, 8 May 2010 22:04:51 +0000 Subject: [PATCH] Mac nightly builds: actually checked in build script, which had previously been ignored due to a local svn setting. git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@3302 127b21dd-08f5-0310-b4b7-95ae10353056 --- tools/nightly-build/mac/build-nightly | 270 ++++++++++++++++++++++++++ 1 file changed, 270 insertions(+) create mode 100755 tools/nightly-build/mac/build-nightly diff --git a/tools/nightly-build/mac/build-nightly b/tools/nightly-build/mac/build-nightly new file mode 100755 index 00000000..a787ac37 --- /dev/null +++ b/tools/nightly-build/mac/build-nightly @@ -0,0 +1,270 @@ +#! /bin/bash + +VAR_DIR_NAME=var +REPO_DIR_NAME=trunk +CONFIGURATION=TestRelease + +VAR=../$VAR_DIR_NAME/ +LOG=$VAR/log/ +LOG_OLD=$VAR/log-old/ +LOG_SUCCESS=$VAR/log-success/ +COCOA_SRC_DIR=src/Cocoa/ +SNAPSHOT_MACRO_FILE=$COCOA_SRC_DIR/oolite-snapshot.xcconfig +BUILD_DIR=build/$CONFIGURATION/ + +LAST_REVISION_FILE=$VAR/revision +SUCCESS_REVISION_FILE=$VAR/success_revision +PREVIOUS_SUCCESS_REVISION_FILE=$VAR/previous_success_revision +LATEST_NAME_FILE=$VAR/latest +CHANGELOG_FILE=$LOG/change_log +DIAGNOSTICS_FILE=$LOG/diagnostics +STDERR_FILE=$LOG/xcb_stderr.txt +STDOUT_FILE=$LOG/xcb_stdout.txt +STATUS_FILE=$LOG/build_log +SVNUP_FILE=$LOG/svnup.txt +LAST_UPDATED_FILE="$VAR/last_updated" +OOLITE_APP_PKG=$BUILD_DIR/Oolite.app +DEBUG_OXP_PKG=$BUILD_DIR/Debug.oxp +FTP_URL_FILE=../config/ftp_url +FTP_CREDENTIALS_FILE=../config/ftp_credentials + + +function report +{ + if [ `which growlnotify` ] + then + growlnotify -n "Oolite nightly build" -s "$1" -m "$2" + fi + echo $2 +} + + +function fail +{ + if [ $FTP_INFO_SET -eq 1 ] && [ -e $LAST_REVISION_FILE ] + then + curl --silent $FTP_CREDENTIALS -T "$LAST_REVISION_FILE" "$FTP_URL/revision" + fi + report "Oolite nightly build failure" "$1" + exit 1 +} + + +if [ ! -e $REPO_DIR_NAME ] +then +# # Check out repo if necessary. +# CLEAN_CHECKOUT=1 +# +# echo "Checking out Oolite..." +# svn checkout --quiet svn://svn.berlios.de/oolite-linux/trunk $REPO_DIR_NAME +# if [ ! $? ] +# then +# fail "Failed to check out." +# fi +# +# if [ -e $REPO_DIR_NAME/$LAST_REVISION_FILE ] +# then +# rm $REPO_DIR_NAME/$LAST_REVISION_FILE +# fi + + # Can't actually automate checkout because of the need for libpng sources. + fail "No $REPO_DIR_NAME checkout found!" +else + CLEAN_CHECKOUT=0 +fi + + +cd $REPO_DIR_NAME + + +# ftp_url should contain a URL to an upload directory. +# ftp_credentials should contain command line arguments for curl authentication, +# such as -u user:password. +if [ -e $FTP_URL_FILE ] && [ -e $FTP_CREDENTIALS_FILE ] +then + FTP_URL=`head -n 1 "$FTP_URL_FILE"` + FTP_CREDENTIALS=`head -n 1 "$FTP_CREDENTIALS_FILE"` + FTP_INFO_SET=1 +else + FTP_INFO_SET=0 +fi + +# Get $OOLITE_VERSION +source $COCOA_SRC_DIR/oolite-version.xcconfig + + +# Ensure output directories exist. +if [ ! -e $VAR ] +then + mkdir $VAR +fi + + +if [ -e $LOG ] +then + if [ -e $LOG_OLD ] + then + rm -rf $LOG_OLD + fi + mv $LOG $LOG_OLD +fi + + +mkdir $LOG + + +# Get last revision. +if [ ! -e $LAST_REVISION_FILE ] +then + LAST_REVISION=0 +else + LAST_REVISION=`head -n 1 "$LAST_REVISION_FILE"` +fi + + +if [ $CLEAN_CHECKOUT -eq 0 ] +then + # Revert the file we manipulate for watermarking, then update repo. + echo "Updating..." + svn revert --quiet $SNAPSHOT_MACRO_FILE + svn update > $SVNUP_FILE + if [ $? -ne 0 ] + then + echo "Update failed: " > $DIAGNOSTICS_FILE + cat $SVNUP_FILE >> $DIAGNOSTICS_FILE + fail "SVN update failed." + fi +fi + + +# Get current revision. +CURRENT_REVISION=`svn info 2> /dev/null | grep "Revision:" | cut -f 2 -d " "` +if [ ! $? ] +then + fail "Could not get revision number." +fi + +if [ $LAST_REVISION -eq $CURRENT_REVISION ] +then + report "Oolite nightly unchanged" "No change, still at revision $LAST_REVISION." + exit 0 +fi + +echo "Updated from revision $LAST_REVISION to $CURRENT_REVISION, building..." + +# Delete existing build products so no old files are left lying around. +if [ -e $OOLITE_APP_PKG ] +then + rm -rf $OOLITE_APP_PKG +fi +if [ -e $DEBUG_OXP_PKG ] +then + rm -rf $DEBUG_OXP_PKG +fi + +# Nastytacular: overwrite the oolite-snapshot.xcconfig file to generate the nightly watermark macros. +# The backslash jungle builds a string like -DOOLITE_SNAPSHOT_VERSION="\"1.74-3040\"". +echo "SNAPSHOT_MACROS= -DSNAPSHOT_BUILD=1 -DOOLITE_SNAPSHOT_VERSION=\"\\\"$OOLITE_VERSION-$CURRENT_REVISION\\\"\"" > src/Cocoa/oolite-snapshot.xcconfig + +# Buildez la vache! +xcodebuild -project Oolite.xcodeproj -target "Build All" -configuration $CONFIGURATION RUN_CLANG_STATIC_ANALYZER=NO >$STDOUT_FILE 2>$STDERR_FILE + +# Generate status and diagnostics files. The -mlong-branch bit filters out +# an unimportant warning generated by a bug in the 10.4 SDK for Xcode 3.2. +grep "^[^\ ]" $STDOUT_FILE > $STATUS_FILE +grep -e "warning:" -e "error:" $STDOUT_FILE | grep -v -e "-mlong-branch" > $DIAGNOSTICS_FILE + +# ERROR_COUNT=`grep "error:" $STDOUT_FILE | wc -l | tr -d " "` +# Count all diagnostics since we build with -Werror (and I don't want to +# disable that for nightlies). +ERROR_COUNT=`cat $DIAGNOSTICS_FILE | wc -l | tr -d " "` + +# Set last revision regardless of success or failure, on the basis that a +# failed build isn't likely to suddenly work if you just retry it a day later. +echo $CURRENT_REVISION > $LAST_REVISION_FILE + + +if [ $ERROR_COUNT -ne 0 ] +then + fail "Build failed with $ERROR_COUNT errors." +fi + + +# Write changelog. +if [ $LAST_REVISION -ne 0 ] +then + svn log -r$CURRENT_REVISION:$[$LAST_REVISION + 1] > $CHANGELOG_FILE +else + echo "Initial checkout." > $CHANGELOG_FILE +fi + +mv $SUCCESS_REVISION_FILE $PREVIOUS_SUCCESS_REVISION_FILE +echo $CURRENT_REVISION > $SUCCESS_REVISION_FILE + +# Keep logs of latest successful build. +if [ -e $LOG_SUCCESS ] +then + rm -rf $LOG_SUCCESS +fi +cp -R $LOG $LOG_SUCCESS + +# Pack up a zip file. +FULLVERSION=$OOLITE_VERSION.0.$CURRENT_REVISION-dev +echo "Packaging nightly $FULLVERSION..." + +PACKAGE_NAME=Oolite-nightly-$FULLVERSION +PACKAGE_DIR=$VAR/$PACKAGE_NAME/ +ADDONS_DIR=$PACKAGE_DIR/AddOns/ +ZIP_NAME=oolite-trunk-$FULLVERSION.mac-universal.zip +echo $ZIP_NAME > "$LATEST_NAME_FILE" + +mkdir $PACKAGE_DIR +cp -R $OOLITE_APP_PKG $PACKAGE_DIR +mkdir $ADDONS_DIR +cp -R $DEBUG_OXP_PKG $ADDONS_DIR + +pushd $VAR > /dev/null +ditto -ck --noqtn --noacl --nocache --zlibCompressionLevel 9 $PACKAGE_NAME $ZIP_NAME +if [ ! $? ] +then + fail "Could not create zip archive (ditto failed with exit code $?)." +fi +rm -rf $PACKAGE_NAME +popd > /dev/null + +# Record date of this momentous event. +date > $LAST_UPDATED_FILE + +if [ ! -e $VAR/$ZIP_NAME ] +then + fail "Archive was not made for some reason." +fi + +if [ $FTP_INFO_SET -eq 0 ] +then + report "Oolite nightly success" "Build succeeded, but ftp_url and/or ftp_credentials are missing, so data cannot be uploaded." + exit 0 +fi + + +echo "Uploading $ZIP_NAME..." +curl "-#" $FTP_CREDENTIALS -T "$VAR/$ZIP_NAME" "$FTP_URL/$ZIP_NAME" +if [ ! $? ] +then + echo "" + fail "Upload failed ($?)." +fi + +echo "" +echo "Uploading metadata..." +curl --silent $FTP_CREDENTIALS -T "$LAST_UPDATED_FILE" "$FTP_URL/last_updated" +curl --silent $FTP_CREDENTIALS -T "$CHANGELOG_FILE" "$FTP_URL/change_log" +curl --silent $FTP_CREDENTIALS -T "$DIAGNOSTICS_FILE" "$FTP_URL/diagnostics" +curl --silent $FTP_CREDENTIALS -T "$STATUS_FILE" "$FTP_URL/build_log" +curl --silent $FTP_CREDENTIALS -T "$LAST_REVISION_FILE" "$FTP_URL/revision" +curl --silent $FTP_CREDENTIALS -T "$PREVIOUS_SUCCESS_REVISION_FILE" "$FTP_URL/previous_successful" +curl --silent $FTP_CREDENTIALS -T "$LATEST_NAME_FILE" "$FTP_URL/latest" + + +rm $VAR/$ZIP_NAME +report $"Oolite nightly success" "Successfully built r$CURRENT_REVISION and uploaded as $ZIP_NAME."