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