2009-01-19 16:18:30 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# __________ __ ___.
|
|
|
|
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
# \/ \/ \/ \/ \/
|
|
|
|
# $Id$
|
|
|
|
#
|
|
|
|
|
|
|
|
# Usage: version.sh [source-root]
|
|
|
|
|
|
|
|
# Prints the revision of the repository.
|
|
|
|
#
|
2020-07-10 00:27:50 +00:00
|
|
|
# The format is rNNNNNNNNNN[M]-YYMMDD
|
2009-01-19 16:18:30 +00:00
|
|
|
#
|
2020-07-10 00:27:50 +00:00
|
|
|
# The M indicates the revision has been locally modified
|
|
|
|
#
|
|
|
|
# This logic is pulled from the Linux's scripts/setlocalversion (also GPL)
|
|
|
|
# and tweaked for rockbox.
|
2009-01-19 16:18:30 +00:00
|
|
|
gitversion() {
|
2009-05-15 01:14:48 +00:00
|
|
|
export GIT_DIR="$1/.git"
|
2009-01-19 16:18:30 +00:00
|
|
|
|
|
|
|
# This verifies we are in a git directory
|
2020-07-10 00:27:50 +00:00
|
|
|
if head=`git rev-parse --verify --short=10 HEAD 2>/dev/null`; then
|
2009-01-19 16:18:30 +00:00
|
|
|
|
|
|
|
# Are there uncommitted changes?
|
2011-05-06 08:36:10 +00:00
|
|
|
export GIT_WORK_TREE="$1"
|
|
|
|
if git diff --name-only HEAD | read dummy; then
|
|
|
|
mod="M"
|
|
|
|
elif git diff --name-only --cached HEAD | read dummy; then
|
|
|
|
mod="M"
|
2009-01-19 16:18:30 +00:00
|
|
|
fi
|
|
|
|
|
2020-07-10 00:27:50 +00:00
|
|
|
echo "${head}${mod}"
|
2009-01-19 16:18:30 +00:00
|
|
|
# All done with git
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# First locate the top of the src tree (passed in usually)
|
|
|
|
#
|
|
|
|
if [ -n "$1" ]; then TOP=$1; else TOP=..; fi
|
|
|
|
|
2010-10-31 21:52:48 +00:00
|
|
|
# setting VERSION var on commandline has precedence
|
|
|
|
if [ -z $VERSION ]; then
|
|
|
|
# If the VERSIONFILE exisits we use that
|
|
|
|
VERSIONFILE=docs/VERSION
|
2020-07-10 00:27:50 +00:00
|
|
|
if [ -r $TOP/$VERSIONFILE ]; then
|
|
|
|
VER=`cat $TOP/$VERSIONFILE`;
|
2009-01-19 16:18:30 +00:00
|
|
|
else
|
2010-10-31 21:52:48 +00:00
|
|
|
# Ok, we need to derive it from the Version Control system
|
|
|
|
if [ -d "$TOP/.git" ]; then
|
|
|
|
VER=`gitversion $TOP`
|
|
|
|
fi
|
2009-01-19 16:18:30 +00:00
|
|
|
fi
|
|
|
|
VERSION=$VER-`date -u +%y%m%d`
|
2010-10-31 21:52:48 +00:00
|
|
|
fi
|
2009-01-19 16:18:30 +00:00
|
|
|
echo $VERSION
|
|
|
|
|