#!/bin/sh if [ "$1" == '-v' ] then shift VERBOSE=1 fi REPO=$1 if [ -z "$REPO" ] || [ ! -d patchlist ] then echo "No dice" exit 0 fi # svn doesn't give you the diff for the very first patch initializing a # repository. You can fake it by hand via: # for i in `find . -type f | sed 's ^\./ ' | grep -v .svn`; do diff -u /dev/null "$i"; done # Figure out last patch in directory, avoiding shell globbing which can # blow up past what some command lines can handle. Don't put anything in # the directory that shows up after "svn" alphabetically. last=$(ls patchlist | sort -t- -k2,2n | sed -n '$s/svn-\([0-9]*\)\.patch/\1/p') # Check if repository has changed. Don't ask me why "log -r HEAD" takes 1/3 # the time of "info", I don't know. head=$(svn info svn+ssh://busybox.net/svn/trunk/busybox | sed -n 's/Revision: //p') echo head $head last $last if [ -z "$head" ] || [ "$last" == "$head" ] then [ ! -z "$VERBOSE" ] && echo Up to date. exit 0 fi [ ! -z "$VERBOSE" ] && echo Updating... svn log -v "$REPO" -r HEAD:$[${last:=1}+1] > patchlist/.changelog.new # Create new changelog, in background. rm -f patchlist/trigger ((for i in `find patchlist -name "svn-*.patch" | sort -t- -k2,2nr`; do sed -n -e '2,/^ ----------*/{p}' $i; done) | gzip > patchlist/changelog.txt.gz; touch patchlist/trigger)& for i in $(cat patchlist/.changelog.new | sed -n -e 's/^r\([0-9]*\) | .*/\1/p' | sort -n) do [ ! -z "$VERBOSE" ] && echo " $i" svn log -v -r $i "$REPO" | sed -e 's/^-----*$/ \0/' | \ tee patchlist/svn-$i.patch | ([ ! -z "$VERBOSE" ] && cat) svn diff -r$[$i-1]:$i "$REPO" >> patchlist/svn-$i.patch touch patchlist/svn-$i.patch -d "$(cat patchlist/svn-$i.patch | head -n 2 | tail -n 1 | awk '{print $5" "$6}')" done [ ! -z "$VERBOSE" ] && echo Collating. # Create recent.html ( echo "
"
for i in `ls patchlist | sort -t- -k 2,2nr | head -n 100`
do
  echo ""
  sed -e '1,2b' -e '/^ -----*$/a ' patchlist/$i
done
echo "
" ) > patchlist/recent.html echo Waiting for changelog.txt.gz to finish... while /bin/true do rm patchlist/trigger 2> /dev/null && break sleep 1 done rm patchlist/.changelog.new # Tar it all up find patchlist -name "svn-*.patch" | sort -t- -k 2,2n | tar -T- -c -z -f patchlist/patchlist.tgz # Actually did something. exit 1