3 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
11 # Usage: version.sh [source-root]
13 # Prints the revision of the repository.
15 # The format is rNNNNN[M]-YYMMDD
17 # The M indicates the revision isn't matched to a pure Subversion ID, usually
18 # because it's built from something like GIT.
21 # LANG=C forces svnversion to not localize "exported".
22 if OUTPUT
=`LANG=C svnversion "$@"`; then
23 if [ "$OUTPUT" = "exported" ]; then
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
39 # This verifies we are in a git directory
40 if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
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 | head -n 1 | perl -ne 'm/@(\d*)/; print "r" . $1;'`
45 # Is this a git-svn commit?
46 if ! git log HEAD^..
--pretty=format
:"%b" |
grep -q "git-svn-id: svn" ; then
50 # Are there uncommitted changes?
51 git update-index
--refresh --unmerged > /dev
/null
52 if git diff-index
--name-only HEAD |
read dummy
; then
56 echo "${version}${mod}"
63 # First locate the top of the src tree (passed in usually)
65 if [ -n "$1" ]; then TOP
=$1; else TOP
=..
; fi
67 # If the VERSIONFILE exisits we use that
68 VERSIONFILE
=docs
/VERSION
69 if [ -r $TOP/$VERSIONFILE ]; then VER
=`cat $TOP/$VERSIONFILE`;
71 # Ok, we need to derive it from the Version Control system
72 if [ -d "$TOP/.git" ]; then
73 VER
=`gitversion $TOP/.git`
75 VER
=`svnversion_safe $TOP`;
76 if [ "$VER" = "unknown" ]; then
77 # try getting it from a subdir to test if perhaps they are symlinked
79 VER
=`svnversion_safe $TOP/tools`;
83 VERSION
=$VER-`date -u +%y%m%d`