I was asked on the BXE mailinglist, how we do the ā€œautomatic Buildā€ update for showing the latest revision number in the Splash Box. So, here it comes:

What we basically do is calculating an MD5 sum over all files (in our case JS files only) each night, compare that with the md5sum from last night and if it's different, we change our build date string in the corresponding file. Then we commit it to our subversion repository, do an md5-sum again (the content changed, because Subversion adds a new revision number) and then start the snapshots-making process

#!/bin/bash
cd /path/to/sources
svn up
OLD='md5sum div/jsfiles | cut -d " " -f 1'
mv div/jsfiles div/jsfiles.old
for i in 'find . -name "*.js" ' ; do
  md5sum $i >> div/jsfiles;
done
NEW='md5sum div/jsfiles| cut -d " " -f 1'
if test $NEW != $OLD then
  bash div/updateBuildDate.sh
  svn ci -m"automatic BuildDate Update" bxeLoader.js
  rm div/jsfiles
  for i in 'find . -name "*.js"' ; do
    md5sum $i >> div/jsfiles;
  done
  bash makeSnapshots.sh
fi

updateBuildDate.sh just looks vor the BXE_BUILD variable in bxeLoader and replaces this line with the new ā€œbuildā€ date.

date='date +%Y%m%d%H%M';
sed -e "s/var BXE_BUILD = .*/var BXE_BUILD = 
  "$date"/" bxeLoader.js > bxeLoader.js.new ;
mv bxeLoader.js.new bxeLoader.js

And the corresponding lines in bxeLoader.js are the following:

var BXE_VERSION = "1.1.0-dev";
var BXE_BUILD = "200411250330"
var BXE_REVISION =
  "$Rev: 940 $".replace(/$Rev: ([0-9]+) $/,"r$1");

Now I can just use BXE_REVISION in the splash/about box to display the latest revision number of the whole project and the date it was ā€œbuildā€. ($Rev: 940 $ is automatically replaced by Subversion if you set the right property, see the Subversion Book for details). In the above case, this would be ā€œ1.1.0-dev/2004112550330/r940ā€ and users can quickly tell me, which exact version they are using, which is very useful for debugging.

As we only start this script once a day, changes made during the day are not reflected in BXE_REVISION. Therefore, you have to either start it by hand, start it more often with a cron job (as it only changes the sources if something changed, this wouldn't clutter up your SVN logs) or just live with it ;)