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