2011-05-16 02:45:43 +04:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
determineGitRevision()
|
|
|
|
{
|
2011-05-16 20:11:42 +04:00
|
|
|
haikuTop=$1
|
|
|
|
haikuBuildOutputDir=$2
|
|
|
|
|
|
|
|
revision=`cat ${haikuBuildOutputDir}/haiku-revision 2>/dev/null`
|
|
|
|
lastBuiltRevision=`cat ${haikuBuildOutputDir}/last-built-revision \
|
2011-05-16 02:45:43 +04:00
|
|
|
2>/dev/null`
|
|
|
|
localRev=`git rev-list -n1 HEAD`
|
|
|
|
|
|
|
|
# only determine the haiku-revision if anything has changed from
|
|
|
|
# last build
|
|
|
|
if [ -z "$revision" -o "$lastBuiltRevision" != "$localRev" ]; then
|
2011-06-06 22:20:38 +04:00
|
|
|
# the revision we use is the description of HEAD with respect to the
|
|
|
|
# last reachable hrev-(haiku-revision-)tag
|
|
|
|
revision=`git describe --dirty --tags --match=hrev*`
|
|
|
|
if echo "$revision" | grep -- '-' >/dev/null; then
|
|
|
|
# HEAD is not directly a changeset from Haiku's central repo, so we
|
|
|
|
# add the current branch name as additional info
|
|
|
|
branchName=`git branch | grep '*' | cut -b 3-`
|
|
|
|
revision="$revision [$branchName]"
|
2011-05-16 02:45:43 +04:00
|
|
|
fi
|
2011-05-16 20:11:42 +04:00
|
|
|
echo $localRev >${haikuBuildOutputDir}/last-built-revision
|
2011-05-16 02:45:43 +04:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-16 20:11:42 +04:00
|
|
|
determineHaikuRevision()
|
|
|
|
{
|
|
|
|
haikuTop=$1
|
|
|
|
haikuBuildOutputDir=$2
|
|
|
|
|
2011-05-25 01:14:41 +04:00
|
|
|
case `uname` in
|
2011-05-24 23:23:56 +04:00
|
|
|
Darwin)
|
|
|
|
SED=gsed
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
SED=sed
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
export SED
|
|
|
|
|
2011-05-16 20:11:42 +04:00
|
|
|
originalDir=`pwd`
|
|
|
|
cd ${haikuTop}
|
|
|
|
export LC_ALL=C
|
|
|
|
if [ -d .svn ]; then
|
|
|
|
revision=`svn info 2>/dev/null | grep Revision | awk '{printf $2}'`
|
|
|
|
elif [ -d .git/svn ]; then
|
|
|
|
revision=`git svn info 2>/dev/null | grep Revision | awk '{printf $2}'`
|
|
|
|
elif [ -d .git ]; then
|
|
|
|
determineGitRevision $haikuTop $haikuBuildOutputDir
|
|
|
|
elif [ -d .hg ]; then
|
|
|
|
# Try searching hg log for last svn commit
|
|
|
|
# Extract from "(svn r12345) ..." line
|
|
|
|
revision=`(cd ${haikuTop} &&
|
|
|
|
hg log --no-merges --template "{desc|firstline}\n") 2> /dev/null |
|
|
|
|
grep --max-count=1 "(svn r" |
|
2011-05-24 23:23:56 +04:00
|
|
|
$SED -n -e 's,(svn r\(.*\)).*,\1,p'`
|
2011-05-16 20:11:42 +04:00
|
|
|
fi
|
|
|
|
if [ "$revision" = "" ]; then
|
|
|
|
revision=0
|
|
|
|
fi
|
|
|
|
echo $revision >${haikuBuildOutputDir}/haiku-revision
|
|
|
|
cd $originalDir
|
|
|
|
}
|