-
Notifications
You must be signed in to change notification settings - Fork 21
/
incremente-versions
executable file
·244 lines (228 loc) · 7.17 KB
/
incremente-versions
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#!/bin/csh -f
# Copyright(c)'1994-2011 by The Givaro group
# This file is part of Givaro.
# Givaro is governed by the CeCILL-B license under French law
# and abiding by the rules of distribution of free software.
# see the COPYRIGHT file for more details.
set conf = configure.ac
set mak = src/Makefile.am
set ver = src/kernel/system/givconfig.h
set mkf = Makefile.am
#verbatim second argument of AC_INIT
set verb = `grep ^AC_INIT $conf | cut -d',' -f2`
#removes spaces and brackets
set vern = `echo "$verb" | sed 's/ //g;s/\[//;s/\]//'`
echo "Current version is $vern."
###################################
## INCREMENT THE LIBRARY VERSION ##
###################################
echo -n "Increment library version ? (y/n)"
set answ = $<
if ("$answ" == "y") then
#gets the line
set line = `grep -n ^AC_INIT $conf | cut -d':' -f1`
#a version number is macro.minor.micro
set macro = `echo "$vern" | cut -d'.' -f1`
set minor = `echo "$vern" | cut -d'.' -f2`
set micro = `echo "$vern" | cut -d'.' -f3`
#make temp files for sed
set tmpfile = `mktemp`
set sedfile = `mktemp`
#increment the revision numbers.
set pmicro = `echo $micro`
@ pmicro ++
set pminor = `echo $minor`
@ pminor ++
set pmacro = `echo $macro`
@ pmacro ++
# talk to the user. This choice is very important here
echo "Increment micro revision number ($vern -> $macro.$minor.$pmicro) ? press '0' "
echo "Increment minor revision number ($vern -> $macro.$pminor.0) ? press '1' "
echo -n "Increment macro revision number ($vern -> $pmacro.0.0) ? press '2' "
set increm = $<
switch ($increm)
case 0:
set newv = "[$macro.$minor.$pmicro]"
breaksw
case 1:
set newv = "[$macro.$pminor.0]"
breaksw
case 2:
set newv = "[$pmacro.0.0]"
breaksw
default:
set newv = "$verb"
echo "'$increm' was read. Not incrementing anything."
breaksw
endsw
# replacing [ ] and . with escaped version for sed would understand them as 'operators'.
# This line is important when the used left spaces or removed [].
echo "$line s/$verb/$newv/" | sed 's/\./\\\./g;s/\[/\\\[/g;s/\]/\\\]/g' > $sedfile
sed -f $sedfile $conf > $tmpfile
# clean up
\rm -f $sedfile
# diff for changes
diff -u0 $conf $tmpfile
# if something was changed, confirm incrementation :
# if not confirm, we restore and abort.
if ("$newv" != "$verb") then
echo -n "Confirmation of incrementation ? (yes/no)"
set answ = $<
set backupconf = $conf.back$$
if ("$answ" == "yes") then
\cp -p $conf $backupconf
echo "Back-up of $conf made in $backupconf. Now overwriting $conf."
\mv -f $tmpfile $conf
else
echo "'$answ' was read. Not incrementing anything."
\rm -f $tmpfile
exit 0
endif
#####################################
## INCREMENT THE GIVCONFIG VERSION ##
#####################################
echo -n "Incrementing givconfig revision accordingly."
set backupver = $ver.back$$
set tmpfile = `mktemp`
set sedfile = `mktemp`
switch ($increm)
case 0:
echo "s/GIVARO_REVISION_VERSION.*/GIVARO_REVISION_VERSION $pmicro/" > $sedfile
set decimalversion = `expr \( $macro \* 100 + $minor \) \* 100 + $pmicro`
breaksw
case 1:
echo "s/GIVARO_MINOR_VERSION.*/GIVARO_MINOR_VERSION $pminor/" > $sedfile
echo "s/GIVARO_REVISION_VERSION.*/GIVARO_REVISION_VERSION 0/" >> $sedfile
set decimalversion = `expr \( $macro \* 100 + $pminor \) \* 100`
breaksw
case 2:
echo "s/GIVARO_MAJOR_VERSION.*/GIVARO_MAJOR_VERSION $pmacro/" > $sedfile
echo "s/GIVARO_REVISION_VERSION.*/GIVARO_REVISION_VERSION 0/" >> $sedfile
echo "s/GIVARO_MINOR_VERSION.*/GIVARO_MINOR_VERSION 0/" >> $sedfile
set decimalversion = `expr $pmacro \* 10000`
breaksw
default:
echo "Something abnormal happened"
exit 1
breaksw
endsw
echo "s/GIVARO_VERSION.*/GIVARO_VERSION $decimalversion/" >> $sedfile
sed -f $sedfile $ver > $tmpfile
\rm -f $sedfile
diff -u0 $ver $tmpfile
echo -n "Confirmation of incrementation ? (yes/no) "
set answ = $<
if ("$answ" == "yes") then
\cp -p $ver $backupver
\mv -f $tmpfile $ver
else
echo "'$answ' was read. Not incrementing anything."
echo " your old $conf is restored..."
\rm -f $tmpfile
\mv -f $backupconf $conf
exit 0
endif
#####################################
## INCREMENT THE MAKEFILE VERSION ##
#####################################
echo "Incrementing Makefile.am version."
set tmpfile = `mktemp` #tempfile
set sedfile = `mktemp` #tempfile
switch ($increm)
case 0:
echo -n "s/VERSION.*/VERSION=$macro.$minor.$pmicro/" >> $sedfile
breaksw
case 1:
echo "s/VERSION.*/VERSION=$macro.$pminor.0/" > $sedfile
breaksw
case 2:
echo "s/VERSION.*/VERSION=$pmacro.0.0/" > $sedfile
breaksw
default:
echo "Something abnormal happened"
exit 1
breaksw
endsw
sed -f $sedfile $mkf > $tmpfile
\rm -f $sedfile
diff -u0 $mkf $tmpfile
echo -n "Confirmation of incrementation ? (yes/no) "
set backupmkf = $mkf.back$$
set answ = $<
if ("$answ" == "yes") then
\cp -p $mkf $backupmkf
\mv -f $tmpfile $mkf
else
echo "'$answ' read. Not incrementing anything."
echo " your old $conf and $ver are restored..."
\rm -f $tmpfile
\mv -f $backupconf $conf
\mv -f $backupver $ver
exit 0
endif
##################################
## INCREMENT THE SONAME VERSION ##
##################################
echo "Incrementing soname version now."
set backupmake = $mak.back$$
set infostring = `grep "libgivaro_la_LDFLAGS.*version-info" $mak | awk '{print $NF}'`
set cur = `echo $infostring | cut -d':' -f1`
set rev = `echo $infostring | cut -d':' -f2`
set age = `echo $infostring | cut -d':' -f3`
set pcur = `echo $cur`
@ pcur ++
set prev = `echo $rev`
@ prev ++
set page = `echo $age`
@ page ++
set tmpfile = `mktemp`
set sedfile = `mktemp`
switch ($increm)
case 0:
echo "s/${infostring}/${cur}:${prev}:${age}/" > $sedfile
breaksw
case 1:
echo "s/${infostring}/${pcur}:0:${page}/" > $sedfile
breaksw
case 2:
echo "s/${infostring}/${pcur}:0:0/" > $sedfile
breaksw
default:
echo "Something enourmously abnormal happened"
exit 1
breaksw
endsw
sed -f $sedfile $mak > $tmpfile
\rm -f $sedfile
diff -u0 $mak $tmpfile
echo -n "Confirmation of incrementation ? (yes/no) "
set answ = $<
if ("$answ" == "yes") then
\cp -p $mak $backupmake
\mv -f $tmpfile $mak
echo -n "Removing back-up for $conf, $mkf, $mak and $ver ? (y/n)"
set remo = $<
if ("$remo" == "y") then
\rm -f $backupconf
\rm -f $backupver
\rm -f $backupmake
\rm -f $backupmkf
else
echo "You can find them in $backupconf, $backupmkf, $backupver and $backupmake."
endif
else
echo "'$answ' was read. Not incrementing anything."
echo " your old $conf and $ver are restored..."
\rm -f $tmpfile
\mv -f $backupconf $conf
\mv -f $backupver $ver
\mv -f $backupmkf $mkf
exit 0
endif
endif
else
echo "'$answ' was read. Not incrementing anything."
exit 0
endif
exit 0
# how to unset set variables ?