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 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*` 33 if [ -z "$revision" ]; then 34 # failed to find any hrev tags, use short hash instead 35 revision=`git rev-parse --short HEAD` 36 elif echo "$revision" | grep -- '-' >/dev/null; then 37 # HEAD is not directly a changeset from Haiku's central repo, so we 38 # add the current branch name as additional info 39 branchName=`git branch | grep '*' | cut -b 3-` 40 revision="$revision [$branchName]" 41 fi 42fi 43 44cd $originalDir 45 46if [ -z "$revision" ]; then 47 revision=0 48fi 49 50echo $localRev >${lastBuiltRevisionFile} 51echo $revision >${revisionFile} 52