-
Notifications
You must be signed in to change notification settings - Fork 14
/
version.mgr
executable file
·78 lines (67 loc) · 2.08 KB
/
version.mgr
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#! /bin/sh
#########################################################################
#
# version.mgr
#
# (C) Copyright 1993-99. Dpto Ingenieria Sistemas Telematicos UPM Spain
# Dec 31, 1999 Transfered to Agora Systems S.A.
# (C) Copyright 2000-2011. Agora Systems S.A.
#
# Description
#
# This script implement methods to update files containing version numbers.
#
#########################################################################
VersionMgr(){
if [ "$1" = "-h" ] ; then
echo "$0 help:"
echo "Usage: $0 <method> <version_filename>"
echo "Methods:"
echo " newMayor: increments mayor version number."
echo " newMinor: increments minor version number."
echo " newRelease: increments release number."
echo " getVersion: returns a version number string."
echo " getRelease: returns a release string."
exit 1
fi
if [ "$#" -lt 2 ] ; then
echo "Usage: $0 <method> <version_filename>"
exit 1
fi
local method=$1
local versionfile=$2
if [ ! -f $versionfile ] ; then
echo "ERROR: \"$versionfile\" not found."
exit 1
fi
local mayorvernum=$(awk '{print $1}' $versionfile) # mayor version number.
local minorvernum=$(awk '{print $2}' $versionfile) # minor version number.
local releasenum=$(awk '{print $3}' $versionfile) # release number.
case "$method" in
"newMayor")
mayorvernum=$(($mayorvernum+1))
minorvernum=0
releasenum=0
echo "$mayorvernum $minorvernum $releasenum" > $versionfile
;;
"newMinor")
minorvernum=$(($minorvernum+1))
releasenum=0
echo "$mayorvernum $minorvernum $releasenum" > $versionfile
;;
"newRelease")
releasenum=$(($releasenum+1))
echo "$mayorvernum $minorvernum $releasenum" > $versionfile
;;
"getVersion")
echo "$mayorvernum.$minorvernum"
;;
"getRelease")
echo "$releasenum"
;;
*)
echo "ERROR: $method is an invalid method."
exit 1
esac
}
VersionMgr $*