1#!/bin/sh 2 3haikuTop=$1 4revisionFile=$2 5haikuBuildOutputDir=`dirname $revisionFile` 6lastBuiltRevisionFile=${haikuBuildOutputDir}/last-built-revision 7 8case `uname` in 9Darwin) 10 SED=gsed 11 ;; 12*) 13 SED=sed 14 ;; 15esac 16export SED 17 18revision=`cat ${revisionFile} 2>/dev/null` 19lastBuiltRevision=`cat $lastBuiltRevisionFile 2>/dev/null` 20 21originalDir=`pwd` 22cd ${haikuTop} 23export LC_ALL=C 24 25localRev=`git rev-parse HEAD` 26 27# only determine the haiku-revision if anything has changed from the 28# last build 29if [ -z "$revision" -o "$lastBuiltRevision" != "$localRev" ]; then 30 # the revision we use is the description of HEAD with respect to the 31 # last reachable hrev-(haiku-revision-)tag 32 revision=`git describe --dirty --tags --match=hrev* --abbrev=1` 33 if [ -z "$revision" ]; then 34 # failed to find any hrev tags, bail out 35 echo "Error: you are using a Haiku clone without tags, please set" 36 echo " the revision tag to use (e.g. HAIKU_REVISION=hrev43210)" 37 exit 1 38 fi 39 40 revision=`echo $revision | sed 's/-g[0-9a-z]\+//' | sed 's/-/+/g'` 41 if echo "$revision" | grep -- '-' >/dev/null; then 42 # HEAD is not directly a changeset from Haiku's central repo, so we 43 # add the current branch name as additional info 44 branchName=`git branch | grep '*' | cut -b 3-` 45 revision="$revision [$branchName]" 46 fi 47fi 48 49cd $originalDir 50 51if [ -z "$revision" ]; then 52 revision=0 53fi 54 55echo $localRev >${lastBuiltRevisionFile} 56echo $revision >${revisionFile} 57