summaryrefslogtreecommitdiff
path: root/tools/svnversion.sh
blob: f30d4193ebebe50529664cc02290336570eb44c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh
#             __________               __   ___.
#   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
#   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
#   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
#   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
#                     \/            \/     \/    \/            \/
# $Id$
#

# Usage: svnversion.sh [source-root]

VERSIONFILE=docs/VERSION
if [ -n "$1" ]; then TOP=$1; else TOP=..; fi
if [ -r $TOP/$VERSIONFILE ]; then SVNVER=`cat $TOP/$VERSIONFILE`; 
else if [ `which svnversion 2>/dev/null` ]; then 
    SVNALT=`svnversion $1`;
    if [ "$SVNALT" = "exported" ]; then 
        # try getting it from a subdir to test if perhaps they are symlinked
        # from the root
        SVNALT=`svnversion $1/tools`
        if [ "$SVNALT" != exported ]; then
            # yeah, it is there so we use this
            SVNVER="r$SVNALT"
        else
            SVNALT="unknown";
        fi
    else
        SVNVER="r$SVNALT";
    fi
else SVNVER="unknown"; fi
fi
VERSION=$SVNVER-`date -u +%y%m%d`
echo $VERSION