]> git.pld-linux.org Git - packages/ApacheJServ.git/blob - ApacheJServ.spec
fixed classpathx_servlet URL
[packages/ApacheJServ.git] / ApacheJServ.spec
1 #%define libexecdir `apxs -q LIBEXECDIR`
2 %define libexecdir /usr/lib/apache
3
4 #%define httpdconf `apxs -q SYSCONFDIR`
5 %define httpdconf  /etc/httpd/conf
6
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 20000924
12
13 Summary:        Servlet engine with support for the leading web server
14 Name:           ApacheJServ
15 Version:        1.1
16 Release:        3
17 Source0:        http://java.apache.org/jserv/dist/%{name}-%{version}.tar.gz
18 Source1:        http://www.euronet.nl/~pauls/java/servlet/download/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
25 Requires:       apache >= 1.3.6
26 Provides:       jserv jsdk20
27 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
28
29 #BuildRequires: any-java-compiler
30
31 BuildRequires:  automake     >= 1.4
32 BuildRequires:  autoconf     >= 2.13
33 BuildRequires:  libtool      >= 1.3.3 
34 BuildRequires:  apache-devel >= 1.3.9-8
35
36 %description
37 Apache JServ is a servlet engine, developed by the Java Apache Project
38 <http://java.apache.org/>. The Apache JServ servlet engine is written
39 in 100pc Java application, and listens for servlet requests using the
40 Apache Java protocol (AJp). Typically, these requests will originate
41 from the mod_jserv Apache module (DSO included). This package contains
42 a LGPL'ed implementation of sun's java servlet api version 2.0 by Paul
43 Siegmann <http://www.euronet.nl/~pauls/java/servlet/>
44
45 %description -l pl
46 Apache JServ jest silnikiem serwletowym, rozwijanym przez Java Apache Project
47 <http://java.apache.org/>. Silnik serwletowy Apache JServ zosta³ napisany
48 od pocz±tku do koñca w Javie; nas³uchuje wywo³añ serwletu wykorzystuj±c
49 protokó³ Apache Java (AJp). Zazwyczaj wywo³ania te pochodz± z modu³u
50 Apache mod_jservmodule (³±cznie z DSO). Pakiet ten zawiera sunowsk±
51 implementacjê api serletów w javie w wersji 2.0 (na licencji LGPL)
52 napisana przez Paula Siegmanna <http://www.euronet.nl/~pauls/java/servlet/>
53
54 %prep
55 rm -rf $RPM_BUILD_ROOT
56 %setup -q -a 1
57
58 %patch0
59 %patch1 -p1
60
61 # final position of GNU JSDK-Classes 
62 sed 's|@JSDK_CLASSES@|%{classesdir}/servlet-2.0.jar|g' \
63     < conf/jserv.properties.in  > conf/jserv.properties.in.new
64 mv conf/jserv.properties.in.new conf/jserv.properties.in
65
66 # do not load module in provided jserv.conf; we do this in httpd.conf
67 sed 's|@LOAD_OR_NOT@|#|g' \
68     < conf/jserv.conf.in  > conf/jserv.conf.in.new
69 mv conf/jserv.conf.in.new conf/jserv.conf.in
70
71 # prepare compilation
72 aclocal
73 autoconf
74 automake
75
76 %build
77 %{__make} -C classpathx_servlet-%{jsdkversion} jar_2_0
78 %{__make} -C classpathx_servlet-%{jsdkversion}/apidoc
79
80 # copy API-doc
81 mkdir jsdk-doc
82 cp classpathx_servlet-%{jsdkversion}/README \
83         classpathx_servlet-%{jsdkversion}/AUTHORS \
84         classpathx_servlet-%{jsdkversion}/COPYING.LIB \
85         jsdk-doc
86 cp -r classpathx_servlet-%{jsdkversion}/apidoc jsdk-doc
87
88 ### JSERV
89
90 # find apxs utility ..
91 # .. in PATH
92 APXS_UTIL=`type -p apxs || true`
93
94 # .. from RPM
95 if test "x$APXS_UTIL" = x ; then
96   # mmh, is it possible to query just for
97   # the executeables  (like -qd and -qc) ?
98   APXSMATCH=`rpm -ql apache-devel apache | grep apxs`
99   for f in $APXSMATCH ; do
100     if test -x "$f"  ; then
101        APXS_UTIL=$f
102        break
103     fi
104   done
105 fi
106
107 # .. at usual places
108 if test "x$APXS_UTIL" = x ; then
109    for loc in \
110     %{_bindir}               \
111     %{_sbindir}              \
112     %{_prefix}/local/apache/bin  \
113     %{_prefix}/local/apache/sbin \
114     %{_prefix}/local/httpd/bin   \
115     %{_prefix}/local/httpd/sbin 
116   do
117     if test -x "$loc/apxs" ; then
118        APXS_UTIL="$loc/apxs"
119        break
120     fi
121   done
122 fi
123
124 if test "x$APXS_UTIL" = x ; then
125    echo "Didn't find apxs .. exiting"
126    exit -1
127 fi
128
129 APXS_CFLAGS=`$APXS_UTIL -q CFLAGS`
130 CFLAGS="$APXS_CFLAGS $RPM_OPT_FLAGS" ./configure \
131         --prefix=%{_prefix}          \
132         --disable-debugging           \
133         --with-apxs=$APXS_UTIL        \
134         --with-logdir=%{logdir}       \
135         --with-servlets=%{servletdir} \
136         --with-JSDK=`pwd`/classpathx_servlet-%{jsdkversion}/servlet-2.0.jar
137 %{__make}
138
139 %install
140 rm -rf $RPM_BUILD_ROOT
141
142 %{__make} DESTDIR=$RPM_BUILD_ROOT install
143
144 echo "default - change on install `date`" > $RPM_BUILD_ROOT/%{jservconf}/jserv.secret.key
145 chmod 600 $RPM_BUILD_ROOT/%{jservconf}/jserv.secret.key
146
147 # currently disabled
148 #install -d $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d
149 #install -d $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
150 #install -d $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d
151 #install -m755 src/scripts/package/rpm/jserv.init      $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/jserv
152 #install -m755 src/scripts/package/rpm/jserv.sh        $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
153 #install -m644 src/scripts/package/rpm/jserv.logrotate $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/jserv
154
155 ### GNU JSDK-classes
156 install -d ${RPM_BUILD_ROOT}%{classesdir}
157 install classpathx_servlet-%{jsdkversion}/servlet-2.0.jar ${RPM_BUILD_ROOT}%{classesdir}
158
159 %clean
160 rm -rf $RPM_BUILD_ROOT
161
162 %post
163
164 # use fortune + install-date + process-list to create pseudo-random, hardly
165 # guessable secret key. Use md5sum to create a hash from this, if available:
166 (%{_prefix}/games/fortune 2>/dev/null ; date ; ps -eal 2>/dev/null)   \
167                     | (md5sum 2>/dev/null || cat)               \
168                     > %{jservconf}/jserv.secret.key 
169 chmod 600 %{jservconf}/jserv.secret.key
170
171 #
172 # determine apache-USER and chown the jserv.secrect.key - file
173 #
174 APACHEUSER=`grep "^User[         ]\+" %{httpdconf}/httpd.conf | awk '{print $2}'`
175 if test ! "x$APACHEUSER" = x ; then
176    USERCOMMENT="(which is '$APACHEUSER' ?)"
177 else
178    # assumption:        
179    APACHEUSER=nobody
180 fi
181 chown $APACHEUSER %{jservconf}/jserv.secret.key
182
183 #
184 # determine apache-GROUP and allow this group to write to %{logdir}
185 APACHEGROUP=`grep "^Group[       ]\+" %{httpdconf}/httpd.conf | awk '{print $2}'`
186 if test "x$APACHEGROUP" = x ; then
187    APACHEGROUP=nobody
188 fi
189 chgrp $APACHEGROUP %{logdir}
190 chmod g+w %{logdir}
191
192 #
193 # Add 'jserv' as an independent service (manual mode)
194 #/sbin/chkconfig --add jserv
195 #/etc/rc.d/init.d/jserv start
196
197 #
198 # Find Include Statement or add it if necessary
199 #
200 cp %{httpdconf}/httpd.conf %{httpdconf}/httpd.conf.rpmorig
201 grep '#\?.*[iI]nclude.*/jserv.conf' %{httpdconf}/httpd.conf \
202      >/dev/null
203 if test $? -eq 0 ; then
204    # found. Insert our include statement here
205    ## this depends on GNU-sed ('|') .. but we're on a RedHat system anyway
206    sed 's|^#\?\(.*Include\).*/jserv.conf.*$|\1 %{jservconf}/jserv.conf|g' \
207        < %{httpdconf}/httpd.conf.rpmorig                 \
208        > %{httpdconf}/httpd.conf
209 else
210    # append it
211    ( 
212      echo "<IfModule mod_jserv.c>"
213      echo "          Include %{jservconf}/jserv.conf"
214      echo "</IfModule>"
215    ) >> %{httpdconf}/httpd.conf
216 fi
217
218 #
219 # LoadModule; uncomment or insert
220 #
221 grep '#\?.*LoadModule.*jserv_module.*mod_jserv.so' %{httpdconf}/httpd.conf \
222      >/dev/null
223 if test $? -eq 0 ; then
224    # found. Remove any comment
225    sed 's|^#.*\(LoadModule.*mod_jserv.so\)|\1|g' \
226        < %{httpdconf}/httpd.conf                 \
227        > %{httpdconf}/httpd.conf.loadMod
228    mv %{httpdconf}/httpd.conf.loadMod %{httpdconf}/httpd.conf
229 else
230    # Insert LoadModule line before first valid LoadModule
231    ( echo "/^LoadModule"
232      echo "i"
233      echo "LoadModule jserv_module      modules/mod_jserv.so"
234      echo "."
235      echo "wq"
236    ) | ed %{httpdconf}/httpd.conf > /dev/null 2>&1
237 fi
238
239 #
240 # AddModule; uncomment or insert
241 #
242 grep '#\?.*AddModule.*mod_jserv.c' %{httpdconf}/httpd.conf >/dev/null
243 if test $? -eq 0  ; then
244    # found. Remove any comment
245    sed 's|^#.*\(AddModule.*mod_jserv.c\)|\1|g' \
246        < %{httpdconf}/httpd.conf               \
247        > %{httpdconf}/httpd.conf.addMod
248    mv %{httpdconf}/httpd.conf.addMod %{httpdconf}/httpd.conf
249 else
250    ( echo "/^AddModule"
251      echo "i"
252      echo "AddModule mod_jserv.c"
253      echo "."
254      echo "wq"
255    ) | ed %{httpdconf}/httpd.conf > /dev/null 2>&1
256 fi
257
258 #
259 # Search vor JAVA at possible locations and edit wrapper.bin
260 #
261 unset JAVABIN
262 for lookfor in java jre ; do
263   for loc in \
264     $JAVA_HOME            \
265     $JDK_HOME             \
266     /usr/local/java       \
267     /usr/local/jdk       \
268     /usr/local/jdk117_v3  \
269     /usr/local/jdk117_v1a
270   do
271     if test -x "$loc/bin/$lookfor" ; then
272        JAVABIN="$loc/bin/$lookfor"
273        break
274     fi
275   done
276
277   if test -z "$JAVABIN" ; then
278     for prefix in /usr/jdk /usr/jdk- /usr/local/jdk /usr/local/jdk- ; do
279       for jplatform in 2 1 ; do
280         for subvers in .9 .8 .7 .6 .5 .4 .3 .2 .1 "" ; do
281           if test -x "${prefix}1.$jplatform$subvers/bin/$lookfor" ; then
282              JAVABIN="${prefix}1.$jplatform$subvers/bin/$lookfor"
283              break
284           fi
285         done
286         if test ! -z "$JAVABIN" ; then break ; fi
287       done
288       if test ! -z "$JAVABIN" ; then break ; fi
289     done
290   fi
291   if test ! -z "$JAVABIN" ; then break ; fi
292 done
293
294 if test ! -z "$JAVABIN" ; then
295    sed "s|^wrapper.bin=.*$|wrapper.bin=$JAVABIN|" \
296        < %{jservconf}/jserv.properties \
297        > %{jservconf}/jserv.properties.new
298    mv %{jservconf}/jserv.properties.new %{jservconf}/jserv.properties
299 fi
300
301 #
302 # Get Server Port to echo right URL below
303 #
304 SERVERPORT=`grep "^Port" %{httpdconf}/httpd.conf | \
305                         head -1 | awk '{print ":" $2}'`
306 if test "$SERVERPORT" = ":80" ; then
307         SERVERPORT=""
308 fi
309
310 #FIXME:         make this i18n-aware
311
312 if test ! "x$JAVABIN" = x ; then
313    echo "using java VM $JAVABIN"
314 else
315    echo "## didn't find java or jre. Please install it and edit the"
316    echo "## wrapper.bin property in %{jservconf}/jserv.properties"
317 fi
318 echo ""
319 echo "In order to enable JServ, restart the webserver and try"
320 echo "           http://localhost$SERVERPORT/servlets/IsItWorking"
321 echo "   and"
322 echo "           http://localhost$SERVERPORT/jserv/"
323 echo "-- ENJOY! --"
324 echo ""
325
326 ## we hopefully may distribute SUN-jsdk.jar with jserv once ..
327 echo " | NOTE that this distribution contains a fully functional"
328 echo " | free jsdk replacement, see <http://www.euronet.nl/~pauls/java/servlet/>."
329 echo " | If you want to use the SUN-jsdk, replace the servlet-2.0.jar"
330 echo " | in the wrapper.classpath - line in the file"
331 echo " |                 %{jservconf}/jserv.properties"
332 echo " | with the SUN jsdk."
333 echo " | Get it from <http://java.sun.com/products/servlet/>."
334 echo " | Only JSDK 2.0 (Java Servlet Development Kit)"
335 echo " | is supported (_EXACTLY_ 2.0)."
336 echo ""
337
338 echo "Please send comments/suggestions regarding"
339 echo "this RPM to <zeller@to.com>."
340
341 %preun
342 # do not remove the configured stuff if we upgrade.
343 # the $1 argument contains the number of packages _after_ installation.
344 if [ ! $1 -eq 0 ] ; then
345    exit 0
346 fi
347
348 # Remove 'jserv' service (manual mode)
349 #/etc/rc.d/init.d/jserv stop
350 #/sbin/chkconfig --del jserv
351
352 #
353 # Find jserv related configuration settings and comment
354 # them out
355 #
356 cp %{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
362 # remove old logs
363 /bin/rm -fr %{logdir}/mod_jserv.log
364 /bin/rm -fr %{logdir}/jserv.log
365
366 %files
367 %defattr(644,root,root,755)
368 # mmh, we can't give %{_prefix}/docs to %doc ..
369 %doc index.html README docs jsdk-doc
370
371 %dir %{jservconf}
372 %config %{jservconf}/jserv.properties
373 %config %{jservconf}/zone.properties
374 %config %{jservconf}/jserv.conf
375
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
382
383 %attr(-,nobody,nobody) %{jservconf}/jserv.secret.key
384 #%config %{_sysconfdir}/rc.d/init.d/jserv
385 #%config %{_sysconfdir}/logrotate.d/jserv
386 #%config %{_sysconfdir}/profile.d/jserv.sh
387
388 %{libexecdir}/mod_jserv.so
389 %{libexecdir}/ApacheJServ.jar
390
391 %dir %{classesdir}
392 %{classesdir}/servlet-2.0.jar
393
394 %dir %{servletdir}
395 %{servletdir}/IsItWorking.java
396 %{servletdir}/IsItWorking.class
397
398 # we need to have write access here
399 %attr(-,nobody,-) %dir %{logdir}
This page took 0.080997 seconds and 3 git commands to generate.