3 # Licensed to the Apache Software Foundation (ASF) under one or more
4 # contributor license agreements. See the NOTICE file distributed with
5 # this work for additional information regarding copyright ownership.
6 # The ASF licenses this file to You under the Apache License, Version 2.0
7 # (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
19 # Make sure to set your path so that we can find
20 # the following binaries:
21 # cd, mkdir, cp, rm, find
24 # libtoolize, aclocal, autoheader, automake, autoconf
27 # And any one of: w3m, elinks, links (links2)
29 SVNROOT="http://svn.apache.org/repos/asf"
31 JK_CVST="tomcat-connectors"
37 COPY_JK="BUILD.txt native jkstatus support tools xdocs"
38 COPY_NATIVE="LICENSE NOTICE"
40 COPY_CONF="httpd-jk.conf uriworkermap.properties workers.properties workers.properties.minimal"
43 #################### NO CHANGE BELOW THIS LINE ##############
45 #################### FUNCTIONS ##############
48 echo "Usage:: $0 -v VERSION [-f] [-r revision] [-t tag | -b BRANCH | -T | -d DIR]"
49 echo " -v: version to package"
50 echo " -f: force, do not validate tag against version"
51 echo " -t: tag to use if different from version"
52 echo " -r: revision to package"
53 echo " -b: package from branch BRANCH"
54 echo " -T: package from trunk"
55 echo " -d: package from local directory"
56 echo " -p: GNU PG passphrrase used for signing"
57 echo " -k: ID of GNU PG key to use for signing"
68 echo "Copying $item from $src ..."
69 cp -pr $src/$item $target/
73 #################### MAIN ##############
76 while getopts :v:t:r:b:d:p:k:Tf c
81 conflict=$(($conflict+1));;
83 k) SIGN_OPTS="--default-key=$OPTARG $SIGN_OPTS";;
84 p) SIGN_OPTS="--passphrase=$OPTARG $SIGN_OPTS";;
86 conflict=$(($conflict+1));;
88 conflict=$(($conflict+1));;
90 conflict=$(($conflict+1));;
98 shift `expr $OPTIND - 1`
100 if [ $conflict -gt 1 ]
103 echo "Only one of the options '-t', '-b', '-T' and '-d' is allowed."
107 if [ -n "$local_dir" ]
109 echo "Caution: Packaging from directory!"
110 echo "Make sure the directory is committed."
112 while [ "$answer" != "y" -a "$answer" != "n" ]
114 echo "Do you want to proceed? [y/n]"
117 if [ "$answer" != "y" ]
129 if [ -n "$revision" ]
131 revision="-r $revision"
135 JK_SVN_URL="${SVNROOT}/${SVNPROJ}/trunk"
136 svn_url_info="`svn help info | grep URL`"
137 if [ -n "$svn_url_info" ]
139 JK_SVN_INFO="${JK_SVN_URL}"
143 JK_REV=`svn info $revision $JK_SVN_INFO | awk '$1 == "Revision:" {print $2}'`
146 echo "No Revision found at '$JK_SVN_URL'"
150 JK_DIST=${JK_CVST}-${version}-dev${JK_SUFFIX}-src
151 elif [ -n "$branch" ]
153 JK_BRANCH=`echo $branch | sed -e 's#/#__#g'`
154 JK_SVN_URL="${SVNROOT}/${SVNPROJ}/branches/$branch"
155 JK_REV=`svn info $revision ${JK_SVN_URL} | awk '$1 == "Revision:" {print $2}'`
158 echo "No Revision found at '$JK_SVN_URL'"
161 JK_SUFFIX=-${JK_BRANCH}-${JK_REV}
162 JK_DIST=${JK_CVST}-${version}-dev${JK_SUFFIX}-src
163 elif [ -n "$local_dir" ]
165 JK_SVN_URL="$local_dir"
166 JK_REV=`svn info $revision ${JK_SVN_URL} | awk '$1 == "Revision:" {print $2}'`
169 echo "No Revision found at '$JK_SVN_URL'"
172 JK_SUFFIX=-local-`date +%Y%m%d%H%M%S`-${JK_REV}
173 JK_DIST=${JK_CVST}-${version}-dev${JK_SUFFIX}-src
176 JK_TAG=`echo $version | sed -e 's#^#JK_#' -e 's#\.#_#g'`
181 echo $tag | grep "^$JK_TAG" > /dev/null 2>&1
184 echo "Tag '$tag' doesn't belong to version '$version'."
185 echo "Force using '-f' if you are sure."
191 JK_SVN_URL="${SVNROOT}/${SVNPROJ}/tags/${JK_TAG}"
192 JK_REV=`svn info $revision ${JK_SVN_URL} | awk '$1 == "Revision:" {print $2}'`
193 JK_SUFFIX=" ($JK_REV)"
194 JK_DIST=${JK_CVST}-${JK_VER}-src
197 echo "Using subversion URL: $JK_SVN_URL"
198 echo "Rolling into file $JK_DIST.*"
204 rm -rf ${JK_DIST}.tmp
206 mkdir -p ${JK_DIST}.tmp
207 svn export $revision "${JK_SVN_URL}" ${JK_DIST}.tmp/jk
208 if [ $? -ne 0 ]; then
209 echo "svn export failed"
213 for item in ${COPY_TOP}
215 svn export $revision "${JK_SVN_URL}/${item}" ${JK_DIST}.tmp/${item}
218 # Build documentation.
219 cd ${JK_DIST}.tmp/jk/xdocs
223 # Update version information
224 file=${JK_DIST}.tmp/jk/native/common/jk_version.h
225 cp -p $file $file.orig
226 sed -e 's/^#define JK_REVISION .*/#define JK_REVISION "'"$JK_SUFFIX"'"/' \
230 # Copying things into the source distribution
231 copy_files ${JK_DIST}.tmp $JK_DIST "$COPY_TOP"
232 copy_files ${JK_DIST}.tmp/jk $JK_DIST "$COPY_JK"
233 copy_files ${JK_DIST}.tmp/jk/native $JK_DIST "$COPY_NATIVE"
234 copy_files ${JK_DIST}.tmp/jk/build $JK_DIST "$COPY_BUILD"
235 copy_files ${JK_DIST}.tmp/jk/conf $JK_DIST/conf "$COPY_CONF"
237 # Remove extra directories and files
239 rm -rf ${targetdir}/xdocs/jk2
240 rm -rf ${targetdir}/native/CHANGES.txt
241 rm -rf ${targetdir}/native/build.xml
242 rm -rf ${targetdir}/native/NOTICE
243 rm -rf ${targetdir}/native/LICENSE
244 find ${JK_DIST} -name .cvsignore -exec rm -rf \{\} \;
245 find ${JK_DIST} -name CVS -exec rm -rf \{\} \;
246 find ${JK_DIST} -name .svn -exec rm -rf \{\} \;
250 # Check for links, elinks or w3m
251 W3MOPTS="-dump -cols 80 -t 4 -S -O iso-8859-1 -T text/html"
252 ELNKOPTS="-dump -dump-width 80 -dump-charset iso-8859-1 -no-numbering -no-home"
253 LNKOPTS="-dump -width 80 -codepage iso-8859-1 -no-g -html-numbered-links 0"
255 for tool in `echo "w3m elinks links"`
258 for dir in `echo ${PATH} | sed 's!^:!.:!;s!:$!:.!;s!::!:.:!g;s!:! !g'`
260 if [ -x ${dir}/${tool} ]
275 TOOL="links $LNKOPTS"
278 TOOL="elinks $ELNKOPTS"
282 echo "Creating the CHANGES file using '$TOOL' ..."
283 ${TOOL} ../docs/miscellaneous/printer/changelog.html > CHANGES 2>/dev/null
284 if [ -f CHANGES -a -s CHANGES ]
291 if [ ${failed} = "true" ]
293 echo "Can't convert html to text (CHANGES)"
298 echo "Creating the NEWS file using '$TOOL' ..."
301 for news in `ls -r ../xdocs/news/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].xml`
303 print=`echo $news | sed -e 's#xdocs/news#docs/news/printer#' -e 's#\.xml#.html#'`
304 echo "Adding $print to NEWS file ..."
305 ${TOOL} $print >>NEWS
309 echo "Can't convert html to text (NEWS)"
313 # Generate configure et. al.
318 tar cfz ${JK_DIST}.tar.gz --owner="${JK_OWNER}" --group="${JK_GROUP}" ${JK_DIST} || exit 1
319 perl ${JK_DIST}/tools/lineends.pl --cr ${JK_DIST}
320 zip -9 -r ${JK_DIST}.zip ${JK_DIST}
322 # Create detached signature and verify it
323 archive=${JK_DIST}.tar.gz
324 . ${JK_TOOLS}/signfile.sh ${SIGN_OPTS} $archive
325 archive=${JK_DIST}.zip
326 . ${JK_TOOLS}/signfile.sh ${SIGN_OPTS} $archive