Skip to content

Instantly share code, notes, and snippets.

@Spenser309
Created May 15, 2013 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Spenser309/5587802 to your computer and use it in GitHub Desktop.
Save Spenser309/5587802 to your computer and use it in GitHub Desktop.
Script to run a build for submission to an autobuilder.
#!/bin/bash
#
# Submit a build to the autobuilder. This script can be used to start a
# build which will be submitted to the autobuilder.
#
# This script must be run from the buildroot top dir.
TIMEOUT=${TIMEOUT:="2h"}
RESULTDIR=${RESULTDIR:=$(mktemp -d)}
BUILDDIR=${BUILDDIR:="output"}
SUBMITTER=${SUBMITTER:="$(whoami)@$(hostname -f)"}
DEFCONFIG=$1
decho() {
echo "$@" 1>&2
}
usage() {
decho "usage: $0 <defconfig>"
}
if [ "x$1" == "x" ]; then
usage
exit
fi
if [ ! -f configs/${DEFCONFIG}_defconfig ]; then
decho "ERROR: Defconfig for \"${DEFCONFIG}\" does not exist"
exit
fi
GITID=$(git log -n1 | grep commit | sed "s/commit\ //")
if [ -f $(echo "$GITID" | cut -b1-8)-${DEFCONFIG}.tar.gz ]; then
decho "ERROR: Output file already exists"
exit
fi
decho "-----------------------------------------------------"
decho "-- Running autobuild of $DEFCONFIG"
decho "-- Submitter: $SUBMITTER"
decho "-- Timeout: $TIMEOUT"
decho "-- Result Dir: $RESULTDIR"
decho "-- Build Dir: $BUILDDIR"
decho "-- Git ID: $GITID"
cp configs/${DEFCONFIG}_defconfig $RESULTDIR/defconfig
make O=$BUILDDIR ${DEFCONFIG}_defconfig 2>&1 || ( decho "ERROR: Defconfig failed"; exit )
cp $BUILDDIR/.config $RESULTDIR/config
timeout $TIMEOUT make O=$BUILDDIR 2>&1 > build.log
ret=$?
decho "-- Return Code: $ret"
case "$ret" in
"0")
decho "-- Build Status: OK"
echo "OK" > $RESULTDIR/status
;;
"124")
decho "-- Build Status: TIMEOUT"
echo "TIMEOUT" > $RESULTDIR/status
;;
*)
decho "-- Build Status: NOK"
echo "NOK" > $RESULTDIR/status
;;
esac
tail -n 100 build.log > $RESULTDIR/build-end.log
echo "$GITID" > $RESULTDIR/gitid
echo "$SUBMITTER" > $RESULTDIR/submitter
pushd . 2>&1 > /dev/null
cd $RESULTDIR && tar czf $(echo "$GITID" | cut -b1-8)-${DEFCONFIG}.tar.gz *
popd 2>&1 > /dev/null
decho "-- Build Complete"
decho "----------------------------------------------------"
rm -rf $RESULTDIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment