IP4/IP6 FIB: fix crash during interface delete
[vpp.git] / src / scripts / version
1 #!/bin/bash
2
3 path=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P )
4
5 cd "$path"
6
7 if [ -f .version ]; then
8     vstring=$(cat .version)
9 else
10     vstring=$(git describe)
11     if [ $? != 0 ]; then
12       exit 1
13     fi
14 fi
15
16 TAG=$(echo ${vstring} | cut -d- -f1 | sed -e 's/^v//')
17 ADD=$(echo ${vstring} | cut -s -d- -f2)
18
19 git rev-parse 2> /dev/null
20 if [ $? == 0 ]; then
21     CMT=$(git describe --dirty --match 'v*'| cut -s -d- -f3,4)
22 else
23     CMT=$(echo ${vstring} | cut -s -d- -f3,4)
24 fi
25 CMTR=$(echo $CMT | sed 's/-/_/')
26
27 if [ -n "${BUILD_NUMBER}" ]; then
28        BLD="~b${BUILD_NUMBER}"
29 fi
30
31 if [ "$1" = "rpm-version" ]; then
32   echo ${TAG}
33   exit
34 fi
35
36 if [ "$1" = "rpm-release" ]; then
37   [ -z "${ADD}" ] && echo release && exit
38   echo ${ADD}${CMTR:+~${CMTR}}${BLD}
39   exit
40 fi
41
42   if [ -n "${ADD}" ]; then
43     if [ "$1" = "rpm-string" ]; then
44       echo ${TAG}-${ADD}${CMTR:+~${CMTR}}${BLD}
45     else
46       echo ${TAG}-${ADD}${CMT:+~${CMT}}${BLD}
47     fi
48   else
49     echo ${TAG}-release
50 fi