-
Notifications
You must be signed in to change notification settings - Fork 23
/
incremente-versions
executable file
·135 lines (125 loc) · 3.98 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
#!/bin/csh -f
# Copyright (c) 2011 FFLAS-FFPACK
# written by Brice Boyer (briceboyer) <[email protected]>
# adapted from LinBox configuration
#
# ========LICENCE========
# This file is part of the library FFLAS-FFPACK.
#
# FFLAS-FFPACK is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
# ========LICENCE========
#/
set conf = configure.ac
set ver = 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."
echo -n "Increment library version ? (y/n)"
set answ = $<
if ("$answ" == "y") then
set line = `fgrep -n ^AC_INIT $conf | cut -d':' -f1` #gets the line
set macro = `echo "$vern" | cut -d'.' -f1` #a version number is macro.minor.micro
set minor = `echo "$vern" | cut -d'.' -f2`
set micro = `echo "$vern" | cut -d'.' -f3`
set tmpfile = `mktemp` #tempfile
set sedfile = `mktemp` #temp sed file
set pmicro = `echo $micro`
@ pmicro ++
set pminor = `echo $minor`
@ pminor ++
set pmacro = `echo $macro`
@ pmacro ++
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' read. Not incrementing anything."
breaksw
endsw
#replacing [ ] and . with escaped version for sed would understand them as 'operators'
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 ("$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' read. Not incrementing anything."
\rm -f $tmpfile
exit 0 ;
endif
#now change Makefile accordingly
echo -n "Incrementing Makefile revision accordingly"
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 $ver > $tmpfile
\rm -f $sedfile
diff -u0 $ver $tmpfile
echo -n "Confirmation of incrementation ? (yes/no) "
set answ = $<
if ("$answ" == "yes") then
\mv -f $tmpfile $ver
echo " your old $conf is destroyed..."
\rm -f $backupconf
else
echo "'$answ' read. Not incrementing anything."
echo " your old $conf is restored..."
\rm -f $tmpfile
\mv -f $backupconf $conf
exit 0
endif
endif
else
echo "'$answ' read. Not doing anything."
endif
exit 0