]> git.pld-linux.org Git - packages/ApacheJServ.git/blob - ApacheJServ.spec
- fix improper usage of %%{_sysconfdir}
[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/services/httpd/servlets
10 %define classesdir /home/services/httpd/classes
11 %define jsdkversion 20000924
12
13 Summary:        Servlet engine with support for the leading web server
14 Summary(pl):    Silnik serwletów ze wsparciem dla wiod±cego serwera WWW
15 Name:           ApacheJServ
16 Version:        1.1
17 Release:        3
18 Source0:        http://java.apache.org/jserv/dist/%{name}-%{version}.tar.gz
19 Source1:        http://www.euronet.nl/~pauls/java/servlet/download/classpathx_servlet-%{jsdkversion}.tar.gz
20 Patch0:         %{name}-enable-secret.patch
21 Patch1:         %{name}-DESTDIR.patch
22 URL:            http://java.apache.org/
23 License:        freely distributable & usable
24 Group:          Networking/Daemons
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
47 Project <http://java.apache.org/>. Silnik serwletowy Apache JServ
48 zosta³ napisany od pocz±tku do koñca w Javie; nas³uchuje wywo³añ
49 serwletu wykorzystuj±c protokó³ Apache Java (AJp). Zazwyczaj wywo³ania
50 te pochodz± z modu³u Apache mod_jservmodule (³±cznie z DSO). Pakiet
51 ten zawiera sunowsk± implementacjê api serletów w javie w wersji 2.0
52 (na licencji LGPL) napisana przez Paula Siegmanna
53 <http://www.euronet.nl/~pauls/java/servlet/>
54
55 %prep
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 %build
72 # prepare compilation
73 rm -f missing
74 %{__aclocal}
75 %{__autoconf}
76 %{__automake}
77
78 %{__make} -C classpathx_servlet-%{jsdkversion} jar_2_0
79 %{__make} -C classpathx_servlet-%{jsdkversion}/apidoc
80
81 # copy API-doc
82 mkdir jsdk-doc
83 cp classpathx_servlet-%{jsdkversion}/README \
84         classpathx_servlet-%{jsdkversion}/AUTHORS \
85         classpathx_servlet-%{jsdkversion}/COPYING.LIB \
86         jsdk-doc
87 cp -r classpathx_servlet-%{jsdkversion}/apidoc jsdk-doc
88
89 ### JSERV
90
91 APXS_CFLAGS=`$APXS_UTIL -q CFLAGS`
92 CFLAGS="$APXS_CFLAGS %{rpmcflags}" ./configure \
93         --prefix=%{_prefix} \
94         --disable-debugging \
95         --with-apxs=/usr/sbin/apxs \
96         --with-logdir=%{logdir} \
97         --with-servlets=%{servletdir} \
98         --with-JSDK=`pwd`/classpathx_servlet-%{jsdkversion}/servlet-2.0.jar
99 %{__make}
100
101 %install
102 rm -rf $RPM_BUILD_ROOT
103
104 %{__make} DESTDIR=$RPM_BUILD_ROOT install
105
106 echo "default - change on install `date`" > $RPM_BUILD_ROOT/%{jservconf}/jserv.secret.key
107 chmod 600 $RPM_BUILD_ROOT/%{jservconf}/jserv.secret.key
108
109 # currently disabled
110 #install -d $RPM_BUILD_ROOT/etc/rc.d/init.d
111 #install -d $RPM_BUILD_ROOT/etc/profile.d
112 #install -d $RPM_BUILD_ROOT/etc/logrotate.d
113 #install -m755 src/scripts/package/rpm/jserv.init      $RPM_BUILD_ROOT/etc/rc.d/init.d/jserv
114 #install -m755 src/scripts/package/rpm/jserv.sh        $RPM_BUILD_ROOT/etc/profile.d
115 #install -m644 src/scripts/package/rpm/jserv.logrotate $RPM_BUILD_ROOT/etc/logrotate.d/jserv
116
117 ### GNU JSDK-classes
118 install -d ${RPM_BUILD_ROOT}%{classesdir}
119 install classpathx_servlet-%{jsdkversion}/servlet-2.0.jar ${RPM_BUILD_ROOT}%{classesdir}
120
121 %clean
122 rm -rf $RPM_BUILD_ROOT
123
124 %post
125
126 # use fortune + install-date + process-list to create pseudo-random, hardly
127 # guessable secret key. Use md5sum to create a hash from this, if available:
128 (%{_prefix}/games/fortune 2>/dev/null ; date ; ps -eal 2>/dev/null)   \
129                     | (md5sum 2>/dev/null || cat)               \
130                     > %{jservconf}/jserv.secret.key
131 chmod 600 %{jservconf}/jserv.secret.key
132
133 #
134 # determine apache-USER and chown the jserv.secrect.key - file
135 #
136 APACHEUSER=`grep "^User[         ]\+" %{httpdconf}/httpd.conf | awk '{print $2}'`
137 if test ! "x$APACHEUSER" = x ; then
138    USERCOMMENT="(which is '$APACHEUSER' ?)"
139 else
140    # assumption:
141    APACHEUSER=nobody
142 fi
143 chown $APACHEUSER %{jservconf}/jserv.secret.key
144
145 #
146 # determine apache-GROUP and allow this group to write to %{logdir}
147 APACHEGROUP=`grep "^Group[       ]\+" %{httpdconf}/httpd.conf | awk '{print $2}'`
148 if test "x$APACHEGROUP" = x ; then
149    APACHEGROUP=nobody
150 fi
151 chgrp $APACHEGROUP %{logdir}
152 chmod g+w %{logdir}
153
154 #
155 # Add 'jserv' as an independent service (manual mode)
156 #/sbin/chkconfig --add jserv
157 #/etc/rc.d/init.d/jserv start
158
159 #
160 # Find Include Statement or add it if necessary
161 #
162 cp %{httpdconf}/httpd.conf %{httpdconf}/httpd.conf.rpmorig
163 grep '#\?.*[iI]nclude.*/jserv.conf' %{httpdconf}/httpd.conf \
164      >/dev/null
165 if test $? -eq 0 ; then
166    # found. Insert our include statement here
167    ## this depends on GNU-sed ('|') .. but we're on a RedHat system anyway
168    sed 's|^#\?\(.*Include\).*/jserv.conf.*$|\1 %{jservconf}/jserv.conf|g' \
169        < %{httpdconf}/httpd.conf.rpmorig                 \
170        > %{httpdconf}/httpd.conf
171 else
172    # append it
173    (
174      echo "<IfModule mod_jserv.c>"
175      echo "          Include %{jservconf}/jserv.conf"
176      echo "</IfModule>"
177    ) >> %{httpdconf}/httpd.conf
178 fi
179
180 #
181 # LoadModule; uncomment or insert
182 #
183 grep '#\?.*LoadModule.*jserv_module.*mod_jserv.so' %{httpdconf}/httpd.conf \
184      >/dev/null
185 if test $? -eq 0 ; then
186    # found. Remove any comment
187    sed 's|^#.*\(LoadModule.*mod_jserv.so\)|\1|g' \
188        < %{httpdconf}/httpd.conf                 \
189        > %{httpdconf}/httpd.conf.loadMod
190    mv %{httpdconf}/httpd.conf.loadMod %{httpdconf}/httpd.conf
191 else
192    # Insert LoadModule line before first valid LoadModule
193    ( echo "/^LoadModule"
194      echo "i"
195      echo "LoadModule jserv_module      modules/mod_jserv.so"
196      echo "."
197      echo "wq"
198    ) | ed %{httpdconf}/httpd.conf > /dev/null 2>&1
199 fi
200
201 #
202 # AddModule; uncomment or insert
203 #
204 grep '#\?.*AddModule.*mod_jserv.c' %{httpdconf}/httpd.conf >/dev/null
205 if test $? -eq 0  ; then
206    # found. Remove any comment
207    sed 's|^#.*\(AddModule.*mod_jserv.c\)|\1|g' \
208        < %{httpdconf}/httpd.conf               \
209        > %{httpdconf}/httpd.conf.addMod
210    mv %{httpdconf}/httpd.conf.addMod %{httpdconf}/httpd.conf
211 else
212    ( echo "/^AddModule"
213      echo "i"
214      echo "AddModule mod_jserv.c"
215      echo "."
216      echo "wq"
217    ) | ed %{httpdconf}/httpd.conf > /dev/null 2>&1
218 fi
219
220 #
221 # Search vor JAVA at possible locations and edit wrapper.bin
222 #
223 unset JAVABIN
224 for lookfor in java jre ; do
225   for loc in \
226     $JAVA_HOME            \
227     $JDK_HOME             \
228     /usr/local/java       \
229     /usr/local/jdk       \
230     /usr/local/jdk117_v3  \
231     /usr/local/jdk117_v1a
232   do
233     if test -x "$loc/bin/$lookfor" ; then
234        JAVABIN="$loc/bin/$lookfor"
235        break
236     fi
237   done
238
239   if test -z "$JAVABIN" ; then
240     for prefix in /usr/jdk /usr/jdk- /usr/local/jdk /usr/local/jdk- ; do
241       for jplatform in 2 1 ; do
242         for subvers in .9 .8 .7 .6 .5 .4 .3 .2 .1 "" ; do
243           if test -x "${prefix}1.$jplatform$subvers/bin/$lookfor" ; then
244              JAVABIN="${prefix}1.$jplatform$subvers/bin/$lookfor"
245              break
246           fi
247         done
248         if test ! -z "$JAVABIN" ; then break ; fi
249       done
250       if test ! -z "$JAVABIN" ; then break ; fi
251     done
252   fi
253   if test ! -z "$JAVABIN" ; then break ; fi
254 done
255
256 if test ! -z "$JAVABIN" ; then
257    sed "s|^wrapper.bin=.*$|wrapper.bin=$JAVABIN|" \
258        < %{jservconf}/jserv.properties \
259        > %{jservconf}/jserv.properties.new
260    mv %{jservconf}/jserv.properties.new %{jservconf}/jserv.properties
261 fi
262
263 #
264 # Get Server Port to echo right URL below
265 #
266 SERVERPORT=`grep "^Port" %{httpdconf}/httpd.conf | \
267                         head -1 | awk '{print ":" $2}'`
268 if test "$SERVERPORT" = ":80" ; then
269         SERVERPORT=""
270 fi
271
272 #FIXME:         make this i18n-aware
273
274 if test ! "x$JAVABIN" = x ; then
275    echo "using java VM $JAVABIN"
276 else
277    echo "## didn't find java or jre. Please install it and edit the"
278    echo "## wrapper.bin property in %{jservconf}/jserv.properties"
279 fi
280 echo ""
281 echo "In order to enable JServ, restart the webserver and try"
282 echo "           http://localhost$SERVERPORT/servlets/IsItWorking"
283 echo "   and"
284 echo "           http://localhost$SERVERPORT/jserv/"
285 echo "-- ENJOY! --"
286 echo ""
287
288 ## we hopefully may distribute SUN-jsdk.jar with jserv once ..
289 echo " | NOTE that this distribution contains a fully functional"
290 echo " | free jsdk replacement, see <http://www.euronet.nl/~pauls/java/servlet/>."
291 echo " | If you want to use the SUN-jsdk, replace the servlet-2.0.jar"
292 echo " | in the wrapper.classpath - line in the file"
293 echo " |                 %{jservconf}/jserv.properties"
294 echo " | with the SUN jsdk."
295 echo " | Get it from <http://java.sun.com/products/servlet/>."
296 echo " | Only JSDK 2.0 (Java Servlet Development Kit)"
297 echo " | is supported (_EXACTLY_ 2.0)."
298 echo ""
299
300 echo "Please send comments/suggestions regarding"
301 echo "this RPM to <zeller@to.com>."
302
303 %preun
304 # do not remove the configured stuff if we upgrade.
305 # the $1 argument contains the number of packages _after_ installation.
306 if [ ! $1 -eq 0 ] ; then
307    exit 0
308 fi
309
310 # Remove 'jserv' service (manual mode)
311 #/etc/rc.d/init.d/jserv stop
312 #/sbin/chkconfig --del jserv
313
314 #
315 # Find jserv related configuration settings and comment
316 # them out
317 #
318 cp %{httpdconf}/httpd.conf %{httpdconf}/httpd.conf.rpmorig
319 sed 's|.*\(Include.*%{jservconf}/jserv.conf\)|#\1|g' \
320     < %{httpdconf}/httpd.conf.rpmorig                \
321     | sed 's|^\(AddModule.*mod_jserv.c\)|#\1|g'      \
322     | sed 's|^\(LoadModule.*mod_jserv.so\)|#\1|g'    \
323     > %{httpdconf}/httpd.conf
324 # remove old logs
325 /bin/rm -fr %{logdir}/mod_jserv.log
326 /bin/rm -fr %{logdir}/jserv.log
327
328 %files
329 %defattr(644,root,root,755)
330 # mmh, we can't give %{_prefix}/docs to %doc ..
331 %doc index.html README docs jsdk-doc
332
333 %dir %{jservconf}
334 %config %{jservconf}/jserv.properties
335 %config %{jservconf}/zone.properties
336 %config %{jservconf}/jserv.conf
337
338 # these are just for demonstration and thus,
339 # no %config-files per-se; do not install
340 # them for the RPM-packet
341 #%{jservconf}/jserv.properties.default
342 #%{jservconf}/zone.properties.default
343 #%{jservconf}/jserv.conf.default
344
345 %attr(-,nobody,nobody) %{jservconf}/jserv.secret.key
346 #%config /etc/rc.d/init.d/jserv
347 #%config /etc/logrotate.d/jserv
348 #%config /etc/profile.d/jserv.sh
349
350 %{libexecdir}/mod_jserv.so
351 %{libexecdir}/ApacheJServ.jar
352
353 %dir %{classesdir}
354 %{classesdir}/servlet-2.0.jar
355
356 %dir %{servletdir}
357 %{servletdir}/IsItWorking.java
358 %{servletdir}/IsItWorking.class
359
360 # we need to have write access here
361 %attr(-,nobody,-) %dir %{logdir}
This page took 0.133738 seconds and 3 git commands to generate.