]> git.pld-linux.org Git - packages/ApacheJServ.git/blame - ApacheJServ.spec
- partialy rewrited.
[packages/ApacheJServ.git] / ApacheJServ.spec
CommitLineData
0464d88f 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
0464d88f 13Summary: Servlet engine with support for the leading web server
14Name: ApacheJServ
15Version: 1.1
16Release: 3
20a63901 17Source0: http://java.apache.org/jserv/dist/%{name}-%{version}.tar.gz
18Source1: http://www.euronet.nl/~pauls/java/servlet/download/%{version}%{name}classpathx_servlet-%{jsdkversion}.tar.gz
19Patch0: ApacheJServ-enable-secret.patch
20Patch1: ApacheJServ-DESTDIR.patch
0464d88f 21URL: http://java.apache.org/
22Copyright: Freely distributable & usable
23Group: Networking/Daemons
20a63901 24Group(pl): Sieciowe/Serwery
25Docdir: %{prefix}/doc
0464d88f 26Requires: apache >= 1.3.6
27Provides: jserv jsdk20
20a63901 28BuildRoot: /tmp/%{name}-%{version}-root
0464d88f 29
20a63901 30#BuildRequires: any-java-compiler
0464d88f 31
32BuildRequires: automake >= 1.4
33BuildRequires: autoconf >= 2.13
34BuildRequires: libtool >= 1.3.3
0464d88f 35BuildRequires: apache-devel >= 1.3.9-8
36
37%description
20a63901 38Apache JServ is a servlet engine, developed by the Java Apache Project
39<http://java.apache.org/>. The Apache JServ servlet engine is written in
40100pc Java application, and listens for servlet requests using the Apache
41Java protocol (AJp). Typically, these requests will originate from the
42mod_jserv Apache module (DSO included). This package contains a LGPL'ed
43implementation of sun's java servlet api version 2.0 by Paul Siegmann
44<http://www.euronet.nl/~pauls/java/servlet/>
0464d88f 45
46%prep
47rm -rf $RPM_BUILD_ROOT
20a63901 48%setup -q -a 1
0464d88f 49
0464d88f 50%patch0
51%patch1 -p1
52
53# final position of GNU JSDK-Classes
54sed 's|@JSDK_CLASSES@|%{classesdir}/servlet-2.0.jar|g' \
55 < conf/jserv.properties.in > conf/jserv.properties.in.new
56mv 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
59sed 's|@LOAD_OR_NOT@|#|g' \
60 < conf/jserv.conf.in > conf/jserv.conf.in.new
61mv conf/jserv.conf.in.new conf/jserv.conf.in
62
63# prepare compilation
64aclocal
65autoconf
66automake
67
68%build
0464d88f 69make -C classpathx_servlet-%{jsdkversion} jar_2_0
70make -C classpathx_servlet-%{jsdkversion}/apidoc
71
72# copy API-doc
73mkdir jsdk-doc
74cp classpathx_servlet-%{jsdkversion}/README \
75 classpathx_servlet-%{jsdkversion}/AUTHORS \
76 classpathx_servlet-%{jsdkversion}/COPYING.LIB \
77 jsdk-doc
78cp -r classpathx_servlet-%{jsdkversion}/apidoc jsdk-doc
79
80
81### JSERV
82
83# find apxs utility ..
84# .. in PATH
85APXS_UTIL=`type -p apxs || true`
86
87# .. from RPM
88if 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
98fi
99
100# .. at usual places
101if test "x$APXS_UTIL" = x ; then
102 for loc in \
20a63901 103 %{_bindir} \
104 %{_sbindir} \
105 %{_prefix}/local/apache/bin \
106 %{_prefix}/local/apache/sbin \
107 %{_prefix}/local/httpd/bin \
108 %{_prefix}/local/httpd/sbin
0464d88f 109 do
110 if test -x "$loc/apxs" ; then
111 APXS_UTIL="$loc/apxs"
112 break
113 fi
114 done
115fi
116
117if test "x$APXS_UTIL" = x ; then
118 echo "Didn't find apxs .. exiting"
119 exit -1
120fi
121
122APXS_CFLAGS=`$APXS_UTIL -q CFLAGS`
123CFLAGS="$APXS_CFLAGS $RPM_OPT_FLAGS" ./configure \
20a63901 124 --prefix=%{_prefix} \
0464d88f 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
130make
131
132%install
20a63901 133rm -rf $RPM_BUILD_ROOT
134
0464d88f 135make DESTDIR=$RPM_BUILD_ROOT install
136
137echo "default - change on install `date`" > $RPM_BUILD_ROOT/%{jservconf}/jserv.secret.key
138chmod 600 $RPM_BUILD_ROOT/%{jservconf}/jserv.secret.key
139
140# currently disabled
20a63901 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
0464d88f 147
148### GNU JSDK-classes
149install -d ${RPM_BUILD_ROOT}%{classesdir}
150install classpathx_servlet-%{jsdkversion}/servlet-2.0.jar ${RPM_BUILD_ROOT}%{classesdir}
151
152%clean
153rm -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:
20a63901 159(%{_prefix}/games/fortune 2>/dev/null ; date ; ps -eal 2>/dev/null) \
0464d88f 160 | (md5sum 2>/dev/null || cat) \
161 > %{jservconf}/jserv.secret.key
162chmod 600 %{jservconf}/jserv.secret.key
163
164#
165# determine apache-USER and chown the jserv.secrect.key - file
166#
167APACHEUSER=`grep "^User[ ]\+" %{httpdconf}/httpd.conf | awk '{print $2}'`
168if test ! "x$APACHEUSER" = x ; then
169 USERCOMMENT="(which is '$APACHEUSER' ?)"
170else
20a63901 171 # assumption:
0464d88f 172 APACHEUSER=nobody
173fi
174chown $APACHEUSER %{jservconf}/jserv.secret.key
175
176#
177# determine apache-GROUP and allow this group to write to %{logdir}
178APACHEGROUP=`grep "^Group[ ]\+" %{httpdconf}/httpd.conf | awk '{print $2}'`
179if test "x$APACHEGROUP" = x ; then
180 APACHEGROUP=nobody
181fi
182chgrp $APACHEGROUP %{logdir}
183chmod 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#
193cp %{httpdconf}/httpd.conf %{httpdconf}/httpd.conf.rpmorig
194grep '#\?.*[iI]nclude.*/jserv.conf' %{httpdconf}/httpd.conf \
195 >/dev/null
196if 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
202else
203 # append it
204 (
205 echo "<IfModule mod_jserv.c>"
206 echo " Include %{jservconf}/jserv.conf"
207 echo "</IfModule>"
208 ) >> %{httpdconf}/httpd.conf
209fi
210
211#
212# LoadModule; uncomment or insert
213#
214grep '#\?.*LoadModule.*jserv_module.*mod_jserv.so' %{httpdconf}/httpd.conf \
215 >/dev/null
216if 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
222else
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
230fi
231
232#
233# AddModule; uncomment or insert
234#
235grep '#\?.*AddModule.*mod_jserv.c' %{httpdconf}/httpd.conf >/dev/null
236if 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
242else
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
249fi
250
251#
252# Search vor JAVA at possible locations and edit wrapper.bin
253#
254unset JAVABIN
255for 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
285done
286
287if 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
292fi
293
294#
295# Get Server Port to echo right URL below
296#
297SERVERPORT=`grep "^Port" %{httpdconf}/httpd.conf | \
298 head -1 | awk '{print ":" $2}'`
299if test "$SERVERPORT" = ":80" ; then
300 SERVERPORT=""
301fi
302
20a63901 303#FIXME: make this i18n-aware
0464d88f 304
305if test ! "x$JAVABIN" = x ; then
306 echo "using java VM $JAVABIN"
307else
308 echo "## didn't find java or jre. Please install it and edit the"
309 echo "## wrapper.bin property in %{jservconf}/jserv.properties"
310fi
311echo ""
312echo "In order to enable JServ, restart the webserver and try"
313echo " http://localhost$SERVERPORT/servlets/IsItWorking"
314echo " and"
315echo " http://localhost$SERVERPORT/jserv/"
316echo "-- ENJOY! --"
317echo ""
318
319## we hopefully may distribute SUN-jsdk.jar with jserv once ..
320echo " | NOTE that this distribution contains a fully functional"
321echo " | free jsdk replacement, see <http://www.euronet.nl/~pauls/java/servlet/>."
322echo " | If you want to use the SUN-jsdk, replace the servlet-2.0.jar"
323echo " | in the wrapper.classpath - line in the file"
324echo " | %{jservconf}/jserv.properties"
325echo " | with the SUN jsdk."
326echo " | Get it from <http://java.sun.com/products/servlet/>."
327echo " | Only JSDK 2.0 (Java Servlet Development Kit)"
328echo " | is supported (_EXACTLY_ 2.0)."
329echo ""
330
331echo "Please send comments/suggestions regarding"
332echo "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.
338if [ ! $1 -eq 0 ] ; then
339 exit 0
340fi
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#
350cp %{httpdconf}/httpd.conf %{httpdconf}/httpd.conf.rpmorig
351sed '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
20a63901 361%defattr(644,root,root,755)
362# mmh, we can't give %{_prefix}/docs to %doc ..
0464d88f 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
20a63901 378#%config %{_sysconfdir}/rc.d/init.d/jserv
379#%config %{_sysconfdir}/logrotate.d/jserv
380#%config %{_sysconfdir}/profile.d/jserv.sh
0464d88f 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.163683 seconds and 4 git commands to generate.