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