libroot/posix/stdio: Remove unused portions.
[haiku.git] / build / scripts / determine_haiku_revision
blob0796c8c2e0fd3e38d486bd0f63348c6d94c15bc4
1 #!/bin/sh
3 haikuTop=$1
4 revisionFile=$2
5 haikuBuildOutputDir=`dirname $revisionFile`
6 lastBuiltRevisionFile=${haikuBuildOutputDir}/last-built-revision
8 case `uname` in
9 Darwin)
10 SED=gsed
13 SED=sed
15 esac
16 export SED
18 revision=`cat ${revisionFile} 2>/dev/null`
19 lastBuiltRevision=`cat $lastBuiltRevisionFile 2>/dev/null`
21 originalDir=`pwd`
22 cd ${haikuTop}
23 export LC_ALL=C
25 localRev=`git rev-parse HEAD`
27 # only determine the haiku-revision if anything has changed from
28 # last build
29 if [ -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, 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 elif echo "$revision" | grep -- '-' >/dev/null; then
39 # HEAD is not directly a changeset from Haiku's central repo, so we
40 # add the current branch name as additional info
41 branchName=`git branch | grep '*' | cut -b 3-`
42 revision="$revision [$branchName]"
46 cd $originalDir
48 if [ -z "$revision" ]; then
49 revision=0
52 echo $localRev >${lastBuiltRevisionFile}
53 echo $revision >${revisionFile}