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
49 %define _noautocompressdoc package-list
52 Apache JServ is a servlet engine, developed by the Java Apache Project
53 <http://java.apache.org/>. The Apache JServ servlet engine is written
54 in 100pc Java application, and listens for servlet requests using the
55 Apache Java protocol (AJp). Typically, these requests will originate
56 from the mod_jserv Apache module (DSO included). This package contains
57 a LGPL'ed implementation of sun's java servlet api version 2.0 by Paul
58 Siegmann <http://www.euronet.nl/~pauls/java/servlet/>
61 Apache JServ jest silnikiem serwletowym, rozwijanym przez Java Apache
62 Project <http://java.apache.org/>. Silnik serwletowy Apache JServ
63 zosta³ napisany od pocz±tku do koñca w Javie; nas³uchuje wywo³añ
64 serwletu wykorzystuj±c protokó³ Apache Java (AJp). Zazwyczaj wywo³ania
65 te pochodz± z modu³u Apache mod_jservmodule (³±cznie z DSO). Pakiet
66 ten zawiera sunowsk± implementacjê api serletów w javie w wersji 2.0
67 (na licencji LGPL) napisana przez Paula Siegmanna
68 <http://www.euronet.nl/~pauls/java/servlet/>
71 Summary: ApacheJServ documentation
72 Group: Development/Languages/Java
75 ApacheJserv documentation.
82 # final position of GNU JSDK-Classes
83 sed -i -e 's|@JSDK_CLASSES@|%{classesdir}/servlet-2.0.jar|g' conf/jserv.properties.in
85 # do not load module in provided jserv.conf; we do this in httpd.conf
86 sed -i -e 's|@LOAD_OR_NOT@|#|g' conf/jserv.conf.in
88 # we don't want gcj related deps
89 sed -i -e '/^SUBDIRS/s,java,,' src/Makefile.am
90 sed -i -e '/^SUBDIRS/s,example,,' Makefile.am
93 if [ ! -f _autotools.done.1 ]; then
99 touch _autotools.done.1
102 # prepare compilation
103 if [ ! -f classpathx_servlet-%{jsdkversion}/servlet-2.0.jar ]; then
104 %{__make} -C classpathx_servlet-%{jsdkversion} jar_2_0
107 if [ ! -d jsdk-doc ]; then
108 %{__make} -C classpathx_servlet-%{jsdkversion}/apidoc
112 cp classpathx_servlet-%{jsdkversion}/{README,AUTHORS,COPYING.LIB} jsdk-doc
113 cp -r classpathx_servlet-%{jsdkversion}/apidoc jsdk-doc
116 #%{!?with_gcj:GCJ=javac GCJFLAGS= CLASSPATH=`pwd` JAVAC_OPT="-source 1.4" ac_cv_objext=class} \
119 APXS_CFLAGS=`%{apxs} -q CFLAGS`
120 %{!?with_gcj:GCJ=javac GCJFLAGS= CLASSPATH=`pwd` JAVAC_OPT="-source 1.4"} \
121 CFLAGS="$APXS_CFLAGS %{rpmcflags}" ./configure \
122 --prefix=%{_prefix} \
123 --disable-debugging \
124 --with-apxs=%{apxs} \
125 --with-logdir=%{logdir} \
126 --with-servlets=%{servletdir} \
127 %{!?with_gcj:--with-javac=%{_bindir}/javac --with-jdk-home=%{_libdir}/java} \
128 %{?with_gcj:--with-javac=%{_bindir}/gcj --with-jar=%{_bindir}/fastjar} \
129 --with-JSDK=`pwd`/classpathx_servlet-%{jsdkversion}/servlet-2.0.jar \
131 %{__make} %{!?with_gcj:OBJEXT=class JAVAC_OPT='-source 1.4'} \
136 rm -rf $RPM_BUILD_ROOT
137 install -d $RPM_BUILD_ROOT%{classesdir}
138 #install -d $RPM_BUILD_ROOT/etc/{rc.d/init.d,profile.d,logrotate.d}
141 DESTDIR=$RPM_BUILD_ROOT
143 # we removed java, so do it manually
145 %{!?with_gcj:OBJEXT=class JAVAC_OPT='-source 1.4'} \
147 DESTDIR=$RPM_BUILD_ROOT
149 echo "default - change on install `date`" > $RPM_BUILD_ROOT%{jservconf}/jserv.secret.key
150 chmod 600 $RPM_BUILD_ROOT%{jservconf}/jserv.secret.key
153 #install -m755 src/scripts/package/rpm/jserv.init $RPM_BUILD_ROOT/etc/rc.d/init.d/jserv
154 #install -m755 src/scripts/package/rpm/jserv.sh $RPM_BUILD_ROOT/etc/profile.d
155 #install -m644 src/scripts/package/rpm/jserv.logrotate $RPM_BUILD_ROOT/etc/logrotate.d/jserv
158 install classpathx_servlet-%{jsdkversion}/servlet-2.0.jar $RPM_BUILD_ROOT%{classesdir}
160 find jsdk-doc -name 'Makefile*' | xargs rm -f
161 rm -rf jsdk-doc/{COPYING.LIB,CVS} jsdk-doc/apidoc/CVS
164 rm -rf $RPM_BUILD_ROOT
167 # use fortune + install-date + process-list to create pseudo-random, hardly
168 # guessable secret key. Use md5sum to create a hash from this, if available:
169 (fortune 2>/dev/null ; date ; ps -eal 2>/dev/null) \
170 | (md5sum 2>/dev/null || cat) > %{jservconf}/jserv.secret.key
171 chmod 600 %{jservconf}/jserv.secret.key
174 # determine apache-USER and chown the jserv.secrect.key - file
176 APACHEUSER=`grep "^User[ ]\+" %{httpdconf}/httpd.conf | awk '{print $2}'`
177 if test ! "x$APACHEUSER" = x ; then
178 USERCOMMENT="(which is '$APACHEUSER' ?)"
183 chown $APACHEUSER %{jservconf}/jserv.secret.key
186 # determine apache-GROUP and allow this group to write to %{logdir}
187 APACHEGROUP=`grep "^Group[ ]\+" %{httpdconf}/httpd.conf | awk '{print $2}'`
188 if test "x$APACHEGROUP" = x ; then
191 chgrp $APACHEGROUP %{logdir}
195 # Add 'jserv' as an independent service (manual mode)
196 #/sbin/chkconfig --add jserv
197 #/etc/rc.d/init.d/jserv start
200 # Find Include Statement or add it if necessary
203 cp -f %{httpdconf}/httpd.conf %{httpdconf}/httpd.conf.rpmorig
204 grep -q '#\?.*[iI]nclude.*/jserv.conf' %{httpdconf}/httpd.conf
205 if test $? -eq 0 ; then
206 # found. Insert our include statement here
207 ## this depends on GNU-sed ('|')
208 sed 's|^#\?\(.*Include\).*/jserv.conf.*$|\1 %{jservconf}/jserv.conf|g' \
209 %{httpdconf}/httpd.conf.rpmorig > %{httpdconf}/httpd.conf
213 echo "<IfModule mod_jserv.c>"
214 echo " Include %{jservconf}/jserv.conf"
216 ) >> %{httpdconf}/httpd.conf
220 # LoadModule; uncomment or insert
222 grep -q '#\?.*LoadModule.*jserv_module.*mod_jserv.so' %{httpdconf}/httpd.conf
223 if test $? -eq 0 ; then
224 # found. Remove any comment
225 sed 's|^#.*\(LoadModule.*mod_jserv.so\)|\1|g' \
226 %{httpdconf}/httpd.conf > %{httpdconf}/httpd.conf.loadMod
227 mv -f %{httpdconf}/httpd.conf.loadMod %{httpdconf}/httpd.conf
229 # Insert LoadModule line before first valid LoadModule
233 echo "LoadModule jserv_module modules/mod_jserv.so"
236 ) | ed %{httpdconf}/httpd.conf > /dev/null 2>&1
240 # AddModule; uncomment or insert
242 grep -q '#\?.*AddModule.*mod_jserv.c' %{httpdconf}/httpd.conf
243 if test $? -eq 0 ; then
244 # found. Remove any comment
245 sed 's|^#.*\(AddModule.*mod_jserv.c\)|\1|g' \
246 %{httpdconf}/httpd.conf > %{httpdconf}/httpd.conf.addMod
247 mv -f %{httpdconf}/httpd.conf.addMod %{httpdconf}/httpd.conf
252 echo "AddModule mod_jserv.c"
255 ) | ed %{httpdconf}/httpd.conf > /dev/null 2>&1
259 # Search for JAVA at possible locations and edit wrapper.bin
262 for lookfor in java jre ; do
270 if test -x "$loc/bin/$lookfor" ; then
271 JAVABIN="$loc/bin/$lookfor"
276 if test -z "$JAVABIN" ; then
277 for prefix in /usr/jdk /usr/jdk- /usr/local/jdk /usr/local/jdk- ; do
278 for jplatform in 2 1 ; do
279 for subvers in .9 .8 .7 .6 .5 .4 .3 .2 .1 "" ; do
280 if test -x "${prefix}1.$jplatform$subvers/bin/$lookfor" ; then
281 JAVABIN="${prefix}1.$jplatform$subvers/bin/$lookfor"
285 if test ! -z "$JAVABIN" ; then break ; fi
287 if test ! -z "$JAVABIN" ; then break ; fi
290 if test ! -z "$JAVABIN" ; then break ; fi
294 if test ! -z "$JAVABIN" ; then
295 sed "s|^wrapper.bin=.*$|wrapper.bin=$JAVABIN|" \
296 %{jservconf}/jserv.properties > %{jservconf}/jserv.properties.new
297 mv -f %{jservconf}/jserv.properties.new %{jservconf}/jserv.properties
301 # Get Server Port to echo right URL below
303 SERVERPORT=`grep "^Port" %{httpdconf}/httpd.conf | \
304 head -n 1 | awk '{print ":" $2}'`
305 if test "$SERVERPORT" = ":80" ; then
309 #FIXME: make this i18n-aware
311 if test ! "x$JAVABIN" = x ; then
312 echo "using java VM $JAVABIN"
314 echo "## didn't find java or jre. Please install it and edit the"
315 echo "## wrapper.bin property in %{jservconf}/jserv.properties"
318 echo "In order to enable JServ, restart the webserver and try"
319 echo " http://localhost$SERVERPORT/servlets/IsItWorking"
321 echo " http://localhost$SERVERPORT/jserv/"
325 ## we hopefully may distribute SUN-jsdk.jar with jserv once ..
326 echo " | NOTE that this distribution contains a fully functional"
327 echo " | free jsdk replacement, see <http://www.euronet.nl/~pauls/java/servlet/>."
328 echo " | If you want to use the SUN-jsdk, replace the servlet-2.0.jar"
329 echo " | in the wrapper.classpath - line in the file"
330 echo " | %{jservconf}/jserv.properties"
331 echo " | with the SUN jsdk."
332 echo " | Get it from <http://java.sun.com/products/servlet/>."
333 echo " | Only JSDK 2.0 (Java Servlet Development Kit)"
334 echo " | is supported (_EXACTLY_ 2.0)."
337 echo "Please send comments/suggestions regarding"
338 echo "this RPM to <zeller@to.com>."
341 # do not remove the configured stuff if we upgrade.
342 # the $1 argument contains the number of packages _after_ installation.
343 if [ "$1" != "0" ] ; then
347 # Remove 'jserv' service (manual mode)
348 #/etc/rc.d/init.d/jserv stop
349 #/sbin/chkconfig --del jserv
352 # Find jserv related configuration settings and comment
356 cp -f %{httpdconf}/httpd.conf %{httpdconf}/httpd.conf.rpmorig
357 sed 's|.*\(Include.*%{jservconf}/jserv.conf\)|#\1|g' \
358 %{httpdconf}/httpd.conf.rpmorig \
359 | sed 's|^\(AddModule.*mod_jserv.c\)|#\1|g' \
360 | sed 's|^\(LoadModule.*mod_jserv.so\)|#\1|g' \
361 > %{httpdconf}/httpd.conf
363 /bin/rm -fr %{logdir}/mod_jserv.log
364 /bin/rm -fr %{logdir}/jserv.log
367 %defattr(644,root,root,755)
368 # mmh, we can't give %{_prefix}/docs to %doc ..
372 %config(noreplace) %verify(not md5 mtime size) %{jservconf}/jserv.properties
373 %config(noreplace) %verify(not md5 mtime size) %{jservconf}/zone.properties
374 %config(noreplace) %verify(not md5 mtime size) %{jservconf}/jserv.conf
376 # these are just for demonstration and thus,
377 # no %config-files per-se; do not install
378 # them for the RPM-packet
379 #%%{jservconf}/jserv.properties.default
380 #%%{jservconf}/zone.properties.default
381 #%%{jservconf}/jserv.conf.default
383 %attr(600,http,http) %{jservconf}/jserv.secret.key
384 #%config /etc/rc.d/init.d/jserv
385 #%attr(640,root,root) %config(noreplace) %verify(not size mtime md5) /etc/logrotate.d/jserv
386 #%config /etc/profile.d/jserv.sh
388 %attr(755,root,root) %{libexecdir}/mod_jserv.so
389 %{libexecdir}/ApacheJServ.jar
392 %{classesdir}/servlet-2.0.jar
396 %{servletdir}/Hello.java
397 %{servletdir}/Hello.class
398 %{servletdir}/IsItWorking.java
399 %{servletdir}/IsItWorking.class
402 # we need to have write access here
403 %attr(770,root,http) %dir %{logdir}