This repository has been archived by the owner on Apr 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathfixVersions.sh
executable file
·163 lines (142 loc) · 5.34 KB
/
fixVersions.sh
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
#!/bin/bash
usage ()
{
echo "----------------------------------------------------------"
echo "Usage : fixVersions.sh -f <from_version> [-t <to_version>] -b <StoS|StoR|MtoR|RCtoR|BST> "
echo "Example : fixVersions.sh -f '2.15.0' -t '2.16.0' -b StoS"
echo "Example : fixVersions.sh -f '2.16.0.M1' -t '2.16.0' -b BST"
echo "Example : fixVersions.sh -f '2.15.0' -b StoS"
echo "Note: '-t' is optional, if not given it will be derived from '-f'"
echo "Note: StoS - Snapshot version to another Snapshot version
StoR - Snapshot version to another Release version
MtoR - Milestone version to another Release version
RCtoR - RC version to another Release version
BST - BootStrap version to another version"
echo "----------------------------------------------------------"
exit
}
checkVersionFormat()
{
re='^[0-9]\.[0-9]+\.[0-9].*$'
if ! [[ $1 =~ $re ]] ; then
echo "Error: Version is not in proper format"
usage
fi
}
deriveToVersion()
{
re='^([0-9])\.([0-9]+)\.([0-9])$'
if [[ $from =~ $re ]]; then
majorVersion="${BASH_REMATCH[1]}"
minorVersion="${BASH_REMATCH[2]}"
bugFixVersion="${BASH_REMATCH[3]}"
to=$majorVersion.$(($minorVersion + 1)).$bugFixVersion
echo "# to_version: $to"
fi
}
#ToDo: not used right now
deriveFromVersion()
{
MVNVersion=$(mvn -f ./releng/pom.xml -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
echo "# MVN version from pom $MVNVersion"
from_version=`echo $MVNVersion | sed -e 's/[^0-9][^0-9]*$//'`
echo "# Derived from_version from MVN version $from_version"
}
xargs_sed_inplace() {
if [[ "$OSTYPE" == "darwin"* ]]; then
xargs sed -i '' "$@"
else
xargs sed -i "$@"
fi
}
SnapshotToSnapshot() {
find . -type f -name "MANIFEST.MF" | xargs_sed_inplace -e "s/${from}.qualifier/${to}.qualifier/g"
find . -type f -name "MANIFEST.MF" | xargs_sed_inplace -e "s/;version=\"${from}\"/;version=\"${to}\"/g"
find . -type f -name "MANIFEST.MF" | xargs_sed_inplace -e "s/org.eclipse.xtext.xbase.lib;bundle-version=\"${from}\"/org.eclipse.xtext.xbase.lib;bundle-version=\"${to}\"/g"
find . -type f -name "MANIFEST.MF" | xargs_sed_inplace -e "s/org.eclipse.xtend.lib;bundle-version=\"${from}\"/org.eclipse.xtend.lib;bundle-version=\"${to}\"/g"
find . -type f -name "MANIFEST.MF_gen" | xargs_sed_inplace -e "s/${from}.qualifier/${to}.qualifier/g"
find . -type f -name "pom.xml" | xargs_sed_inplace -e "s/${from}-SNAPSHOT/${to}-SNAPSHOT/g"
find . -type f -name "maven-pom.xml" | xargs_sed_inplace -e "s/${from}-SNAPSHOT/${to}-SNAPSHOT/g"
find . -type f -name "tycho-pom.xml" | xargs_sed_inplace -e "s/${from}-SNAPSHOT/${to}-SNAPSHOT/g"
find . -type f -name "versions.gradle" | xargs_sed_inplace -e "s/version = '${from}-SNAPSHOT'/version = '${to}-SNAPSHOT'/g"
find . -type f -name "feature.xml" | xargs_sed_inplace -e "s/version=\"${from}.qualifier\"/version=\"${to}.qualifier\"/g"
find . -type f -name "feature.xml" | xargs_sed_inplace -e "s/version=\"${from}\" match=\"equivalent\"/version=\"${to}\" match=\"equivalent\"/g"
find . -type f -name "category.xml" | xargs_sed_inplace -e "s/version=\"${from}.qualifier\"/version=\"${to}.qualifier\"/g"
find . -type f -name "plugin.xml" | xargs_sed_inplace -e "s/<version>${from}-SNAPSHOT<\/version>/<version>${to}-SNAPSHOT<\/version>/g"
}
SnapshotToRelease() {
echo "# not usable now"
}
SnapshotToMilestone() {
echo "# not usable now"
}
MilestoneToRelease() {
echo "# not usable now"
}
RCToRelease() {
echo "# not usable now"
}
VersionBootstrap() {
find . -type f -name "pom.xml" | xargs_sed_inplace -e "s/<xtend-maven-plugin-version>${from}<\/xtend-maven-plugin-version>/<xtend-maven-plugin-version>${to}<\/xtend-maven-plugin-version>/g"
find . -type f -name "versions.gradle" | xargs_sed_inplace -e "s/'xtext_bootstrap': '${from}'/'xtext_bootstrap': '${to}'/g"
}
if [ $# -lt 2 ] || [ $# -gt 6 ] ; then
usage
fi
while [ "$1" != "" ]; do
case $1 in
-f ) shift
from=$1 ;;
-t ) shift
to=$1 ;;
-b ) shift
bump=$1 ;;
*) echo "unknown: option $1"
usage
esac
shift
done
echo "# from_version: $from"
echo "# to_version: $to"
echo "# bump/bootstrap: $bump"
checkVersionFormat "$from"
if [ -z "$to" ] ; then
if [ "$bump" != "BST" ]; then
echo "# 'to_version' is unset or set to the empty string"
echo "# deriving 'to_version' from 'from_verison'"
deriveToVersion
else
echo "ERROR# 'to_version' is mandatory for bootstrapping"
exit 1
fi
fi
checkVersionFormat "$to"
if [ "$bump" == "StoS" ]; then
echo "# bumping version from Snapshot to Snapshot"
directories=$(./allDirectories)
for directory in $directories
do
directory=$(echo $directory | tr -d '\r')
echo "Processing $directory"
# remember current dir and change to repository directory
pushd $(pwd) > /dev/null
cd $directory
SnapshotToSnapshot
popd &> /dev/null
echo
done
fi
if [ "$bump" == "BST" ]; then
echo "# bootstrapping version from $from to $to"
directories=$(./allDirectories)
for directory in $directories
do
directory=$(echo $directory | tr -d '\r')
# remember current dir and change to repository directory
pushd $(pwd) > /dev/null
cd $directory
VersionBootstrap
popd &> /dev/null
echo
done
fi