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