comparison version.sh @ 0:a5a898f6886c

Copy of MonetDB java directory changeset e6e32756ad31.
author Sjoerd Mullender <sjoerd@acm.org>
date Wed, 21 Sep 2016 09:34:48 +0200 (2016-09-21)
parents
children 3abb3634f467 6f74e01c57da
comparison
equal deleted inserted replaced
-1:000000000000 0:a5a898f6886c
1 #!/usr/bin/env bash
2
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 #
7 # Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
8
9 if [[ -z $1 ]] ; then
10 echo "Usage: $0 [-w] <(jdbc|mcl)> <(major|minor|suffix)=newversion> [...]"
11 echo "where -w activates actual write of changes"
12 exit -1
13 fi
14
15 PROPERTIES='build.properties'
16
17 get_value() {
18 local tmp=$(grep -E "^$*=" ${PROPERTIES})
19 echo ${tmp#*=}
20 }
21
22 escape_value() {
23 echo "$*" | sed -e 's/\*/\\*/g' -e 's/\./\\./g'
24 }
25
26 patch="cat"
27
28 # get rid of the script name
29 case $1 in
30 -w)
31 patch="patch -p0";
32 shift
33 ;;
34 esac
35 case $1 in
36 jdbc)
37 TYPE=JDBC
38 FILES="monetdb-jdbc-XXX.jar"
39 ;;
40 mcl)
41 TYPE=MCL
42 FILES="monetdb-mcl-XXX.jar"
43 ;;
44 *)
45 echo "invalid type: $1"
46 exit -1
47 ;;
48 esac
49 shift
50
51 CUR_MAJOR=$(eval "get_value '${TYPE}_MAJOR'")
52 CUR_MINOR=$(eval "get_value '${TYPE}_MINOR'")
53 CUR_SUFFIX=$(eval "get_value '${TYPE}_VER_SUFFIX'")
54
55 NEW_MAJOR=${CUR_MAJOR}
56 NEW_MINOR=${CUR_MINOR}
57 NEW_SUFFIX=${CUR_SUFFIX}
58
59 ESC_MAJOR=$(escape_value ${CUR_MAJOR})
60 ESC_MINOR=$(escape_value ${CUR_MINOR})
61 ESC_SUFFIX=$(escape_value ${CUR_SUFFIX})
62
63 for param in $* ; do
64 arg=${param%%=*}
65 val=${param#*=}
66 num=$(echo ${val} | grep -E '[0-9]+' -o | head -n1)
67 case ${arg} in
68 major)
69 if [[ -z ${num} ]] ; then
70 echo "major needs a numeric argument!";
71 exit -1
72 fi
73 NEW_MAJOR=${num}
74 ;;
75 minor)
76 if [[ -z ${num} ]] ; then
77 echo "minor needs a numeric argument!";
78 exit -1
79 fi
80 NEW_MINOR=${num}
81 ;;
82 suffix)
83 NEW_SUFFIX=${val}
84 ;;
85 esac
86 done
87
88 echo "Current version: ${CUR_MAJOR}.${CUR_MINOR} (${CUR_SUFFIX})"
89 echo "New version: ${NEW_MAJOR}.${NEW_MINOR} (${NEW_SUFFIX})"
90
91 diff="diff -Naur"
92
93 file="release.txt"
94 sed \
95 -e "s|version ${ESC_MAJOR}\.${ESC_MINOR} (${ESC_SUFFIX}|version ${NEW_MAJOR}.${NEW_MINOR} \(${NEW_SUFFIX}|g" \
96 -e "s|${TYPE}-${ESC_MAJOR}\.${ESC_MINOR}|${TYPE}-${NEW_MAJOR}.${NEW_MINOR}|g" \
97 -e "s|Release date: 20[0-9][0-9]-[01][0-9]-[0-3][0-9]|Release date: `date +%F`|" \
98 ${file} | ${diff} ${file} - | ${patch}
99
100 for file in \
101 Makefile.ag \
102 ; do
103 if [[ -f ${file} ]] ; then
104 for f in $FILES ; do
105 fr=${f//XXX/${NEW_MAJOR}.${NEW_MINOR}}
106 fo=${f//XXX/${ESC_MAJOR}.${ESC_MINOR}}
107 fo=${fo//./\\.}
108 sed -e "s|${fo}|${fr}|g" \
109 ${file} | ${diff} ${file} - | ${patch}
110 done
111 else
112 echo "Please do not forget to patch file '${file##*../}', too."
113 fi
114 done
115
116 file="build.properties"
117 sed \
118 -e "s|${TYPE}_MAJOR=${ESC_MAJOR}|${TYPE}_MAJOR=${NEW_MAJOR}|g" \
119 -e "s|${TYPE}_MINOR=${ESC_MINOR}|${TYPE}_MINOR=${NEW_MINOR}|g" \
120 -e "s|${TYPE}_VER_SUFFIX=${ESC_SUFFIX}|${TYPE}_VER_SUFFIX=${NEW_SUFFIX}|g" \
121 ${file} | ${diff} ${file} - | ${patch}
122
123 file="pom.xml"
124 sed \
125 -e "s|<version>${ESC_MAJOR}\.${ESC_MINOR}</version>|<version>${NEW_MAJOR}.${NEW_MINOR}</version>|g" \
126 ${file} | ${diff} ${file} - | ${patch}