abafa8461df43d4c38f6a138313f09e91d77d1e4
[debian/amanda] / config / set_full_version
1 #!/bin/bash
2
3 srcdir=$1
4
5 if test -d .svn; then
6     svn info . > conftemp.svn
7 else
8     echo "" > conftemp.svn
9 fi
10
11 if test -d .svn && ( grep Revision: conftemp.svn > /dev/null; ); then
12 #if grep Revision: conftemp.svn > /dev/null ; then
13     SVN_REV=`grep Revision: conftemp.svn|cut -d: -f 2|cut -c2-`
14     SVN_URL=`grep URL: conftemp.svn|cut -d: -f 2-|cut -c2-`
15     SVN_PATH=`grep URL: conftemp.svn|cut -d "/" -f 7-`
16     SVN_TYPE=`echo ${SVN_PATH} |cut -d "/" -f 1`
17     SVN_BRANCH=`echo "${SVN_PATH}"| cut -d "/" -f 2`
18     url=`grep URL: conftemp.svn|cut -d: -f 2-|cut -c2-`
19 fi
20
21 if test -d .git; then
22     GIT_SHA1=`git rev-parse HEAD | cut -c -8 `
23 fi
24
25 if test -f FULL_VERSION; then
26     FULL_VERSION_FILE="FULL_VERSION"
27     OLD_VERSION=`cat $FULL_VERSION_FILE`
28 else if test -n "$srcdir" -a -f $srcdir/FULL_VERSION; then
29     FULL_VERSION_FILE="$srcdir/FULL_VERSION"
30     OLD_VERSION=`cat $FULL_VERSION_FILE`
31 else
32     FULL_VERSION_FILE="FULL_VERSION"
33     OLD_VERSION=
34 fi
35 fi
36
37 if test -n "$srcdir"; then
38     VERSION_FILE="$srcdir/VERSION"
39 else
40     VERSION_FILE="VERSION"
41 fi
42 VERSION=`cat $VERSION_FILE`
43
44 if test -n "$SVN_REV"; then
45     if test "${SVN_TYPE}" = "branches"; then
46         VERSION=${VERSION}.svn.${SVN_REV}
47     else if test "${SVN_TYPE}" = "trunk"; then
48         VERSION=${VERSION}.svn.${SVN_REV}
49     else
50         RC=`echo "${SVN_BRANCH}"| grep "rc"`
51         if test -n "$RC"; then
52             VERSION=`echo "${SVN_BRANCH}"| sed 's/[^0-9]*// ; s/[_.]//g'`
53             VERSION=`echo ${VERSION}| sed 's/^\([0-9]\)\([0-9]\)\([0-9]\)/\1.\2.\3/'`
54         fi
55     fi
56     fi
57
58 else if test -n "$GIT_SHA1"; then
59     VERSION=${VERSION}".git."${GIT_SHA1}
60
61 else if test -n "$OLD_VERSION"; then
62     VERSION=$OLD_VERSION
63 fi
64 fi
65 fi
66
67 if test "$VERSION" != "$OLD_VERSION" -o $VERSION_FILE -nt FULL_VERSION; then
68     echo "$VERSION" > FULL_VERSION
69 fi
70