Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 70 lines (56 sloc) 1.52 KB
#!/bin/sh
set -e
gethash() {
git log -n1 --pretty="format:%H"
}
mydir="$(dirname "$0")"
[ -z "$mydir" ] && mydir="."
cd $mydir
mydir="$(pwd)"
if [ "$#" -lt 1 ]; then
echo "Usage: $0 <config1> [<config2> [<config3> ...]]" >&2
echo "Configuration files are relative to the script" >&2
fi
mkdir -p status
for conf in "$@"; do
log=$(tempfile)
trap "rm $log" 0
exec > "$log" 2>&1
. "$conf"
if ! [ -e "$BUILD" ]; then
git clone "$REPOURL" "$BUILD"
fi
if ! [ -d "$BUILD/.git" ]; then
echo "$BUILD exists but does not appear to be a git repository. exiting." >&2
exit 1
fi
hashfile=status/"$(basename "$conf")" # may collide
lasthash="$(cat "$hashfile" || true)"
cd "$BUILD"
git checkout "$BRANCH"
git pull --ff-only
thishash=$(gethash)
if [ "$lasthash" != "$thishash" ]; then
echo "============= git log follows ============="
echo
git log "${lasthash}..${thishash}"
echo
echo "============================================"
echo "Building $conf..."
echo "$thishash" > "$mydir/$hashfile"
if make; then
(
cd "$mydir"
echo "Uploading $conf..."
for outfile in $OUTFILES; do
echo "==> $outfile"
sh -c "$UPLOAD" "$outfile"
done
echo "Everything done"
)
else
echo "Build failed"
fi
mail -s "$MAIL_SUBJ" "$MAIL_TO" < "$log"
fi
done
Something went wrong with that request. Please try again.