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