-
Notifications
You must be signed in to change notification settings - Fork 59
/
jnirelease.sh
executable file
·296 lines (267 loc) · 8.04 KB
/
jnirelease.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
#!/bin/sh
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# BEFORE releasing don't forget to edit and commit
# native/include/tcn_version.h
# native/os/win32/libtcnative.rc
# Default place to look for apr source. Can be overridden with
# --with-apr=[directory]
apr_src_dir=`pwd`/native/srclib/apr
GITBASE=https://gitbox.apache.org/repos/asf/tomcat-native.git
TCJAVA_GITBASE=https://gitbox.apache.org/repos/asf/tomcat.git
# Set the environment variable that stops OSX storing extended
# attributes in tar archives etc. with a file starting with ._
COPYFILE_DISABLE=1
export COPYFILE_DISABLE
JKJNIEXT=""
JKJNIHASH=""
JKJNIVER=""
JKJNIREL=""
JKJNIFORCE=""
for o
do
case "$o" in
-*=*) a=`echo "$o" | sed 's/^[-_a-zA-Z0-9]*=//'` ;;
*) a='' ;;
esac
case "$o" in
-f )
JKJNIFORCE=1
shift
;;
--ver*=* )
JKJNIEXT="$a"
shift
;;
--with-apr=* )
apr_src_dir="$a" ;
shift ;;
* )
echo ""
echo "Usage: jnirelease.sh [options]"
echo " --ver[sion]=<version> Tomcat Native version"
echo " --with-apr=<directory> APR sources directory"
echo ""
exit 1
;;
esac
done
if [ -d "$apr_src_dir" ]; then
echo ""
echo "Using apr source from: \`$apr_src_dir'"
else
echo ""
echo "Problem finding apr source in: \`$apr_src_dir'"
echo "Use:"
echo " --with-apr=<directory>"
echo ""
exit 1
fi
if [ "x$JKJNIEXT" = "x" ]; then
echo ""
echo "Unknown Git tag/branch"
echo "Use:"
echo " --ver=<tag>|1.1.x|1.2.x|main|."
echo ""
exit 1
fi
# Check for links, elinks or w3m
w3m_opts="-dump -cols 80 -t 4 -S -O iso-8859-1 -T text/html"
elinks_opts="-dump -dump-width 80 -dump-charset iso-8859-1 -no-numbering -no-references -no-home"
links_opts="-dump -width 80 -codepage iso-8859-1 -no-g -html-numbered-links 0"
EXPTOOL=""
EXPOPTS=""
for i in w3m elinks links
do
EXPTOOL="`which $i 2>/dev/null || type $i 2>&1`"
if [ -x "$EXPTOOL" ]; then
case ${i} in
w3m)
EXPOPTS="${w3m_opts}"
;;
elinks)
EXPOPTS="${elinks_opts}"
;;
links)
EXPOPTS="${links_opts}"
;;
esac
echo "Using: ${EXPTOOL} ${EXPOPTS} ..."
break
fi
done
if [ ! -x "$EXPTOOL" ]; then
echo ""
echo "Cannot find html export tool"
echo "Make sure you have either w3m elinks or links in the PATH"
echo ""
exit 1
fi
PERL="`which perl 2>/dev/null || type perl 2>&1`"
if [ -x "$PERL" ]; then
echo "Using $PERL"
else
echo ""
echo "Cannot find perl"
echo "Make sure you have perl in the PATH"
echo ""
exit 1
fi
if [ "x$JKJNIEXT" = "xmain" ]; then
JKJNIHASH=`git ls-remote $GITBASE refs/heads/main | awk '{print $1}'`
JKJNIVER="$JKJNIEXT-$JKJNIHASH"
elif [ "x$JKJNIEXT" = "x1.2.x" ]; then
JKJNIHASH=`git ls-remote $GITBASE refs/heads/1.2.x | awk '{print $1}'`
JKJNIVER="$JKJNIEXT-$JKJNIHASH"
elif [ "x$JKJNIEXT" = "x1.1.x" ]; then
JKJNIHASH=`git ls-remote $GITBASE refs/heads/1.1.x | awk '{print $1}'`
JKJNIVER="$JKJNIEXT-$JKJNIHASH"
elif [ "x$JKJNIEXT" = "x." ]; then
JKJNIHASH=`git rev-parse --short HEAD`
JKJNIVER="HEAD-$JKJNIHASH"
else
JKJNIHASH=`git ls-remote $GITBASE refs/tags/$JKJNIEXT | awk '{print $1}'`
JKJNIVER="$JKJNIEXT"
JKJNIREL=1
fi
echo "Using GIT repo : \`${GITBASE}\`"
echo "Using version : \`${JKJNIVER}\`"
if [ ! -d .git ]; then
rm -rf tmp-clone
git clone --no-checkout $GITBASE tmp-clone
mv tmp-clone/.git .
rm -rf tmp-clone
# Checking for recentness of git subtree
git checkout --force ${JKJNIHASH}
else
# Checking for recentness of git subtree
git checkout ${JKJNIHASH}
fi
if [ ! -d .git/refs/remotes/tcjava ]; then
git remote add -f tcjava ${TCJAVA_GITBASE}
fi
git remote update tcjava
diffcount=`git diff HEAD remotes/tcjava/main java/org/apache/tomcat/jni | wc -l`
if [ $diffcount -ne 0 ]; then
echo "WARNING: git subtree is not up to date with"
echo " $TCJAVA_GITBASE"
echo " Either correct now by running"
echo " 'git checkout main'"
echo " 'git rm -rf java/org/apache/tomcat/jni'"
echo " 'git read-tree --prefix=java/org/apache/tomcat/jni/ -u tcjava/main:java/org/apache/tomcat/jni'"
echo " 'git commit'"
echo " or run this script with -f (force)"
if [ "X$JKJNIFORCE" = "X1" ]
then
sleep 3
echo "FORCED run chosen"
else
exit 1
fi
fi
JKJNIDIST=tomcat-native-${JKJNIVER}-src
rm -rf ${JKJNIDIST}
mkdir -p ${JKJNIDIST}
git archive ${JKJNIHASH} | tar -x -C ${JKJNIDIST}
if [ $? -ne 0 ]; then
echo ""
echo "git export failed"
echo ""
exit 1
fi
rm -f ${JKJNIDIST}/KEYS ${JKJNIDIST}/download_deps.sh
# check the release if release.
if [ "x$JKJNIREL" = "x1" ]; then
grep TCN_IS_DEV_VERSION ${JKJNIDIST}/native/include/tcn_version.h | grep 0
if [ $? -ne 0 ]; then
echo "Check: ${JKJNIDIST}/native/include/tcn_version.h says -dev"
echo "Check TCN_IS_DEV_VERSION - Aborting"
exit 1
fi
WIN_VERSION=`grep TCN_VERSION ${JKJNIDIST}/native/os/win32/libtcnative.rc | grep define | awk ' { print $3 } '`
if [ "x\"$JKJNIVER\"" != "x$WIN_VERSION" ]; then
echo "Check: ${JKJNIDIST}/native/os/win32/libtcnative.rc says $WIN_VERSION (FILEVERSION, PRODUCTVERSION, TCN_VERSION)"
echo "Must be $JKJNIVER - Aborting"
exit 1
fi
else
echo "Not a release"
fi
top="`pwd`"
cd ${JKJNIDIST}/xdocs
# Make docs
ant
if [ $? -ne 0 ]; then
echo ""
echo "ant (building docs failed)"
echo ""
exit 1
fi
$EXPTOOL $EXPOPTS ../build/docs/miscellaneous/changelog.html > ../CHANGELOG.txt 2>/dev/null
if [ $? -ne 0 ]; then
echo ""
echo "$EXPTOOL $EXPOPTS ../build/docs/miscellaneous/changelog.html failed"
echo ""
exit 1
fi
# Remove page navigation data from converted file.
cp -p ../CHANGELOG.txt ../CHANGELOG.txt.tmp
awk '/Preface/ {o=1} o>0' ../CHANGELOG.txt.tmp > ../CHANGELOG.txt
rm ../CHANGELOG.txt.tmp
cd "$top"
mv ${JKJNIDIST}/build/docs ${JKJNIDIST}/docs
rm -rf ${JKJNIDIST}/build
# Prebuild (create configure)
cd ${JKJNIDIST}/native
./buildconf --with-apr=$apr_src_dir || exit 1
cd "$top"
# Create source distribution
tar -cf - ${JKJNIDIST} | gzip -c9 > ${JKJNIDIST}.tar.gz || exit 1
# Create Win32 source distribution
JKWINDIST=tomcat-native-${JKJNIVER}-win32-src
rm -rf ${JKWINDIST}
mkdir -p ${JKWINDIST}
git -c core.autocrlf=true -c core.eol=crlf archive ${JKJNIHASH} | tar -x -C ${JKWINDIST}
if [ $? -ne 0 ]; then
echo ""
echo "git export failed"
echo ""
exit 1
fi
rm -f ${JKWINDIST}/KEYS ${JKWINDIST}/download_deps.sh
top="`pwd`"
cd ${JKWINDIST}/xdocs
# Make docs
ant
if [ $? -ne 0 ]; then
echo ""
echo "ant (building docs failed)"
echo ""
exit 1
fi
cd "$top"
cp ${JKJNIDIST}/CHANGELOG.txt ${JKWINDIST}
mv ${JKWINDIST}/build/docs ${JKWINDIST}/docs
rm -rf ${JKWINDIST}/build
for i in LICENSE NOTICE README.txt
do
$PERL ${JKWINDIST}/native/build/lineends.pl --cr ${JKWINDIST}/${i}
done
$PERL ${JKWINDIST}/native/build/lineends.pl --cr ${JKWINDIST}/CHANGELOG.txt
$PERL ${JKWINDIST}/native/build/lineends.pl --nocr ${JKWINDIST}/native/srclib/openssl/openssl-msvcrt-3.0.x.patch
zip -9rqyo ${JKWINDIST}.zip ${JKWINDIST}