]> git.pld-linux.org Git - packages/ApacheJServ.git/blob - ApacheJServ.spec
ac5e669c31ad4c6a60461c3c4288a2003e0edb4f
[packages/ApacheJServ.git] / ApacheJServ.spec
1 %define myprefix        /usr
2
3 # we should determine these places with apxs..
4 # it would be nice to do this at install-time
5 # as well in order to dynamically 'relocate' the package.
6 # .. but I think we've to wait for a new RPM to make this happen
7 ##
8
9 ## unfortuatly, we don't know the location of the apxs-binary yet .. and
10 ## it may not be in the path which will make the build fail (can
11 ## we set defines conditionally ?)
12
13 #%define libexecdir `apxs -q LIBEXECDIR`
14 %define libexecdir /usr/lib/apache
15
16 #%define httpdconf `apxs -q SYSCONFDIR`
17 %define httpdconf  /etc/httpd/conf
18
19 %define jservconf  %{httpdconf}/jserv
20 %define logdir     /var/log/httpd
21 %define servletdir /home/httpd/servlets
22 %define classesdir /home/httpd/classes
23 %define jsdkversion 19991120
24
25 Source:         %{name}-%{version}.tar.gz
26 Source1:        http://www.euronet.nl/~pauls/java/servlet/download/classpathx_servlet-%{jsdkversion}.tar.gz
27 Patch0:         jserv-enable-secret.patch
28 Patch1:         ApacheJServ-1.1-megaloman.patch
29
30 Summary:        Servlet engine with support for the leading web server
31 Name:           ApacheJServ
32 Version:        1.1
33 Release:        3
34 URL:            http://java.apache.org/
35 Copyright:      Freely distributable & usable
36 Group:          Networking/Daemons
37 Packager:       Henner Zeller <zeller@to.com>
38 Docdir:         %{myprefix}/doc
39 Requires:       apache >= 1.3.6
40 Provides:       jserv jsdk20
41 BuildRoot:      /var/tmp/%{name}-%{version}-root
42 Prefix:         %{myprefix}
43
44 #BuildRequires: any-java-compiler
45
46 BuildRequires:  automake     >= 1.4
47 BuildRequires:  autoconf     >= 2.13
48 BuildRequires:  libtool      >= 1.3.3 
49
50 ## Building this package depending on standard RPM packages
51 ## requires the apxs utility to be there, located in the apache-devel package.
52 ## Because the RH 6.1 1.3.9-4 version has a bug, we need a newer package.
53 ## Comment this out if you want to build this SRC-RPM on your personal
54 ## installation of apache (and thus, apxs).
55 ## (dunno, at which particular release this was fixed .. -4 was faulty and
56 ##  -8 works)
57 BuildRequires:  apache-devel >= 1.3.9-8
58
59 %description
60 Apache JServ is a servlet engine, developed by the 
61 Java Apache Project <http://java.apache.org/>.
62
63 The Apache JServ servlet engine is written in 100pc Java application, and 
64 listens for servlet requests using the Apache Java protocol (AJp). Typically, 
65 these requests will originate from the mod_jserv Apache module (DSO included).
66
67 This package contains a LGPL'ed implementation of sun's java servlet api 
68 version 2.0 by Paul Siegmann <http://www.euronet.nl/~pauls/java/servlet/>
69
70 %prep
71 rm -rf $RPM_BUILD_ROOT
72 %setup -a 1 -n %{name}-%{version}
73
74 # enable socket authentification
75 %patch0
76 %patch1 -p1
77
78 # final position of GNU JSDK-Classes 
79 sed 's|@JSDK_CLASSES@|%{classesdir}/servlet-2.0.jar|g' \
80     < conf/jserv.properties.in  > conf/jserv.properties.in.new
81 mv conf/jserv.properties.in.new conf/jserv.properties.in
82
83 # do not load module in provided jserv.conf; we do this in httpd.conf
84 sed 's|@LOAD_OR_NOT@|#|g' \
85     < conf/jserv.conf.in  > conf/jserv.conf.in.new
86 mv conf/jserv.conf.in.new conf/jserv.conf.in
87
88 # prepare compilation
89 aclocal
90 autoconf
91 automake
92
93 %build
94
95 ### jsdk API
96 make -C classpathx_servlet-%{jsdkversion} jar_2_0
97 make -C classpathx_servlet-%{jsdkversion}/apidoc
98
99 # copy API-doc
100 mkdir jsdk-doc
101 cp classpathx_servlet-%{jsdkversion}/README \
102         classpathx_servlet-%{jsdkversion}/AUTHORS \
103         classpathx_servlet-%{jsdkversion}/COPYING.LIB \
104         jsdk-doc
105 cp -r classpathx_servlet-%{jsdkversion}/apidoc jsdk-doc
106
107
108 ### JSERV
109
110 # find apxs utility ..
111 # .. in PATH
112 APXS_UTIL=`type -p apxs || true`
113
114 # .. from RPM
115 if test "x$APXS_UTIL" = x ; then
116   # mmh, is it possible to query just for
117   # the executeables  (like -qd and -qc) ?
118   APXSMATCH=`rpm -ql apache-devel apache | grep apxs`
119   for f in $APXSMATCH ; do
120     if test -x "$f"  ; then
121        APXS_UTIL=$f
122        break
123     fi
124   done
125 fi
126
127 # .. at usual places
128 if test "x$APXS_UTIL" = x ; then
129    for loc in \
130     /usr/bin               \
131     /usr/sbin              \
132     /usr/local/apache/bin  \
133     /usr/local/apache/sbin \
134     /usr/local/httpd/bin   \
135     /usr/local/httpd/sbin 
136   do
137     if test -x "$loc/apxs" ; then
138        APXS_UTIL="$loc/apxs"
139        break
140     fi
141   done
142 fi
143
144 if test "x$APXS_UTIL" = x ; then
145    echo "Didn't find apxs .. exiting"
146    exit -1
147 fi
148
149 APXS_CFLAGS=`$APXS_UTIL -q CFLAGS`
150 CFLAGS="$APXS_CFLAGS $RPM_OPT_FLAGS" ./configure \
151         --prefix=%{myprefix}          \
152         --disable-debugging           \
153         --with-apxs=$APXS_UTIL        \
154         --with-logdir=%{logdir}       \
155         --with-servlets=%{servletdir} \
156         --with-JSDK=`pwd`/classpathx_servlet-%{jsdkversion}/servlet-2.0.jar
157 make
158
159 %install
160 make DESTDIR=$RPM_BUILD_ROOT install
161
162 echo "default - change on install `date`" > $RPM_BUILD_ROOT/%{jservconf}/jserv.secret.key
163 chmod 600 $RPM_BUILD_ROOT/%{jservconf}/jserv.secret.key
164
165 # currently disabled
166 #install -d $RPM_BUILD_ROOT/etc/rc.d/init.d
167 #install -d $RPM_BUILD_ROOT/etc/profile.d
168 #install -d $RPM_BUILD_ROOT/etc/logrotate.d
169 #install -m755 src/scripts/package/rpm/jserv.init      $RPM_BUILD_ROOT/etc/rc.d/init.d/jserv
170 #install -m755 src/scripts/package/rpm/jserv.sh        $RPM_BUILD_ROOT/etc/profile.d
171 #install -m644 src/scripts/package/rpm/jserv.logrotate $RPM_BUILD_ROOT/etc/logrotate.d/jserv
172
173 ### GNU JSDK-classes
174 install -d ${RPM_BUILD_ROOT}%{classesdir}
175 install classpathx_servlet-%{jsdkversion}/servlet-2.0.jar ${RPM_BUILD_ROOT}%{classesdir}
176
177 %clean
178 rm -rf $RPM_BUILD_ROOT
179
180 %post
181
182 # use fortune + install-date + process-list to create pseudo-random, hardly
183 # guessable secret key. Use md5sum to create a hash from this, if available:
184 (/usr/games/fortune 2>/dev/null ; date ; ps -eal 2>/dev/null)   \
185                     | (md5sum 2>/dev/null || cat)               \
186                     > %{jservconf}/jserv.secret.key 
187 chmod 600 %{jservconf}/jserv.secret.key
188
189 #
190 # determine apache-USER and chown the jserv.secrect.key - file
191 #
192 APACHEUSER=`grep "^User[         ]\+" %{httpdconf}/httpd.conf | awk '{print $2}'`
193 if test ! "x$APACHEUSER" = x ; then
194    USERCOMMENT="(which is '$APACHEUSER' ?)"
195 else
196    # assumption:
197    APACHEUSER=nobody
198 fi
199 chown $APACHEUSER %{jservconf}/jserv.secret.key
200
201 #
202 # determine apache-GROUP and allow this group to write to %{logdir}
203 APACHEGROUP=`grep "^Group[       ]\+" %{httpdconf}/httpd.conf | awk '{print $2}'`
204 if test "x$APACHEGROUP" = x ; then
205    APACHEGROUP=nobody
206 fi
207 chgrp $APACHEGROUP %{logdir}
208 chmod g+w %{logdir}
209
210 #
211 # Add 'jserv' as an independent service (manual mode)
212 #/sbin/chkconfig --add jserv
213 #/etc/rc.d/init.d/jserv start
214
215 #
216 # Find Include Statement or add it if necessary
217 #
218 cp %{httpdconf}/httpd.conf %{httpdconf}/httpd.conf.rpmorig
219 grep '#\?.*[iI]nclude.*/jserv.conf' %{httpdconf}/httpd.conf \
220      >/dev/null
221 if test $? -eq 0 ; then
222    # found. Insert our include statement here
223    ## this depends on GNU-sed ('|') .. but we're on a RedHat system anyway
224    sed 's|^#\?\(.*Include\).*/jserv.conf.*$|\1 %{jservconf}/jserv.conf|g' \
225        < %{httpdconf}/httpd.conf.rpmorig                 \
226        > %{httpdconf}/httpd.conf
227 else
228    # append it
229    ( 
230      echo "<IfModule mod_jserv.c>"
231      echo "          Include %{jservconf}/jserv.conf"
232      echo "</IfModule>"
233    ) >> %{httpdconf}/httpd.conf
234 fi
235
236 #
237 # LoadModule; uncomment or insert
238 #
239 grep '#\?.*LoadModule.*jserv_module.*mod_jserv.so' %{httpdconf}/httpd.conf \
240      >/dev/null
241 if test $? -eq 0 ; then
242    # found. Remove any comment
243    sed 's|^#.*\(LoadModule.*mod_jserv.so\)|\1|g' \
244        < %{httpdconf}/httpd.conf                 \
245        > %{httpdconf}/httpd.conf.loadMod
246    mv %{httpdconf}/httpd.conf.loadMod %{httpdconf}/httpd.conf
247 else
248    # Insert LoadModule line before first valid LoadModule
249    ( echo "/^LoadModule"
250      echo "i"
251      echo "LoadModule jserv_module      modules/mod_jserv.so"
252      echo "."
253      echo "wq"
254    ) | ed %{httpdconf}/httpd.conf > /dev/null 2>&1
255 fi
256
257 #
258 # AddModule; uncomment or insert
259 #
260 grep '#\?.*AddModule.*mod_jserv.c' %{httpdconf}/httpd.conf >/dev/null
261 if test $? -eq 0  ; then
262    # found. Remove any comment
263    sed 's|^#.*\(AddModule.*mod_jserv.c\)|\1|g' \
264        < %{httpdconf}/httpd.conf               \
265        > %{httpdconf}/httpd.conf.addMod
266    mv %{httpdconf}/httpd.conf.addMod %{httpdconf}/httpd.conf
267 else
268    ( echo "/^AddModule"
269      echo "i"
270      echo "AddModule mod_jserv.c"
271      echo "."
272      echo "wq"
273    ) | ed %{httpdconf}/httpd.conf > /dev/null 2>&1
274 fi
275
276 #
277 # Search vor JAVA at possible locations and edit wrapper.bin
278 #
279 unset JAVABIN
280 for lookfor in java jre ; do
281   for loc in \
282     $JAVA_HOME            \
283     $JDK_HOME             \
284     /usr/local/java       \
285     /usr/local/jdk       \
286     /usr/local/jdk117_v3  \
287     /usr/local/jdk117_v1a
288   do
289     if test -x "$loc/bin/$lookfor" ; then
290        JAVABIN="$loc/bin/$lookfor"
291        break
292     fi
293   done
294
295   if test -z "$JAVABIN" ; then
296     for prefix in /usr/jdk /usr/jdk- /usr/local/jdk /usr/local/jdk- ; do
297       for jplatform in 2 1 ; do
298         for subvers in .9 .8 .7 .6 .5 .4 .3 .2 .1 "" ; do
299           if test -x "${prefix}1.$jplatform$subvers/bin/$lookfor" ; then
300              JAVABIN="${prefix}1.$jplatform$subvers/bin/$lookfor"
301              break
302           fi
303         done
304         if test ! -z "$JAVABIN" ; then break ; fi
305       done
306       if test ! -z "$JAVABIN" ; then break ; fi
307     done
308   fi
309   if test ! -z "$JAVABIN" ; then break ; fi
310 done
311
312 if test ! -z "$JAVABIN" ; then
313    sed "s|^wrapper.bin=.*$|wrapper.bin=$JAVABIN|" \
314        < %{jservconf}/jserv.properties \
315        > %{jservconf}/jserv.properties.new
316    mv %{jservconf}/jserv.properties.new %{jservconf}/jserv.properties
317 fi
318
319 #
320 # Get Server Port to echo right URL below
321 #
322 SERVERPORT=`grep "^Port" %{httpdconf}/httpd.conf | \
323                         head -1 | awk '{print ":" $2}'`
324 if test "$SERVERPORT" = ":80" ; then
325         SERVERPORT=""
326 fi
327
328 #FIXME: make this i18n-aware
329
330 if test ! "x$JAVABIN" = x ; then
331    echo "using java VM $JAVABIN"
332 else
333    echo "## didn't find java or jre. Please install it and edit the"
334    echo "## wrapper.bin property in %{jservconf}/jserv.properties"
335 fi
336 echo ""
337 echo "In order to enable JServ, restart the webserver and try"
338 echo "           http://localhost$SERVERPORT/servlets/IsItWorking"
339 echo "   and"
340 echo "           http://localhost$SERVERPORT/jserv/"
341 echo "-- ENJOY! --"
342 echo ""
343
344 ## we hopefully may distribute SUN-jsdk.jar with jserv once ..
345 echo " | NOTE that this distribution contains a fully functional"
346 echo " | free jsdk replacement, see <http://www.euronet.nl/~pauls/java/servlet/>."
347 echo " | If you want to use the SUN-jsdk, replace the servlet-2.0.jar"
348 echo " | in the wrapper.classpath - line in the file"
349 echo " |                 %{jservconf}/jserv.properties"
350 echo " | with the SUN jsdk."
351 echo " | Get it from <http://java.sun.com/products/servlet/>."
352 echo " | Only JSDK 2.0 (Java Servlet Development Kit)"
353 echo " | is supported (_EXACTLY_ 2.0)."
354 echo ""
355
356 echo "Please send comments/suggestions regarding"
357 echo "this RPM to <zeller@to.com>."
358
359
360 %preun
361 # do not remove the configured stuff if we upgrade.
362 # the $1 argument contains the number of packages _after_ installation.
363 if [ ! $1 -eq 0 ] ; then
364    exit 0
365 fi
366
367 # Remove 'jserv' service (manual mode)
368 #/etc/rc.d/init.d/jserv stop
369 #/sbin/chkconfig --del jserv
370
371 #
372 # Find jserv related configuration settings and comment
373 # them out
374 #
375 cp %{httpdconf}/httpd.conf %{httpdconf}/httpd.conf.rpmorig
376 sed 's|.*\(Include.*%{jservconf}/jserv.conf\)|#\1|g' \
377     < %{httpdconf}/httpd.conf.rpmorig                \
378     | sed 's|^\(AddModule.*mod_jserv.c\)|#\1|g'      \
379     | sed 's|^\(LoadModule.*mod_jserv.so\)|#\1|g'    \
380     > %{httpdconf}/httpd.conf
381 # remove old logs
382 /bin/rm -fr %{logdir}/mod_jserv.log
383 /bin/rm -fr %{logdir}/jserv.log
384
385 %files
386 %defattr(-,root,root)
387 # mmh, we can't give %{prefix}/docs to %doc ..
388 %doc index.html README docs jsdk-doc
389
390 %dir %{jservconf}
391 %config %{jservconf}/jserv.properties
392 %config %{jservconf}/zone.properties
393 %config %{jservconf}/jserv.conf
394
395 # these are just for demonstration and thus,
396 # no %config-files per-se; do not install
397 # them for the RPM-packet
398 #%{jservconf}/jserv.properties.default
399 #%{jservconf}/zone.properties.default
400 #%{jservconf}/jserv.conf.default
401
402 %attr(-,nobody,nobody) %{jservconf}/jserv.secret.key
403 #%config /etc/rc.d/init.d/jserv
404 #%config /etc/logrotate.d/jserv
405 #%config /etc/profile.d/jserv.sh
406
407 %{libexecdir}/mod_jserv.so
408 %{libexecdir}/ApacheJServ.jar
409
410 %dir %{classesdir}
411 %{classesdir}/servlet-2.0.jar
412
413 %dir %{servletdir}
414 %{servletdir}/IsItWorking.java
415 %{servletdir}/IsItWorking.class
416
417 # we need to have write access here
418 %attr(-,nobody,-) %dir %{logdir}
419
420 %changelog
421 * Sun Feb 13 2000 Peter Hanecak <hanecak@megaloman.sk>
422 - used 'APXS_CFLAGS=`$APXS_UTIL -q CFLAGS`' and
423   'CFLAGS="$APXS_CFLAGS $RPM_OPT_FLAGS"' to determine build flags
424   (because of EAPI)
425
426 * Tue Feb  8 2000 Peter Hanecak <hanecak@megaloman.sk>
427 - RPM_OPT_FLAGS passed to CFLAGS
428 - build root changed from '/tmp/...' to '/var/tmp/...'
429 - install process fixed for 'docs/api'
430
431 * Tue Dec 28 1999 HZ <zeller@to.com>
432  - use BuildRequires to reflect the need for current
433    versions of the autoconf/automake suite and a
434    recent apache-devel because of a bug in older
435    versions of this package.
436
437 * Thu Sep 30 1999 HZ <zeller@to.com>
438  - Release of 1.1 Beta 1
439
440 * Wed Sep 29 1999 Henner Zeller <zeller@to.com>
441  - new build scheme (1.1)
442
443 * Sun Sep 19 1999 Henner Zeller <zeller@to.com>
444  - make it work with the apache-1.3.9 RPM
445  - use 'test' instead of '[ ]' in conditionals
446  - look for java virtual machine and edit jserv.properties' wrapper.bin
447
448 * Fri Sep 17 1999 Henner Zeller <zeller@to.com>
449  - added LGPL'ed servlet DK by Paul Siegmann
450
451 * Wed Aug 18 1999 Henner Zeller <zeller@to.com>
452  - edit httpd.conf automatically
453
454 * Sat Jul 24 1999 Henner Zeller <zeller@to.com>
455  - update to install JServ 1.0.*
456
457 * Thu Nov 05 1998 Ross Golder <rossigee@bigfoot.com>
458 - updated to use the autoconf build system
459
460 * Mon Oct 19 1998 Ross Golder <rossg@cpd.co.uk>
461 - created from previous work to deploy daily snapshot RPMs
This page took 0.045004 seconds and 2 git commands to generate.