File: fixver.sh

package info (click to toggle)
allegro4.4 2%3A4.4.3.1-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,756 kB
  • sloc: ansic: 164,458; asm: 17,620; cpp: 3,848; javascript: 3,053; objc: 1,687; sh: 1,107; python: 676; pascal: 179; makefile: 54; perl: 29; lisp: 1
file content (118 lines) | stat: -rwxr-xr-x 2,675 bytes parent folder | download | duplicates (8)
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
#! /bin/sh
#
#  Shell script to adjust the version numbers in various AllegroGL files.
#
#  Note: if you pass "datestamp" as the only argument, then the version
#  digits will remain unchanged and the comment will be set to the date.
#  This is in particular useful for making SVN snapshots.

set -e


if [ $# -lt 3 -o $# -gt 4 ]; then
   if [ $# -eq 1 -a $1 == "datestamp" ]; then
      ver=`grep "^AllegroGL - [0-9]" readme.txt | awk '{ print $3 }'`
      split_ver=`echo $ver | tr '.' ' '`
      datestamp=`date '+%Y%m%d'`
      exec $0 $split_ver $datestamp
   else
      echo "Usage: fixver major_num sub_num wip_num [comment]" 1>&2
      echo "   or: fixver datestamp" 1>&2
      echo "Example: fixver 0 4 4 WIP" 1>&2
      exit 1
   fi
fi

# get the version and date strings in a nice format
if [ $# -eq 3 ]; then
   verstr="$1.$2.$3"
else
   verstr="$1.$2.$3 ($4)"
fi


# Patch routine.
# Write to $sed_script then call dopatch <file1> <file2> ...

sed_script=fixver.sed
tmp_file=fixver.tmp
errcode=0

function dopatch() {
   for x in $* ; do
      if [ -f $x ]; then
         echo "Patching $x..."
         cp $x $tmp_file
         sed -f $sed_script $tmp_file > $x
      else
         echo "WARNING: $x does not exist, skipping"
         errcode=1
      fi
   done
}


# patch include/alleggl.h
cat > $sed_script << END_OF_SED
s#\(define AGL_VERSION.*\)[0-9]#\1$1#
s#\(define AGL_SUB_VERSION.*\)[0-9]#\1$2#
s#\(define AGL_WIP_VERSION.*\)[0-9]#\1$3#
s#\(define AGL_VERSION_STR.*"\)[^"]\+"#\1$verstr"#
END_OF_SED

dopatch include/alleggl.h


# patch readme.txt
cat > $sed_script << END_OF_SED
s#^\(AllegroGL - \).*#\1$verstr#
END_OF_SED

dopatch readme.txt



# patch make/makefile.ver
cat > $sed_script << END_OF_SED
s#^\(shared_version =\).*#\1 $1.$2.$3#
s#^\(shared_major_minor =\).*#\1 $1.$2#
s#^\(shared_major =\).*#\1 $1#
END_OF_SED

dopatch make/makefile.ver


# patch projects/msvc2005/allegrogl/allegrogl.vcproj
# There are two instances of Version= in the file.  We rely on the fact that
# the version we _don't_ want to change contains a comma, and that the
# AllegroGL version number doesn't.
cat > $sed_script << END_OF_SED
s#\(Version="\)[^",]\+"#\1$verstr"#
END_OF_SED

dopatch projects/msvc2005/allegrogl/allegrogl.vcproj


# patch projects/msvc6/allegrogldll/allegrogldll.dsp
cat > $sed_script << END_OF_SED
s#\(version:\)[0-9][.][0-9]\+#\1$1.$2$3#
END_OF_SED

dopatch projects/msvc6/allegrogldll/allegrogldll.dsp


# patch docs/Doxyfile
cat > $sed_script << END_OF_SED
s#^\(PROJECT_NUMBER.*=\).*#\1 $verstr#
END_OF_SED

dopatch docs/Doxyfile


# clean up after ourselves
rm -f $sed_script $tmp_file

echo "Done!"
exit $errcode

# vim: sts=3 sw=3 et