1 #%define libexecdir `apxs -q LIBEXECDIR`
2 %define libexecdir /usr/lib/apache
4 #%define httpdconf `apxs -q SYSCONFDIR`
5 %define httpdconf /etc/httpd/conf
7 %define jservconf %{httpdconf}/jserv
8 %define logdir /var/log/httpd
9 %define servletdir /home/httpd/servlets
10 %define classesdir /home/httpd/classes
11 %define jsdkversion 19991120
13 Summary: Servlet engine with support for the leading web server
17 Source0: http://java.apache.org/jserv/dist/%{name}-%{version}.tar.gz
18 Source1: http://www.euronet.nl/~pauls/java/servlet/download/%{version}%{name}classpathx_servlet-%{jsdkversion}.tar.gz
19 Patch0: ApacheJServ-enable-secret.patch
20 Patch1: ApacheJServ-DESTDIR.patch
21 URL: http://java.apache.org/
22 Copyright: Freely distributable & usable
23 Group: Networking/Daemons
24 Group(pl): Sieciowe/Serwery
26 Requires: apache >= 1.3.6
27 Provides: jserv jsdk20
28 BuildRoot: /tmp/%{name}-%{version}-root
30 #BuildRequires: any-java-compiler
32 BuildRequires: automake >= 1.4
33 BuildRequires: autoconf >= 2.13
34 BuildRequires: libtool >= 1.3.3
35 BuildRequires: apache-devel >= 1.3.9-8
38 Apache JServ is a servlet engine, developed by the Java Apache Project
39 <http://java.apache.org/>. The Apache JServ servlet engine is written in
40 100pc Java application, and listens for servlet requests using the Apache
41 Java protocol (AJp). Typically, these requests will originate from the
42 mod_jserv Apache module (DSO included). This package contains a LGPL'ed
43 implementation of sun's java servlet api version 2.0 by Paul Siegmann
44 <http://www.euronet.nl/~pauls/java/servlet/>
47 rm -rf $RPM_BUILD_ROOT
53 # final position of GNU JSDK-Classes
54 sed 's|@JSDK_CLASSES@|%{classesdir}/servlet-2.0.jar|g' \
55 < conf/jserv.properties.in > conf/jserv.properties.in.new
56 mv conf/jserv.properties.in.new conf/jserv.properties.in
58 # do not load module in provided jserv.conf; we do this in httpd.conf
59 sed 's|@LOAD_OR_NOT@|#|g' \
60 < conf/jserv.conf.in > conf/jserv.conf.in.new
61 mv conf/jserv.conf.in.new conf/jserv.conf.in
69 make -C classpathx_servlet-%{jsdkversion} jar_2_0
70 make -C classpathx_servlet-%{jsdkversion}/apidoc
74 cp classpathx_servlet-%{jsdkversion}/README \
75 classpathx_servlet-%{jsdkversion}/AUTHORS \
76 classpathx_servlet-%{jsdkversion}/COPYING.LIB \
78 cp -r classpathx_servlet-%{jsdkversion}/apidoc jsdk-doc
83 # find apxs utility ..
85 APXS_UTIL=`type -p apxs || true`
88 if test "x$APXS_UTIL" = x ; then
89 # mmh, is it possible to query just for
90 # the executeables (like -qd and -qc) ?
91 APXSMATCH=`rpm -ql apache-devel apache | grep apxs`
92 for f in $APXSMATCH ; do
93 if test -x "$f" ; then
101 if test "x$APXS_UTIL" = x ; then
105 %{_prefix}/local/apache/bin \
106 %{_prefix}/local/apache/sbin \
107 %{_prefix}/local/httpd/bin \
108 %{_prefix}/local/httpd/sbin
110 if test -x "$loc/apxs" ; then
111 APXS_UTIL="$loc/apxs"
117 if test "x$APXS_UTIL" = x ; then
118 echo "Didn't find apxs .. exiting"
122 APXS_CFLAGS=`$APXS_UTIL -q CFLAGS`
123 CFLAGS="$APXS_CFLAGS $RPM_OPT_FLAGS" ./configure \
124 --prefix=%{_prefix} \
125 --disable-debugging \
126 --with-apxs=$APXS_UTIL \
127 --with-logdir=%{logdir} \
128 --with-servlets=%{servletdir} \
129 --with-JSDK=`pwd`/classpathx_servlet-%{jsdkversion}/servlet-2.0.jar
133 rm -rf $RPM_BUILD_ROOT
135 make DESTDIR=$RPM_BUILD_ROOT install
137 echo "default - change on install `date`" > $RPM_BUILD_ROOT/%{jservconf}/jserv.secret.key
138 chmod 600 $RPM_BUILD_ROOT/%{jservconf}/jserv.secret.key
141 #install -d $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d
142 #install -d $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
143 #install -d $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d
144 #install -m755 src/scripts/package/rpm/jserv.init $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/jserv
145 #install -m755 src/scripts/package/rpm/jserv.sh $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
146 #install -m644 src/scripts/package/rpm/jserv.logrotate $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/jserv
149 install -d ${RPM_BUILD_ROOT}%{classesdir}
150 install classpathx_servlet-%{jsdkversion}/servlet-2.0.jar ${RPM_BUILD_ROOT}%{classesdir}
153 rm -rf $RPM_BUILD_ROOT
157 # use fortune + install-date + process-list to create pseudo-random, hardly
158 # guessable secret key. Use md5sum to create a hash from this, if available:
159 (%{_prefix}/games/fortune 2>/dev/null ; date ; ps -eal 2>/dev/null) \
160 | (md5sum 2>/dev/null || cat) \
161 > %{jservconf}/jserv.secret.key
162 chmod 600 %{jservconf}/jserv.secret.key
165 # determine apache-USER and chown the jserv.secrect.key - file
167 APACHEUSER=`grep "^User[ ]\+" %{httpdconf}/httpd.conf | awk '{print $2}'`
168 if test ! "x$APACHEUSER" = x ; then
169 USERCOMMENT="(which is '$APACHEUSER' ?)"
174 chown $APACHEUSER %{jservconf}/jserv.secret.key
177 # determine apache-GROUP and allow this group to write to %{logdir}
178 APACHEGROUP=`grep "^Group[ ]\+" %{httpdconf}/httpd.conf | awk '{print $2}'`
179 if test "x$APACHEGROUP" = x ; then
182 chgrp $APACHEGROUP %{logdir}
186 # Add 'jserv' as an independent service (manual mode)
187 #/sbin/chkconfig --add jserv
188 #/etc/rc.d/init.d/jserv start
191 # Find Include Statement or add it if necessary
193 cp %{httpdconf}/httpd.conf %{httpdconf}/httpd.conf.rpmorig
194 grep '#\?.*[iI]nclude.*/jserv.conf' %{httpdconf}/httpd.conf \
196 if test $? -eq 0 ; then
197 # found. Insert our include statement here
198 ## this depends on GNU-sed ('|') .. but we're on a RedHat system anyway
199 sed 's|^#\?\(.*Include\).*/jserv.conf.*$|\1 %{jservconf}/jserv.conf|g' \
200 < %{httpdconf}/httpd.conf.rpmorig \
201 > %{httpdconf}/httpd.conf
205 echo "<IfModule mod_jserv.c>"
206 echo " Include %{jservconf}/jserv.conf"
208 ) >> %{httpdconf}/httpd.conf
212 # LoadModule; uncomment or insert
214 grep '#\?.*LoadModule.*jserv_module.*mod_jserv.so' %{httpdconf}/httpd.conf \
216 if test $? -eq 0 ; then
217 # found. Remove any comment
218 sed 's|^#.*\(LoadModule.*mod_jserv.so\)|\1|g' \
219 < %{httpdconf}/httpd.conf \
220 > %{httpdconf}/httpd.conf.loadMod
221 mv %{httpdconf}/httpd.conf.loadMod %{httpdconf}/httpd.conf
223 # Insert LoadModule line before first valid LoadModule
224 ( echo "/^LoadModule"
226 echo "LoadModule jserv_module modules/mod_jserv.so"
229 ) | ed %{httpdconf}/httpd.conf > /dev/null 2>&1
233 # AddModule; uncomment or insert
235 grep '#\?.*AddModule.*mod_jserv.c' %{httpdconf}/httpd.conf >/dev/null
236 if test $? -eq 0 ; then
237 # found. Remove any comment
238 sed 's|^#.*\(AddModule.*mod_jserv.c\)|\1|g' \
239 < %{httpdconf}/httpd.conf \
240 > %{httpdconf}/httpd.conf.addMod
241 mv %{httpdconf}/httpd.conf.addMod %{httpdconf}/httpd.conf
245 echo "AddModule mod_jserv.c"
248 ) | ed %{httpdconf}/httpd.conf > /dev/null 2>&1
252 # Search vor JAVA at possible locations and edit wrapper.bin
255 for lookfor in java jre ; do
261 /usr/local/jdk117_v3 \
262 /usr/local/jdk117_v1a
264 if test -x "$loc/bin/$lookfor" ; then
265 JAVABIN="$loc/bin/$lookfor"
270 if test -z "$JAVABIN" ; then
271 for prefix in /usr/jdk /usr/jdk- /usr/local/jdk /usr/local/jdk- ; do
272 for jplatform in 2 1 ; do
273 for subvers in .9 .8 .7 .6 .5 .4 .3 .2 .1 "" ; do
274 if test -x "${prefix}1.$jplatform$subvers/bin/$lookfor" ; then
275 JAVABIN="${prefix}1.$jplatform$subvers/bin/$lookfor"
279 if test ! -z "$JAVABIN" ; then break ; fi
281 if test ! -z "$JAVABIN" ; then break ; fi
284 if test ! -z "$JAVABIN" ; then break ; fi
287 if test ! -z "$JAVABIN" ; then
288 sed "s|^wrapper.bin=.*$|wrapper.bin=$JAVABIN|" \
289 < %{jservconf}/jserv.properties \
290 > %{jservconf}/jserv.properties.new
291 mv %{jservconf}/jserv.properties.new %{jservconf}/jserv.properties
295 # Get Server Port to echo right URL below
297 SERVERPORT=`grep "^Port" %{httpdconf}/httpd.conf | \
298 head -1 | awk '{print ":" $2}'`
299 if test "$SERVERPORT" = ":80" ; then
303 #FIXME: make this i18n-aware
305 if test ! "x$JAVABIN" = x ; then
306 echo "using java VM $JAVABIN"
308 echo "## didn't find java or jre. Please install it and edit the"
309 echo "## wrapper.bin property in %{jservconf}/jserv.properties"
312 echo "In order to enable JServ, restart the webserver and try"
313 echo " http://localhost$SERVERPORT/servlets/IsItWorking"
315 echo " http://localhost$SERVERPORT/jserv/"
319 ## we hopefully may distribute SUN-jsdk.jar with jserv once ..
320 echo " | NOTE that this distribution contains a fully functional"
321 echo " | free jsdk replacement, see <http://www.euronet.nl/~pauls/java/servlet/>."
322 echo " | If you want to use the SUN-jsdk, replace the servlet-2.0.jar"
323 echo " | in the wrapper.classpath - line in the file"
324 echo " | %{jservconf}/jserv.properties"
325 echo " | with the SUN jsdk."
326 echo " | Get it from <http://java.sun.com/products/servlet/>."
327 echo " | Only JSDK 2.0 (Java Servlet Development Kit)"
328 echo " | is supported (_EXACTLY_ 2.0)."
331 echo "Please send comments/suggestions regarding"
332 echo "this RPM to <zeller@to.com>."
336 # do not remove the configured stuff if we upgrade.
337 # the $1 argument contains the number of packages _after_ installation.
338 if [ ! $1 -eq 0 ] ; then
342 # Remove 'jserv' service (manual mode)
343 #/etc/rc.d/init.d/jserv stop
344 #/sbin/chkconfig --del jserv
347 # Find jserv related configuration settings and comment
350 cp %{httpdconf}/httpd.conf %{httpdconf}/httpd.conf.rpmorig
351 sed 's|.*\(Include.*%{jservconf}/jserv.conf\)|#\1|g' \
352 < %{httpdconf}/httpd.conf.rpmorig \
353 | sed 's|^\(AddModule.*mod_jserv.c\)|#\1|g' \
354 | sed 's|^\(LoadModule.*mod_jserv.so\)|#\1|g' \
355 > %{httpdconf}/httpd.conf
357 /bin/rm -fr %{logdir}/mod_jserv.log
358 /bin/rm -fr %{logdir}/jserv.log
361 %defattr(644,root,root,755)
362 # mmh, we can't give %{_prefix}/docs to %doc ..
363 %doc index.html README docs jsdk-doc
366 %config %{jservconf}/jserv.properties
367 %config %{jservconf}/zone.properties
368 %config %{jservconf}/jserv.conf
370 # these are just for demonstration and thus,
371 # no %config-files per-se; do not install
372 # them for the RPM-packet
373 #%{jservconf}/jserv.properties.default
374 #%{jservconf}/zone.properties.default
375 #%{jservconf}/jserv.conf.default
377 %attr(-,nobody,nobody) %{jservconf}/jserv.secret.key
378 #%config %{_sysconfdir}/rc.d/init.d/jserv
379 #%config %{_sysconfdir}/logrotate.d/jserv
380 #%config %{_sysconfdir}/profile.d/jserv.sh
382 %{libexecdir}/mod_jserv.so
383 %{libexecdir}/ApacheJServ.jar
386 %{classesdir}/servlet-2.0.jar
389 %{servletdir}/IsItWorking.java
390 %{servletdir}/IsItWorking.class
392 # we need to have write access here
393 %attr(-,nobody,-) %dir %{logdir}