[Box Backup-commit] COMMIT r2957 - box/bitten

subversion at boxbackup.org subversion at boxbackup.org
Tue May 3 12:39:25 BST 2011


Author: jamesog
Date: 2011-05-03 12:39:25 +0100 (Tue, 03 May 2011)
New Revision: 2957

Added:
   box/bitten/minion
Log:
Add minion, a utility/wrapper script for bitten-slave. This script should be used on all hosts wanting to run as a build automation slave.

It provides a few sanity checks of the environment to make sure there are no false build failures logged in Trac.


Added: box/bitten/minion
===================================================================
--- box/bitten/minion	                        (rev 0)
+++ box/bitten/minion	2011-05-03 11:39:25 UTC (rev 2957)
@@ -0,0 +1,205 @@
+#!/bin/sh
+#
+# minion - Wrapper script for bitten-slave for Box Backup
+#
+
+TRAC_URL="https://www.boxbackup.org/trac/builds"
+LOG="-l bitten.log"
+WORK_DIR="build"
+SSH_ID="$HOME/.ssh/bitten-minion"
+
+# Need to export SSH_ID so it's passed down to bitten-slave
+export SSH_ID
+
+build_os=`uname -s | tr [A-Z] [a-z]`
+config="${build_os}.ini"
+
+# Func: chk_env
+# Desc: Checks that the build environment is suitable
+chk_env () {
+	echo "This looks like the first time you've run the bitten minion."
+	echo "I need to check a few things out first..."
+	echo
+	printf "Checking for Subversion... "
+	svn help >/dev/null 2>&1
+	if [ $? -eq 0 ]; then
+		echo "OK"
+	else
+		printf "\n  ==> ERROR: Subversion is missing.\n"
+		exit 1
+	fi
+
+	printf "Checking for autoconf... "
+	autoconf --help >/dev/null 2>&1
+	if [ $? -eq 0 ]; then
+		echo "OK"
+	else
+		printf "\n  ==> ERROR: autoconf is missing.\n"
+		exit 1
+	fi
+
+	printf "Checking for automake... "
+	automake --help >/dev/null 2>&1
+	if [ $? -eq 0 ]; then
+		echo "OK"
+	else
+		printf "\n  ==> ERROR: automake is missing.\n"
+		exit 1
+	fi
+
+	printf "Checking for gcc... "
+	gcc -v >/dev/null 2>&1
+	if [ $? -eq 0 ]; then
+		echo "OK"
+	else
+		printf "\n  ==> ERROR: gcc is missing.\n"
+		exit 1
+	fi
+
+	printf "Checking for g++... "
+	g++ -v >/dev/null 2>&1
+	if [ $? -eq 0 ]; then
+		echo "OK"
+	else
+		printf "\n  ==> ERROR: g++ is missing.\n"
+		exit 1
+	fi
+
+	printf "Checking for xsltproc... "
+	xsltproc -V >/dev/null 2>&1
+	if [ $? -eq 0 ]; then
+		echo "OK"
+	else
+		printf "\n  ==> ERROR: xsltproc is missing. Please install libxml.\n"
+		exit 1
+	fi
+
+	printf "Checking for LWP::UserAgent... "
+	perl -MLWP::UserAgent -e ''
+	if [ $? -eq 0 ]; then
+		echo "OK"
+	else
+		printf "\n  ==> ERROR: Perl module LWP::UserAgent is missing. Please install libwww.\n"
+		exit 1
+	fi
+
+	printf "Checking if SSH key exists... "
+	test -f $SSH_ID >/dev/null 2>&1
+	if [ $? -eq 0 ]; then
+		echo "OK"
+	else
+		printf "\n  ==> SSH key does not exist. Running ssh-keygen.\n"
+		ssh-keygen -t rsa -f $SSH_ID -N ''
+		echo
+		echo "  ==> SSH key generated. Be sure to have the key uploaded to the build master!"
+	fi
+
+	echo
+	echo "All done! Binaries look fine, but make sure you have headers for the following:"
+	echo " - openssl"
+	echo " - zlib"
+	echo
+	echo "Exiting so you can check this, rather than having failed builds reported."
+	echo "Just re-run `basename $0` when ready."
+
+	touch .minion_env
+	exit
+}
+
+# Func: chk_dist
+# Desc: Attempts to work out which distribution of Linux we're on.
+chk_dist () {
+	if [ -f redhat-release ]; then
+		dist_name=`cat redhat-release | perl -ne '/ release/;print $\`'`
+		dist_ver=`cat redhat-release | perl -ne '/release (\d+(\.\d+)?)/;print $1'`
+		case "$dist_name" in
+			"Red Hat Ent"*)   dist_name="RHEL" ;;
+			"Red Hat Linux"*) dist_name="RHL"  ;;
+		esac
+	elif [ -f /etc/debian_version ]; then
+		dist_name="Debian"
+		dist_ver=`cat /etc/debian_version`
+	elif [ -f /etc/SuSE-release ]; then
+		dist_name="SuSE"
+		dist_ver=`cat /etc/SuSE-release | perl -ne '/VERSION = /;print $\`'`
+		case "$dist_name" in
+			SUSE*Desktop*) dist_name="SLED" ;;
+			SUSE*Server*) dist_name="SLES" ;;
+		esac
+	else
+		# What is this distribution? Tell me if you know!
+		# Default to "Linux" / kernel ver.
+		dist_name=`uname -s`
+		dist_ver=`uname -r`
+	fi
+}
+
+# Func: gen_config
+# Desc: Creates a bitten-slave configuration file (INI format).
+gen_config () {
+	# If we're running a Linux variant, check and change config file name
+	[ x"$build_os" = x"linux" ] && { 
+		chk_dist
+		config="`echo $dist_name | tr [A-Z] [a-z]`.ini"
+	}
+
+	# Back up any existing config before (re-)creating
+	[ -f ${config} ] && mv $config ${config}.old
+	if [ -f ${config}.old ]; then
+		# Copy auth details from the old config
+		echo "[authentication]" > $config
+		grep "username =" ${config}.old >> $config
+		grep "password =" ${config}.old >> $config
+	else
+		cat >>$config <<-END_CONF
+		[authentication]
+		username = changeme
+		password = changeme
+		END_CONF
+	fi
+	cat >>$config <<-END-CONF
+
+	# Un-comment the [machine] section and set name if you want to
+	# hide your hostname.
+	#[machine]
+	#name = myhostname
+	END-CONF
+
+	case $build_os in
+	  linux)
+		cat >>$config <<-END_CONF
+
+		[os]
+		name = $dist_name
+		version = $dist_ver
+		END_CONF
+	  	;;
+	esac
+  	
+	echo "Config generated as $config."
+	echo "Please set Trac user/pass in the [authentication] section."
+	exit
+}
+
+[ x"$1" = x"gen-config" ] && gen_config
+
+case "$build_os" in
+	sunos)
+	  # Export variables needed for GCC on Solaris to avoid using the system
+	  # OpenSSL. Change these to wherever your OpenSSL libs/headers are.
+	  CFLAGS="-I/usr/local/include"
+	  CXXFLAGS="-I/usr/local/include"
+	  LDFLAGS="-L/usr/local/lib"
+	  export CFLAGS CXXFLAGS LDFLAGS
+	  ;;
+esac
+
+[ ! -f .minion_env ] && chk_env
+
+if [ -f "${config}" ]; then
+	bitten-slave -f ${config} -d $WORK_DIR $LOG $* $TRAC_URL
+else
+	echo "Config file missing. Please re-run with gen-config option."
+	exit 1
+fi
+


Property changes on: box/bitten/minion
___________________________________________________________________
Added: svn:executable
   + *




More information about the Boxbackup-commit mailing list