| 1 |
#!/bin/bash |
| 2 |
# |
| 3 |
# This script is run by autogen to create the FULL_VERSION file. |
| 4 |
# |
| 5 |
# If run from a git branch, it append '.git.' + git sha1 to the VERSION file. |
| 6 |
# If run from a svn branch, it append '.svn.' + svn number to the VERSION file. |
| 7 |
# If run from a svn tag that match /rc/ it use only the tag name to set the |
| 8 |
# VERSION, this is done specifically for zmanda rc build. |
| 9 |
# If run from a svn tag that doesn't match /rc/ it use only the VERSION file. |
| 10 |
# |
| 11 |
# It is important to update the VERSION file before creating a tag. |
| 12 |
# |
| 13 |
# ./autogen run config/set_full_version, it create the FULL_VERSION file. |
| 14 |
# ./configure use the FULL_VERSION file. |
| 15 |
# |
| 16 |
srcdir=$1 |
| 17 |
|
| 18 |
if test -d .svn; then |
| 19 |
svn info . > conftemp.svn |
| 20 |
else |
| 21 |
echo "" > conftemp.svn |
| 22 |
fi |
| 23 |
|
| 24 |
if test -d .svn && ( grep Revision: conftemp.svn > /dev/null; ); then |
| 25 |
#if grep Revision: conftemp.svn > /dev/null ; then |
| 26 |
SVN_REV=`grep Revision: conftemp.svn|cut -d: -f 2|cut -c2-` |
| 27 |
SVN_URL=`grep URL: conftemp.svn|cut -d: -f 2-|cut -c2-` |
| 28 |
SVN_PATH=`grep URL: conftemp.svn|cut -d "/" -f 8-` |
| 29 |
SVN_TYPE=`echo ${SVN_PATH} |cut -d "/" -f 1` |
| 30 |
SVN_BRANCH=`echo "${SVN_PATH}"| cut -d "/" -f 2` |
| 31 |
url=`grep URL: conftemp.svn|cut -d: -f 2-|cut -c2-` |
| 32 |
fi |
| 33 |
|
| 34 |
if test -d .git; then |
| 35 |
GIT_SHA1=`git rev-parse HEAD | cut -c -8 ` |
| 36 |
fi |
| 37 |
|
| 38 |
if test -f FULL_VERSION; then |
| 39 |
FULL_VERSION_FILE="FULL_VERSION" |
| 40 |
OLD_VERSION=`cat $FULL_VERSION_FILE` |
| 41 |
else if test -n "$srcdir" -a -f $srcdir/FULL_VERSION; then |
| 42 |
FULL_VERSION_FILE="$srcdir/FULL_VERSION" |
| 43 |
OLD_VERSION=`cat $FULL_VERSION_FILE` |
| 44 |
else |
| 45 |
FULL_VERSION_FILE="FULL_VERSION" |
| 46 |
OLD_VERSION= |
| 47 |
fi |
| 48 |
fi |
| 49 |
|
| 50 |
if test -n "$srcdir"; then |
| 51 |
VERSION_FILE="$srcdir/VERSION" |
| 52 |
else |
| 53 |
VERSION_FILE="VERSION" |
| 54 |
fi |
| 55 |
VERSION=`cat $VERSION_FILE` |
| 56 |
|
| 57 |
if test -n "$SVN_REV"; then |
| 58 |
if test "${SVN_TYPE}" = "branches"; then |
| 59 |
VERSION=${VERSION}.svn.${SVN_REV} |
| 60 |
else if test "${SVN_TYPE}" = "trunk"; then |
| 61 |
VERSION=${VERSION}.svn.${SVN_REV} |
| 62 |
else |
| 63 |
RC=`echo "${SVN_BRANCH}"| grep "rc"` |
| 64 |
if test -n "$RC"; then |
| 65 |
VERSION=`echo "${SVN_BRANCH}"| sed 's/[^0-9]*// ; s/[_.]//g'` |
| 66 |
VERSION=`echo ${VERSION}| sed 's/^\([0-9]\)\([0-9]\)\([0-9]\)/\1.\2.\3/'` |
| 67 |
fi |
| 68 |
fi |
| 69 |
fi |
| 70 |
|
| 71 |
else if test -n "$GIT_SHA1"; then |
| 72 |
VERSION=${VERSION}".git."${GIT_SHA1} |
| 73 |
|
| 74 |
else if test -n "$OLD_VERSION"; then |
| 75 |
VERSION=$OLD_VERSION |
| 76 |
fi |
| 77 |
fi |
| 78 |
fi |
| 79 |
|
| 80 |
if test "$VERSION" != "$OLD_VERSION" -o $VERSION_FILE -nt FULL_VERSION; then |
| 81 |
echo "$VERSION" > FULL_VERSION |
| 82 |
fi |
| 83 |
|