File: incremente-versions

package info (click to toggle)
linbox 1.7.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,940 kB
  • sloc: cpp: 108,392; lisp: 5,469; makefile: 1,345; sh: 1,244; csh: 131; python: 74; perl: 2
file content (151 lines) | stat: -rwxr-xr-x 4,417 bytes parent folder | download | duplicates (4)
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
#!/bin/csh -f
# Copyright(c) 2011 LinBox
# Copyright(c)'1994-2009 by The Givaro group
# Imported and modified from Givaro's by Brice Boyer (briceboyer) <boyer.brice@gmail.com>
# see the COPYING file for more details.


set conf = configure.ac
set ver  = Makefile.am
set autoinst = linbox-auto-install.sh

#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 = $<
                set backupmake = $ver.back$$
		if ("$answ" == "yes") then
			\cp -p $ver $backupmake
			\mv -f $tmpfile $ver
		else
			echo "'$answ' read. Not incrementing anything."
			echo " your old $conf is restored..."
			\rm -f $tmpfile
			\mv -f $backupconf $conf
			exit 0
		endif
	#now change linbox-auto-install accordingly
		echo -n "Incrementing linbox-auto-install.sh revision accordingly"
		set tmpfile = `mktemp` #tempfile
		set sedfile = `mktemp` #tempfile
		switch ($increm)
			case 0:
				echo -n "s/STABLE_LB=.*/STABLE_LB=$macro.$minor.$pmicro/"  >> $sedfile
				breaksw
			case 1:
				echo "s/STABLE_LB=.*/STABLE_LB=$macro.$pminor.0/"  > $sedfile
				breaksw
			case 2:
				echo "s/STABLE_LB=.*/STABLE_LB=$pmacro.0.0/"  > $sedfile
				breaksw
			default:
				echo "Something abnormal happened"
				exit 1
				breaksw
		endsw
		sed -f $sedfile $autoinst > $tmpfile
		\rm -f $sedfile
		diff -u0 $autoinst $tmpfile
		echo -n "Confirmation of incrementation ? (yes/no) "
		set answ = $<
		if ("$answ" == "yes") then
			\mv -f $tmpfile $autoinst
			echo " your old $conf and $ver are destroyed..."
			\rm -f $backupconf $backupmake
		else
			echo "'$answ' read. Not incrementing anything."
			echo " your old $conf and $ver are restored..."
			\rm -f $tmpfile
			\mv -f $backupconf $conf
			\mv -f $backupmake $ver
			exit 0
		endif
	endif
else
	echo "'$answ' read. Not doing anything."
endif

exit 0