Skip to content

Instantly share code, notes, and snippets.

@ph1ee
Created June 16, 2015 02:39
Show Gist options
  • Save ph1ee/0e72209faeb1f4616e2f to your computer and use it in GitHub Desktop.
Save ph1ee/0e72209faeb1f4616e2f to your computer and use it in GitHub Desktop.
Firmware daily build helper script
#!/bin/bash
USERNAME=username
PASSWORD=password
REPO="svn://192.168.0.30/svn/trunk"
FW="project"
OUTDIR=$HOME/build.fw
BUILDLOG=buildlog
BUILTLST=builtlst
AUTH="--no-auth-cache --non-interactive --username $USERNAME --password $PASSWORD"
RANGE={$(date --date="yesterday" --iso-8601=minutes)}:{$(date --date="today" --iso-8601=minutes)}
############################################################
mkdir -p "$OUTDIR"
declare -A builtlst
for n in $(cat "$OUTDIR/$BUILTLST" 2>/dev/null); do
builtlst[$n]=1
done
############################################################
for fw in $FW
do
tmpfile=$(mktemp)
num=$(svn log $AUTH --stop-on-copy --xml -r $RANGE "$REPO/$fw" | tee $tmpfile | xmllint -xpath "count(/log/logentry)" -)
for ((i=0; i < $num; i++))
do
rev=$(xmllint -xpath "number(/log/logentry[$((i+1))]/@revision)" $tmpfile)
name=$(basename "$REPO/$fw")-r$rev
wc="$OUTDIR/$name"
# checkout & build
if [[ ! -d "$wc" && ! ${builtlst[$name]} ]]; then
svn checkout $AUTH --revision "$rev" "$REPO/$fw" "$wc"
# build
build_date=$(date +%Y%m%d%H%M%S)
(cd "$wc" && make all 2>&1 | tee "$BUILDLOG") && chmod -R -w "$wc"
echo "$name" >> "$OUTDIR/$BUILTLST"
fi
done
rm -f $tmpfile
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment