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