2007-02-20 23:01:25 +00:00
|
|
|
#!/bin/sh
|
2007-01-22 23:09:07 +00:00
|
|
|
# __________ __ ___.
|
|
|
|
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
# \/ \/ \/ \/ \/
|
2007-02-20 23:01:25 +00:00
|
|
|
# $Id$
|
2007-01-22 23:09:07 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
# Usage: svnversion.sh [source-root]
|
|
|
|
|
2007-09-11 05:10:42 +00:00
|
|
|
# Prints the revision "rXYZ" of the first argument, as reported by svnversion.
|
|
|
|
# Prints "unknown" if svnversion fails or says "exported".
|
|
|
|
svnversion_safe() {
|
|
|
|
# LANG=C forces svnversion to not localize "exported".
|
|
|
|
if OUTPUT=`LANG=C svnversion "$@"`; then
|
|
|
|
if [ "$OUTPUT" = "exported" ]; then
|
2008-11-04 03:05:46 +00:00
|
|
|
|
|
|
|
# Not a SVN repository, maybe a git-svn one ?
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
GITDIR="./.git"
|
|
|
|
else
|
|
|
|
GITDIR="$1/.git"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# First make sure it is a git repository
|
|
|
|
if [ -d "$GITDIR" ]; then
|
|
|
|
OUTPUT=`LANG=C git --git-dir="$GITDIR" svn info 2>/dev/null|grep '^Revision: '|cut -d\ -f2`
|
|
|
|
if [ -z "$OUTPUT" ]; then
|
|
|
|
echo "unknown"
|
|
|
|
else
|
|
|
|
echo "r$OUTPUT"
|
|
|
|
fi
|
|
|
|
else # not a git repository
|
|
|
|
echo "unknown"
|
|
|
|
fi
|
2007-09-11 05:10:42 +00:00
|
|
|
else
|
|
|
|
echo "r$OUTPUT"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "unknown"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2007-01-22 23:09:07 +00:00
|
|
|
VERSIONFILE=docs/VERSION
|
|
|
|
if [ -n "$1" ]; then TOP=$1; else TOP=..; fi
|
|
|
|
if [ -r $TOP/$VERSIONFILE ]; then SVNVER=`cat $TOP/$VERSIONFILE`;
|
2007-09-11 05:10:42 +00:00
|
|
|
else
|
|
|
|
SVNVER=`svnversion_safe $TOP`;
|
|
|
|
if [ "$SVNVER" = "unknown" ]; then
|
2007-01-25 11:39:30 +00:00
|
|
|
# try getting it from a subdir to test if perhaps they are symlinked
|
|
|
|
# from the root
|
2007-09-11 05:10:42 +00:00
|
|
|
SVNVER=`svnversion_safe $TOP/tools`;
|
2007-01-22 23:09:07 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
VERSION=$SVNVER-`date -u +%y%m%d`
|
|
|
|
echo $VERSION
|
|
|
|
|