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