2 %bcond_with gcj # use javac instead of GCJ
4 %define jsdkversion 20000924
5 %define apxs /usr/sbin/apxs1
6 Summary: Servlet engine with support for the leading web server
7 Summary(pl): Silnik serwletów ze wsparciem dla wiod±cego serwera WWW
11 License: freely distributable & usable (JServ), LGPL (JSDK)
12 Group: Networking/Daemons
13 Source0: http://java.apache.org/jserv/dist/%{name}-%{version}.tar.gz
14 # Source0-md5: 6d48a1b9fcc5eea4dfebaae29ba5a485
15 Source1: http://www.euronet.nl/~pauls/java/servlet/download/classpathx_servlet-%{jsdkversion}.tar.gz
16 # Source1-md5: a81feddb91b1358f9aaed94e83eddb54
17 Patch0: %{name}-enable-secret.patch
18 Patch1: %{name}-ac.patch
19 URL: http://java.apache.org/
20 BuildRequires: apache1-devel >= 1.3.9-8
22 BuildRequires: gcc-java
23 BuildRequires: fastjar
24 #BuildRequires: gcc-java-tools
25 Requires: /usr/bin/gij
34 Requires(post): sh-utils
35 Requires(post): textutils
36 Requires(post,preun): fileutils
37 Requires(post,preun): sed
38 Requires: apache1 >= 1.3.6
41 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
43 %define libexecdir %(%{apxs} -q LIBEXECDIR)
44 %define httpdconf %(%{apxs} -q SYSCONFDIR)
45 %define jservconf %{httpdconf}/jserv
46 %define logdir /var/log/httpd
47 %define servletdir %{_datadir}/jserv/servlets
48 %define classesdir %{_datadir}/jserv/classes
51 Apache JServ is a servlet engine, developed by the Java Apache Project
52 <http://java.apache.org/>. The Apache JServ servlet engine is written
53 in 100pc Java application, and listens for servlet requests using the
54 Apache Java protocol (AJp). Typically, these requests will originate
55 from the mod_jserv Apache module (DSO included). This package contains
56 a LGPL'ed implementation of sun's java servlet api version 2.0 by Paul
57 Siegmann <http://www.euronet.nl/~pauls/java/servlet/>
60 Apache JServ jest silnikiem serwletowym, rozwijanym przez Java Apache
61 Project <http://java.apache.org/>. Silnik serwletowy Apache JServ
62 zosta³ napisany od pocz±tku do koñca w Javie; nas³uchuje wywo³añ
63 serwletu wykorzystuj±c protokó³ Apache Java (AJp). Zazwyczaj wywo³ania
64 te pochodz± z modu³u Apache mod_jservmodule (³±cznie z DSO). Pakiet
65 ten zawiera sunowsk± implementacjê api serletów w javie w wersji 2.0
66 (na licencji LGPL) napisana przez Paula Siegmanna
67 <http://www.euronet.nl/~pauls/java/servlet/>
74 # final position of GNU JSDK-Classes
75 sed -i -e 's|@JSDK_CLASSES@|%{classesdir}/servlet-2.0.jar|g' conf/jserv.properties.in
77 # do not load module in provided jserv.conf; we do this in httpd.conf
78 sed -i -e 's|@LOAD_OR_NOT@|#|g' conf/jserv.conf.in
80 # we don't want gcj related deps
81 sed -i -e '/^SUBDIRS/s,java,,' src/Makefile.am
82 sed -i -e '/^SUBDIRS/s,example,,' Makefile.am
85 if [ ! -f _autotools.done.1 ]; then
91 touch _autotools.done.1
95 if [ ! -f classpathx_servlet-%{jsdkversion}/servlet-2.0.jar ]; then
96 %{__make} -C classpathx_servlet-%{jsdkversion} jar_2_0
99 if [ ! -d jsdk-doc ]; then
100 %{__make} -C classpathx_servlet-%{jsdkversion}/apidoc
104 cp classpathx_servlet-%{jsdkversion}/{README,AUTHORS,COPYING.LIB} jsdk-doc
105 cp -r classpathx_servlet-%{jsdkversion}/apidoc jsdk-doc
108 #%{!?with_gcj:GCJ=javac GCJFLAGS= CLASSPATH=`pwd` JAVAC_OPT="-source 1.4" ac_cv_objext=class} \
111 APXS_CFLAGS=`%{apxs} -q CFLAGS`
112 %{!?with_gcj:GCJ=javac GCJFLAGS= CLASSPATH=`pwd` JAVAC_OPT="-source 1.4"} \
113 CFLAGS="$APXS_CFLAGS %{rpmcflags}" ./configure \
114 --prefix=%{_prefix} \
115 --disable-debugging \
116 --with-apxs=%{apxs} \
117 --with-logdir=%{logdir} \
118 --with-servlets=%{servletdir} \
119 %{!?with_gcj:--with-javac=%{_bindir}/javac --with-jdk-home=%{_libdir}/java} \
120 %{?with_gcj:--with-javac=%{_bindir}/gcj --with-jar=%{_bindir}/fastjar} \
121 --with-JSDK=`pwd`/classpathx_servlet-%{jsdkversion}/servlet-2.0.jar \
123 %{__make} %{!?with_gcj:OBJEXT=class JAVAC_OPT='-source 1.4'} \
128 rm -rf $RPM_BUILD_ROOT
129 install -d $RPM_BUILD_ROOT%{classesdir}
130 #install -d $RPM_BUILD_ROOT/etc/{rc.d/init.d,profile.d,logrotate.d}
133 DESTDIR=$RPM_BUILD_ROOT
135 # we removed java, so do it manually
137 %{!?with_gcj:OBJEXT=class JAVAC_OPT='-source 1.4'} \
139 DESTDIR=$RPM_BUILD_ROOT
141 echo "default - change on install `date`" > $RPM_BUILD_ROOT%{jservconf}/jserv.secret.key
142 chmod 600 $RPM_BUILD_ROOT%{jservconf}/jserv.secret.key
145 #install -m755 src/scripts/package/rpm/jserv.init $RPM_BUILD_ROOT/etc/rc.d/init.d/jserv
146 #install -m755 src/scripts/package/rpm/jserv.sh $RPM_BUILD_ROOT/etc/profile.d
147 #install -m644 src/scripts/package/rpm/jserv.logrotate $RPM_BUILD_ROOT/etc/logrotate.d/jserv
150 install classpathx_servlet-%{jsdkversion}/servlet-2.0.jar $RPM_BUILD_ROOT%{classesdir}
152 find jsdk-doc -name 'Makefile*' | xargs rm -f
153 rm -rf jsdk-doc/{COPYING.LIB,CVS}
156 rm -rf $RPM_BUILD_ROOT
159 # use fortune + install-date + process-list to create pseudo-random, hardly
160 # guessable secret key. Use md5sum to create a hash from this, if available:
161 (fortune 2>/dev/null ; date ; ps -eal 2>/dev/null) \
162 | (md5sum 2>/dev/null || cat) > %{jservconf}/jserv.secret.key
163 chmod 600 %{jservconf}/jserv.secret.key
166 # determine apache-USER and chown the jserv.secrect.key - file
168 APACHEUSER=`grep "^User[ ]\+" %{httpdconf}/httpd.conf | awk '{print $2}'`
169 if test ! "x$APACHEUSER" = x ; then
170 USERCOMMENT="(which is '$APACHEUSER' ?)"
175 chown $APACHEUSER %{jservconf}/jserv.secret.key
178 # determine apache-GROUP and allow this group to write to %{logdir}
179 APACHEGROUP=`grep "^Group[ ]\+" %{httpdconf}/httpd.conf | awk '{print $2}'`
180 if test "x$APACHEGROUP" = x ; then
183 chgrp $APACHEGROUP %{logdir}
187 # Add 'jserv' as an independent service (manual mode)
188 #/sbin/chkconfig --add jserv
189 #/etc/rc.d/init.d/jserv start
192 # Find Include Statement or add it if necessary
195 cp -f %{httpdconf}/httpd.conf %{httpdconf}/httpd.conf.rpmorig
196 grep -q '#\?.*[iI]nclude.*/jserv.conf' %{httpdconf}/httpd.conf
197 if test $? -eq 0 ; then
198 # found. Insert our include statement here
199 ## this depends on GNU-sed ('|')
200 sed 's|^#\?\(.*Include\).*/jserv.conf.*$|\1 %{jservconf}/jserv.conf|g' \
201 %{httpdconf}/httpd.conf.rpmorig > %{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 -q '#\?.*LoadModule.*jserv_module.*mod_jserv.so' %{httpdconf}/httpd.conf
215 if test $? -eq 0 ; then
216 # found. Remove any comment
217 sed 's|^#.*\(LoadModule.*mod_jserv.so\)|\1|g' \
218 %{httpdconf}/httpd.conf > %{httpdconf}/httpd.conf.loadMod
219 mv -f %{httpdconf}/httpd.conf.loadMod %{httpdconf}/httpd.conf
221 # Insert LoadModule line before first valid LoadModule
225 echo "LoadModule jserv_module modules/mod_jserv.so"
228 ) | ed %{httpdconf}/httpd.conf > /dev/null 2>&1
232 # AddModule; uncomment or insert
234 grep -q '#\?.*AddModule.*mod_jserv.c' %{httpdconf}/httpd.conf
235 if test $? -eq 0 ; then
236 # found. Remove any comment
237 sed 's|^#.*\(AddModule.*mod_jserv.c\)|\1|g' \
238 %{httpdconf}/httpd.conf > %{httpdconf}/httpd.conf.addMod
239 mv -f %{httpdconf}/httpd.conf.addMod %{httpdconf}/httpd.conf
244 echo "AddModule mod_jserv.c"
247 ) | ed %{httpdconf}/httpd.conf > /dev/null 2>&1
251 # Search for JAVA at possible locations and edit wrapper.bin
254 for lookfor in java jre ; do
262 if test -x "$loc/bin/$lookfor" ; then
263 JAVABIN="$loc/bin/$lookfor"
268 if test -z "$JAVABIN" ; then
269 for prefix in /usr/jdk /usr/jdk- /usr/local/jdk /usr/local/jdk- ; do
270 for jplatform in 2 1 ; do
271 for subvers in .9 .8 .7 .6 .5 .4 .3 .2 .1 "" ; do
272 if test -x "${prefix}1.$jplatform$subvers/bin/$lookfor" ; then
273 JAVABIN="${prefix}1.$jplatform$subvers/bin/$lookfor"
277 if test ! -z "$JAVABIN" ; then break ; fi
279 if test ! -z "$JAVABIN" ; then break ; fi
282 if test ! -z "$JAVABIN" ; then break ; fi
286 if test ! -z "$JAVABIN" ; then
287 sed "s|^wrapper.bin=.*$|wrapper.bin=$JAVABIN|" \
288 %{jservconf}/jserv.properties > %{jservconf}/jserv.properties.new
289 mv -f %{jservconf}/jserv.properties.new %{jservconf}/jserv.properties
293 # Get Server Port to echo right URL below
295 SERVERPORT=`grep "^Port" %{httpdconf}/httpd.conf | \
296 head -n 1 | awk '{print ":" $2}'`
297 if test "$SERVERPORT" = ":80" ; then
301 #FIXME: make this i18n-aware
303 if test ! "x$JAVABIN" = x ; then
304 echo "using java VM $JAVABIN"
306 echo "## didn't find java or jre. Please install it and edit the"
307 echo "## wrapper.bin property in %{jservconf}/jserv.properties"
310 echo "In order to enable JServ, restart the webserver and try"
311 echo " http://localhost$SERVERPORT/servlets/IsItWorking"
313 echo " http://localhost$SERVERPORT/jserv/"
317 ## we hopefully may distribute SUN-jsdk.jar with jserv once ..
318 echo " | NOTE that this distribution contains a fully functional"
319 echo " | free jsdk replacement, see <http://www.euronet.nl/~pauls/java/servlet/>."
320 echo " | If you want to use the SUN-jsdk, replace the servlet-2.0.jar"
321 echo " | in the wrapper.classpath - line in the file"
322 echo " | %{jservconf}/jserv.properties"
323 echo " | with the SUN jsdk."
324 echo " | Get it from <http://java.sun.com/products/servlet/>."
325 echo " | Only JSDK 2.0 (Java Servlet Development Kit)"
326 echo " | is supported (_EXACTLY_ 2.0)."
329 echo "Please send comments/suggestions regarding"
330 echo "this RPM to <zeller@to.com>."
333 # do not remove the configured stuff if we upgrade.
334 # the $1 argument contains the number of packages _after_ installation.
335 if [ "$1" != "0" ] ; then
339 # Remove 'jserv' service (manual mode)
340 #/etc/rc.d/init.d/jserv stop
341 #/sbin/chkconfig --del jserv
344 # Find jserv related configuration settings and comment
348 cp -f %{httpdconf}/httpd.conf %{httpdconf}/httpd.conf.rpmorig
349 sed 's|.*\(Include.*%{jservconf}/jserv.conf\)|#\1|g' \
350 %{httpdconf}/httpd.conf.rpmorig \
351 | sed 's|^\(AddModule.*mod_jserv.c\)|#\1|g' \
352 | sed 's|^\(LoadModule.*mod_jserv.so\)|#\1|g' \
353 > %{httpdconf}/httpd.conf
355 /bin/rm -fr %{logdir}/mod_jserv.log
356 /bin/rm -fr %{logdir}/jserv.log
359 %defattr(644,root,root,755)
360 # mmh, we can't give %{_prefix}/docs to %doc ..
361 %doc index.html LICENSE README docs jsdk-doc
364 %config(noreplace) %verify(not md5 mtime size) %{jservconf}/jserv.properties
365 %config(noreplace) %verify(not md5 mtime size) %{jservconf}/zone.properties
366 %config(noreplace) %verify(not md5 mtime size) %{jservconf}/jserv.conf
368 # these are just for demonstration and thus,
369 # no %config-files per-se; do not install
370 # them for the RPM-packet
371 #%%{jservconf}/jserv.properties.default
372 #%%{jservconf}/zone.properties.default
373 #%%{jservconf}/jserv.conf.default
375 %attr(600,http,http) %{jservconf}/jserv.secret.key
376 #%config /etc/rc.d/init.d/jserv
377 #%attr(640,root,root) %config(noreplace) %verify(not size mtime md5) /etc/logrotate.d/jserv
378 #%config /etc/profile.d/jserv.sh
380 %attr(755,root,root) %{libexecdir}/mod_jserv.so
381 %{libexecdir}/ApacheJServ.jar
384 %{classesdir}/servlet-2.0.jar
388 %{servletdir}/Hello.java
389 %{servletdir}/Hello.class
390 %{servletdir}/IsItWorking.java
391 %{servletdir}/IsItWorking.class
394 # we need to have write access here
395 %attr(770,root,http) %dir %{logdir}