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