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