]> git.pld-linux.org Git - packages/ApacheJServ.git/blob - ApacheJServ.spec
- spec adapterized.
[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 19991120
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/%{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
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 %prep
46 rm -rf $RPM_BUILD_ROOT
47 %setup -q -a 1
48
49 %patch0
50 %patch1 -p1
51
52 # final position of GNU JSDK-Classes 
53 sed 's|@JSDK_CLASSES@|%{classesdir}/servlet-2.0.jar|g' \
54     < conf/jserv.properties.in  > conf/jserv.properties.in.new
55 mv conf/jserv.properties.in.new conf/jserv.properties.in
56
57 # do not load module in provided jserv.conf; we do this in httpd.conf
58 sed 's|@LOAD_OR_NOT@|#|g' \
59     < conf/jserv.conf.in  > conf/jserv.conf.in.new
60 mv conf/jserv.conf.in.new conf/jserv.conf.in
61
62 # prepare compilation
63 aclocal
64 autoconf
65 automake
66
67 %build
68 make -C classpathx_servlet-%{jsdkversion} jar_2_0
69 make -C classpathx_servlet-%{jsdkversion}/apidoc
70
71 # copy API-doc
72 mkdir jsdk-doc
73 cp classpathx_servlet-%{jsdkversion}/README \
74         classpathx_servlet-%{jsdkversion}/AUTHORS \
75         classpathx_servlet-%{jsdkversion}/COPYING.LIB \
76         jsdk-doc
77 cp -r classpathx_servlet-%{jsdkversion}/apidoc jsdk-doc
78
79 ### JSERV
80
81 # find apxs utility ..
82 # .. in PATH
83 APXS_UTIL=`type -p apxs || true`
84
85 # .. from RPM
86 if test "x$APXS_UTIL" = x ; then
87   # mmh, is it possible to query just for
88   # the executeables  (like -qd and -qc) ?
89   APXSMATCH=`rpm -ql apache-devel apache | grep apxs`
90   for f in $APXSMATCH ; do
91     if test -x "$f"  ; then
92        APXS_UTIL=$f
93        break
94     fi
95   done
96 fi
97
98 # .. at usual places
99 if test "x$APXS_UTIL" = x ; then
100    for loc in \
101     %{_bindir}               \
102     %{_sbindir}              \
103     %{_prefix}/local/apache/bin  \
104     %{_prefix}/local/apache/sbin \
105     %{_prefix}/local/httpd/bin   \
106     %{_prefix}/local/httpd/sbin 
107   do
108     if test -x "$loc/apxs" ; then
109        APXS_UTIL="$loc/apxs"
110        break
111     fi
112   done
113 fi
114
115 if test "x$APXS_UTIL" = x ; then
116    echo "Didn't find apxs .. exiting"
117    exit -1
118 fi
119
120 APXS_CFLAGS=`$APXS_UTIL -q CFLAGS`
121 CFLAGS="$APXS_CFLAGS $RPM_OPT_FLAGS" ./configure \
122         --prefix=%{_prefix}          \
123         --disable-debugging           \
124         --with-apxs=$APXS_UTIL        \
125         --with-logdir=%{logdir}       \
126         --with-servlets=%{servletdir} \
127         --with-JSDK=`pwd`/classpathx_servlet-%{jsdkversion}/servlet-2.0.jar
128 make
129
130 %install
131 rm -rf $RPM_BUILD_ROOT
132
133 make DESTDIR=$RPM_BUILD_ROOT install
134
135 echo "default - change on install `date`" > $RPM_BUILD_ROOT/%{jservconf}/jserv.secret.key
136 chmod 600 $RPM_BUILD_ROOT/%{jservconf}/jserv.secret.key
137
138 # currently disabled
139 #install -d $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d
140 #install -d $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
141 #install -d $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d
142 #install -m755 src/scripts/package/rpm/jserv.init      $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/jserv
143 #install -m755 src/scripts/package/rpm/jserv.sh        $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
144 #install -m644 src/scripts/package/rpm/jserv.logrotate $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/jserv
145
146 ### GNU JSDK-classes
147 install -d ${RPM_BUILD_ROOT}%{classesdir}
148 install classpathx_servlet-%{jsdkversion}/servlet-2.0.jar ${RPM_BUILD_ROOT}%{classesdir}
149
150 %clean
151 rm -rf $RPM_BUILD_ROOT
152
153 %post
154
155 # use fortune + install-date + process-list to create pseudo-random, hardly
156 # guessable secret key. Use md5sum to create a hash from this, if available:
157 (%{_prefix}/games/fortune 2>/dev/null ; date ; ps -eal 2>/dev/null)   \
158                     | (md5sum 2>/dev/null || cat)               \
159                     > %{jservconf}/jserv.secret.key 
160 chmod 600 %{jservconf}/jserv.secret.key
161
162 #
163 # determine apache-USER and chown the jserv.secrect.key - file
164 #
165 APACHEUSER=`grep "^User[         ]\+" %{httpdconf}/httpd.conf | awk '{print $2}'`
166 if test ! "x$APACHEUSER" = x ; then
167    USERCOMMENT="(which is '$APACHEUSER' ?)"
168 else
169    # assumption:        
170    APACHEUSER=nobody
171 fi
172 chown $APACHEUSER %{jservconf}/jserv.secret.key
173
174 #
175 # determine apache-GROUP and allow this group to write to %{logdir}
176 APACHEGROUP=`grep "^Group[       ]\+" %{httpdconf}/httpd.conf | awk '{print $2}'`
177 if test "x$APACHEGROUP" = x ; then
178    APACHEGROUP=nobody
179 fi
180 chgrp $APACHEGROUP %{logdir}
181 chmod g+w %{logdir}
182
183 #
184 # Add 'jserv' as an independent service (manual mode)
185 #/sbin/chkconfig --add jserv
186 #/etc/rc.d/init.d/jserv start
187
188 #
189 # Find Include Statement or add it if necessary
190 #
191 cp %{httpdconf}/httpd.conf %{httpdconf}/httpd.conf.rpmorig
192 grep '#\?.*[iI]nclude.*/jserv.conf' %{httpdconf}/httpd.conf \
193      >/dev/null
194 if test $? -eq 0 ; then
195    # found. Insert our include statement here
196    ## this depends on GNU-sed ('|') .. but we're on a RedHat system anyway
197    sed 's|^#\?\(.*Include\).*/jserv.conf.*$|\1 %{jservconf}/jserv.conf|g' \
198        < %{httpdconf}/httpd.conf.rpmorig                 \
199        > %{httpdconf}/httpd.conf
200 else
201    # append it
202    ( 
203      echo "<IfModule mod_jserv.c>"
204      echo "          Include %{jservconf}/jserv.conf"
205      echo "</IfModule>"
206    ) >> %{httpdconf}/httpd.conf
207 fi
208
209 #
210 # LoadModule; uncomment or insert
211 #
212 grep '#\?.*LoadModule.*jserv_module.*mod_jserv.so' %{httpdconf}/httpd.conf \
213      >/dev/null
214 if test $? -eq 0 ; then
215    # found. Remove any comment
216    sed 's|^#.*\(LoadModule.*mod_jserv.so\)|\1|g' \
217        < %{httpdconf}/httpd.conf                 \
218        > %{httpdconf}/httpd.conf.loadMod
219    mv %{httpdconf}/httpd.conf.loadMod %{httpdconf}/httpd.conf
220 else
221    # Insert LoadModule line before first valid LoadModule
222    ( echo "/^LoadModule"
223      echo "i"
224      echo "LoadModule jserv_module      modules/mod_jserv.so"
225      echo "."
226      echo "wq"
227    ) | ed %{httpdconf}/httpd.conf > /dev/null 2>&1
228 fi
229
230 #
231 # AddModule; uncomment or insert
232 #
233 grep '#\?.*AddModule.*mod_jserv.c' %{httpdconf}/httpd.conf >/dev/null
234 if test $? -eq 0  ; then
235    # found. Remove any comment
236    sed 's|^#.*\(AddModule.*mod_jserv.c\)|\1|g' \
237        < %{httpdconf}/httpd.conf               \
238        > %{httpdconf}/httpd.conf.addMod
239    mv %{httpdconf}/httpd.conf.addMod %{httpdconf}/httpd.conf
240 else
241    ( echo "/^AddModule"
242      echo "i"
243      echo "AddModule mod_jserv.c"
244      echo "."
245      echo "wq"
246    ) | ed %{httpdconf}/httpd.conf > /dev/null 2>&1
247 fi
248
249 #
250 # Search vor JAVA at possible locations and edit wrapper.bin
251 #
252 unset JAVABIN
253 for lookfor in java jre ; do
254   for loc in \
255     $JAVA_HOME            \
256     $JDK_HOME             \
257     /usr/local/java       \
258     /usr/local/jdk       \
259     /usr/local/jdk117_v3  \
260     /usr/local/jdk117_v1a
261   do
262     if test -x "$loc/bin/$lookfor" ; then
263        JAVABIN="$loc/bin/$lookfor"
264        break
265     fi
266   done
267
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"
274              break
275           fi
276         done
277         if test ! -z "$JAVABIN" ; then break ; fi
278       done
279       if test ! -z "$JAVABIN" ; then break ; fi
280     done
281   fi
282   if test ! -z "$JAVABIN" ; then break ; fi
283 done
284
285 if test ! -z "$JAVABIN" ; then
286    sed "s|^wrapper.bin=.*$|wrapper.bin=$JAVABIN|" \
287        < %{jservconf}/jserv.properties \
288        > %{jservconf}/jserv.properties.new
289    mv %{jservconf}/jserv.properties.new %{jservconf}/jserv.properties
290 fi
291
292 #
293 # Get Server Port to echo right URL below
294 #
295 SERVERPORT=`grep "^Port" %{httpdconf}/httpd.conf | \
296                         head -1 | awk '{print ":" $2}'`
297 if test "$SERVERPORT" = ":80" ; then
298         SERVERPORT=""
299 fi
300
301 #FIXME:         make this i18n-aware
302
303 if test ! "x$JAVABIN" = x ; then
304    echo "using java VM $JAVABIN"
305 else
306    echo "## didn't find java or jre. Please install it and edit the"
307    echo "## wrapper.bin property in %{jservconf}/jserv.properties"
308 fi
309 echo ""
310 echo "In order to enable JServ, restart the webserver and try"
311 echo "           http://localhost$SERVERPORT/servlets/IsItWorking"
312 echo "   and"
313 echo "           http://localhost$SERVERPORT/jserv/"
314 echo "-- ENJOY! --"
315 echo ""
316
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)."
327 echo ""
328
329 echo "Please send comments/suggestions regarding"
330 echo "this RPM to <zeller@to.com>."
331
332 %preun
333 # do not remove the configured stuff if we upgrade.
334 # the $1 argument contains the number of packages _after_ installation.
335 if [ ! $1 -eq 0 ] ; then
336    exit 0
337 fi
338
339 # Remove 'jserv' service (manual mode)
340 #/etc/rc.d/init.d/jserv stop
341 #/sbin/chkconfig --del jserv
342
343 #
344 # Find jserv related configuration settings and comment
345 # them out
346 #
347 cp %{httpdconf}/httpd.conf %{httpdconf}/httpd.conf.rpmorig
348 sed 's|.*\(Include.*%{jservconf}/jserv.conf\)|#\1|g' \
349     < %{httpdconf}/httpd.conf.rpmorig                \
350     | sed 's|^\(AddModule.*mod_jserv.c\)|#\1|g'      \
351     | sed 's|^\(LoadModule.*mod_jserv.so\)|#\1|g'    \
352     > %{httpdconf}/httpd.conf
353 # remove old logs
354 /bin/rm -fr %{logdir}/mod_jserv.log
355 /bin/rm -fr %{logdir}/jserv.log
356
357 %files
358 %defattr(644,root,root,755)
359 # mmh, we can't give %{_prefix}/docs to %doc ..
360 %doc index.html README docs jsdk-doc
361
362 %dir %{jservconf}
363 %config %{jservconf}/jserv.properties
364 %config %{jservconf}/zone.properties
365 %config %{jservconf}/jserv.conf
366
367 # these are just for demonstration and thus,
368 # no %config-files per-se; do not install
369 # them for the RPM-packet
370 #%{jservconf}/jserv.properties.default
371 #%{jservconf}/zone.properties.default
372 #%{jservconf}/jserv.conf.default
373
374 %attr(-,nobody,nobody) %{jservconf}/jserv.secret.key
375 #%config %{_sysconfdir}/rc.d/init.d/jserv
376 #%config %{_sysconfdir}/logrotate.d/jserv
377 #%config %{_sysconfdir}/profile.d/jserv.sh
378
379 %{libexecdir}/mod_jserv.so
380 %{libexecdir}/ApacheJServ.jar
381
382 %dir %{classesdir}
383 %{classesdir}/servlet-2.0.jar
384
385 %dir %{servletdir}
386 %{servletdir}/IsItWorking.java
387 %{servletdir}/IsItWorking.class
388
389 # we need to have write access here
390 %attr(-,nobody,-) %dir %{logdir}
This page took 1.411967 seconds and 3 git commands to generate.