summaryrefslogtreecommitdiff
path: root/tools/version.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/version.sh')
-rwxr-xr-xtools/version.sh46
1 files changed, 9 insertions, 37 deletions
diff --git a/tools/version.sh b/tools/version.sh
index 6d6b6ed13a..1863789917 100755
--- a/tools/version.sh
+++ b/tools/version.sh
@@ -12,40 +12,18 @@
12 12
13# Prints the revision of the repository. 13# Prints the revision of the repository.
14# 14#
15# The format is rNNNNN[M]-YYMMDD 15# The format is rNNNNNNNNNN[M]-YYMMDD
16# 16#
17# The M indicates the revision isn't matched to a pure Subversion ID, usually 17# The M indicates the revision has been locally modified
18# because it's built from something like GIT. 18#
19 19# This logic is pulled from the Linux's scripts/setlocalversion (also GPL)
20svnversion_safe() { 20# and tweaked for rockbox.
21 # LANG=C forces svnversion to not localize "exported".
22 if OUTPUT=`LANG=C svnversion "$@"`; then
23 if [ "$OUTPUT" = "exported" ]; then
24 echo "unknown"
25 else
26 echo "r$OUTPUT"
27 fi
28 else
29 echo "unknown"
30 fi
31}
32
33# This logic is pulled from the Linux's scripts/setlocalversion (also GPL) and tweaked for
34# rockbox. If the commit information for HEAD has a svn-id in it we report that instead of
35# the git id
36gitversion() { 21gitversion() {
37 export GIT_DIR="$1/.git" 22 export GIT_DIR="$1/.git"
38 23
39 # This verifies we are in a git directory 24 # This verifies we are in a git directory
40 if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then 25 if head=`git rev-parse --verify --short=10 HEAD 2>/dev/null`; then
41 26
42 # Get the svn revision of the most recent git-svn commit
43 version=`git log --pretty=format:'%b' --grep='git-svn-id: svn' -1 | tail -n 1 | perl -ne 'm/@(\d*)/; print "r" . $1;'`
44 mod=""
45 # Is this a git-svn commit?
46 if ! git log -1 --pretty=format:"%b" | grep -q "git-svn-id: svn" ; then
47 version="$head"
48 fi
49 # Are there uncommitted changes? 27 # Are there uncommitted changes?
50 export GIT_WORK_TREE="$1" 28 export GIT_WORK_TREE="$1"
51 if git diff --name-only HEAD | read dummy; then 29 if git diff --name-only HEAD | read dummy; then
@@ -54,7 +32,7 @@ gitversion() {
54 mod="M" 32 mod="M"
55 fi 33 fi
56 34
57 echo "${version}${mod}" 35 echo "${head}${mod}"
58 # All done with git 36 # All done with git
59 exit 37 exit
60 fi 38 fi
@@ -69,18 +47,12 @@ if [ -n "$1" ]; then TOP=$1; else TOP=..; fi
69if [ -z $VERSION ]; then 47if [ -z $VERSION ]; then
70 # If the VERSIONFILE exisits we use that 48 # If the VERSIONFILE exisits we use that
71 VERSIONFILE=docs/VERSION 49 VERSIONFILE=docs/VERSION
72 if [ -r $TOP/$VERSIONFILE ]; then VER=`cat $TOP/$VERSIONFILE`; 50 if [ -r $TOP/$VERSIONFILE ]; then
51 VER=`cat $TOP/$VERSIONFILE`;
73 else 52 else
74 # Ok, we need to derive it from the Version Control system 53 # Ok, we need to derive it from the Version Control system
75 if [ -d "$TOP/.git" ]; then 54 if [ -d "$TOP/.git" ]; then
76 VER=`gitversion $TOP` 55 VER=`gitversion $TOP`
77 else
78 VER=`svnversion_safe $TOP`;
79 if [ "$VER" = "unknown" ]; then
80 # try getting it from a subdir to test if perhaps they are symlinked
81 # from the root
82 VER=`svnversion_safe $TOP/tools`;
83 fi
84 fi 56 fi
85 fi 57 fi
86VERSION=$VER-`date -u +%y%m%d` 58VERSION=$VER-`date -u +%y%m%d`