Menu

[r633]: / trunk / php-java-bridge / php-java-bridge.spec  Maximize  Restore  History

Download this file

383 lines (332 with data), 12.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
#-*- mode: rpm-spec; tab-width:4 -*-
%define version 5.1.2
%define release 1
%define PHP_MAJOR_VERSION %(((LANG=C rpm -q --queryformat "%{VERSION}" php) || echo "4.0.0") | tail -1 | sed 's/\\\..*$//')
%define PHP_MINOR_VERSION %(((LANG=C rpm -q --queryformat "%{VERSION}" php) || echo "4.0.0") | tail -1 | LANG=C cut -d. -f2)
%define have_j2 %((rpm -q --whatprovides j2sdk) >/dev/null && echo 1 || echo 0)
%define have_j3 %((rpm -q --whatprovides jdk) >/dev/null && echo 1 || echo 0)
%define have_policy_modules %(if test -f /etc/selinux/config && test -d /etc/selinux/%{__policy_tree}/modules; then echo 1; else echo 0; fi)
%define have_policy_devel %(if test -f %{_datadir}/selinux/devel/Makefile; then echo 1; else echo 0; fi)
%define tomcat_name tomcat5
%define tomcat_webapps %{_localstatedir}/lib/%{tomcat_name}/webapps
%define shared_java %{_datadir}/java
%define shared_pear %{_datadir}/pear
Name: php-java-bridge
Summary: PHP Hypertext Preprocessor to Java Bridge
Group: Development/Languages
Version: %{version}
Release: %{release}
License: LGPL
URL: http://www.sourceforge.net/projects/php-java-bridge
Source0: http://osdn.dl.sourceforge.net/sourceforge/php-java-bridge/php-java-bridge_%{version}.tar.gz
BuildRequires: php-devel >= 4.3.4
BuildRequires: gcc >= 3.2.3
BuildRequires: mono-core >= 1.1.8
BuildRequires: gcc-c++
BuildRequires: gcc-java >= 3.3.3
BuildRequires: libstdc++-devel
BuildRequires: httpd make
BuildRequires: libtool >= 1.4.3
BuildRequires: automake >= 1.6.3
BuildRequires: autoconf >= 2.57
%if %{have_j3} == 1
BuildRequires: jdk >= 1.4.2
%else
%if %{have_j2} == 1
BuildRequires: j2sdk >= 1.4.2
%else
BuildRequires: java-devel >= 1.4.2
%endif
%endif
%if %{have_policy_modules} == 1
BuildRequires: selinux-policy
BuildRequires: policycoreutils checkpolicy coreutils
%if %{have_policy_devel} == 0
BuildRequires: selinux-policy-devel
%endif
%endif
# PHP 4 or PHP 5 or PHP 5.1
%if %{PHP_MAJOR_VERSION} == 4
Requires: php >= 4.3.2
Requires: php < 5.0.0
%else
%if %{PHP_MAJOR_VERSION} == 5
Requires: php >= 5.1.1
Requires: php < 6.0.0
%else
Requires: php >= 5.2.0
%endif
%endif
Requires: httpd
Requires: libgcj
%if %{have_policy_modules} == 1
Requires: policycoreutils coreutils
%endif
BuildRoot: %{_tmppath}/%{name}-root
%description
Java module/extension for the PHP script language. Contains the basic
files: java extension for PHP/Apache HTTP server and a simple back-end
which automatically starts and stops when the HTTP server
starts/stops. The bridge log appears in the http server error log.
%package mono
Group: Development/Languages
Summary: Mono module/extension for the PHP script language.
Requires: mono-core >= 1.1.8
%description mono
Java module/extension for the PHP script language. Contains the basic
files: java extension for PHP/Apache HTTP server and a simple back-end
which automatically starts and stops when the HTTP server
starts/stops. The bridge log appears in the http server error log.
%package lucene
Group: System Environment/Daemons
Summary: lucene library for PHP
Requires: php-java-bridge
Requires: lucene
%description lucene
Lucene search library for PHP
%package itext
Group: System Environment/Daemons
Summary: itext library for PHP
Requires: php-java-bridge
%description itext
PDF manipulation library for PHP
%package tomcat
Group: System Environment/Daemons
Summary: Tomcat/J2EE back-end for the PHP/Java Bridge
Requires: php-java-bridge = %{version}
Requires: tomcat5
%description tomcat
Deploys the j2ee back-end into the tomcat servlet engine. The tomcat
back-end is more than 2 times faster than the standalone back-end but
less secure; it uses named pipes instead of abstract local "unix
domain" sockets.
%package devel
Group: Development/Libraries
Summary: PHP/Java Bridge development files and documentation
Requires: php-java-bridge = %{version}
%description devel
Contains the development documentation
and the development files needed to create java applications with
embedded PHP scripts.
%prep
echo Building for PHP %{PHP_MAJOR_VERSION}.
%setup
%build
set -x
PATH=/bin:%{_bindir}
LD_LIBRARY_PATH=/lib:%{_libdir}
# calculate java dir
%if %{have_j3} == 1
pkgid=`rpm -q --whatprovides jdk --queryformat "%{PKGID} %{VERSION}\n" | sed 's/\./0/g;s/_/./' |sort -r -k 2,2 -n | head -1 | awk '{print $1}'`
%else
%if %{have_j2} == 1
pkgid=`rpm -q --whatprovides j2sdk --queryformat "%{PKGID} %{VERSION}\n" | sed 's/\./0/g;s/_/./' |sort -r -k 2,2 -n | head -1 | awk '{print $1}'`
%else
pkgid=`rpm -q --whatprovides java-devel --queryformat "%{PKGID} %{VERSION}\n" | sed 's/\./0/g;s/_/./' |sort -r -k 2,2 -n | head -1 | awk '{print $1}'`
%endif
%endif
jdk=`rpm -q --pkgid $pkgid`
java=`rpm -ql $jdk | grep 'bin/java$' | head -1`
java_dir=`dirname $java`
java_dir=`dirname $java_dir`
if test X`basename $java_dir` = Xjre; then
java_dir=`dirname $java_dir`;
fi
echo "using java_dir: $java_dir"
if test X$java_dir = X; then echo "ERROR: java not installed" >2; exit 1; fi
phpize
./configure --prefix=%{_exec_prefix} --with-java=$java_dir --with-mono
make
%if %{have_policy_modules} == 1
(cd security/module; make -f %{_datadir}/selinux/devel/Makefile; rm -rf tmp;)
%endif
%install
rm -rf $RPM_BUILD_ROOT
%makeinstall | tee install.log
echo >filelist
echo >filelist-mono
echo >filelist-itext
echo >filelist-lucene
echo >filelist-tomcat
echo >filelist-devel
mod_dir=`cat install.log | sed -n '/Installing shared extensions:/s///p' | awk '{print $1}'`
files="php-script.jar script-api.jar"
mkdir -p $RPM_BUILD_ROOT/%{shared_java}
for i in $files;
do cp $mod_dir/$i $RPM_BUILD_ROOT/%{shared_java}/$i;
rm -f $mod_dir/$i;
echo %{shared_java}/$i >>filelist-devel
done
cp $mod_dir/JavaBridge.jar $RPM_BUILD_ROOT/%{shared_java}/JavaBridge.jar;
echo %{shared_java}/JavaBridge.jar >>filelist-devel
files="Client.inc GlobalRef.inc Java.inc JavaBridge.inc JavaProxy.inc NativeParser.inc Options.inc Parser.inc Protocol.inc SimpleParser.inc"
mkdir -p $RPM_BUILD_ROOT/%{shared_pear}/java
for i in $files;
do cp server/META-INF/java/$i $RPM_BUILD_ROOT/%{shared_pear}/java/$i;
echo %{shared_pear}/java/$i >>filelist
done
files='java libnatcJavaBridge.so java.so'
mkdir -p $RPM_BUILD_ROOT/$mod_dir
for i in $files; do
if test -f $mod_dir/$i; then
cp $mod_dir/$i $RPM_BUILD_ROOT/$mod_dir/$i
rm -f $mod_dir/$i
echo $mod_dir/$i >>filelist
fi
done
i=RunJavaBridge
cp $mod_dir/$i $RPM_BUILD_ROOT/$mod_dir/$i
rm -f $mod_dir/$i
i=JavaBridge.jar
cp $mod_dir/$i $RPM_BUILD_ROOT/$mod_dir/$i
rm -f $mod_dir/$i
files='mono.so ICSharpCode.SharpZipLib.dll IKVM.AWT.WinForms.dll IKVM.GNU.Classpath.dll IKVM.Runtime.dll'
for i in $files; do
if test -f $mod_dir/$i; then
cp $mod_dir/$i $RPM_BUILD_ROOT/$mod_dir/$i
rm -f $mod_dir/$i
echo $mod_dir/$i >>filelist-mono
fi
done
i=RunMonoBridge
cp $mod_dir/$i $RPM_BUILD_ROOT/$mod_dir/$i
rm -f $mod_dir/$i
i=MonoBridge.exe
cp $mod_dir/$i $RPM_BUILD_ROOT/$mod_dir/$i
rm -f $mod_dir/$i
mkdir -p $RPM_BUILD_ROOT/%{_datadir}/pear/itext
cp unsupported/itext.jar $RPM_BUILD_ROOT/%{_datadir}/pear/itext
echo %{_datadir}/pear/itext >>filelist-itext
mkdir -p $RPM_BUILD_ROOT/%{_datadir}/pear/lucene
echo %{_datadir}/pear/lucene >>filelist-lucene
files=JavaBridge.war
mkdir -p $RPM_BUILD_ROOT/%{tomcat_webapps}
for i in $files;
do cp $mod_dir/$i $RPM_BUILD_ROOT/%{tomcat_webapps}
rm -f $mod_dir/$i;
echo %{tomcat_webapps}/$i >>filelist-tomcat
done
mkdir -p $RPM_BUILD_ROOT/etc/php.d
cat java-servlet.ini >$RPM_BUILD_ROOT/etc/php.d/java-servlet.ini
cat java.ini >$RPM_BUILD_ROOT/etc/php.d/java.ini
cat mono.ini >$RPM_BUILD_ROOT/etc/php.d/mono.ini
echo /etc/php.d/java.ini >>filelist
mkdir $RPM_BUILD_ROOT/$mod_dir/lib
echo $mod_dir/lib >>filelist
# server also contains the server documentation
mv server server.backup
mkdir server
mv server.backup/documentation server
mv server.backup/javabridge.policy server
mv server.backup/WEB-INF server
rm -rf server/WEB-INF/lib server/WEB-INF/classes server/WEB-INF/cgi
mv server.backup/test server
(cd documentation; ln -s ../server/documentation/API .)
%clean
rm -rf $RPM_BUILD_ROOT
%post
if test -f /etc/selinux/config; then
if test -d /etc/selinux/%{__policy_tree}/modules; then
/sbin/service httpd stop > /dev/null 2>&1
%{_sbindir}/semodule -i %{_docdir}/%{name}-%{version}/security/module/php-java-bridge.pp
chcon -t javabridge_exec_t %{_libdir}/php/modules/RunJavaBridge
chcon -t bin_t %{_libdir}/php/modules/java
/sbin/service httpd start > /dev/null 2>&1
else
te=/etc/selinux/%{__policy_tree}/src/policy/domains/program/php-java-bridge.te
fc=/etc/selinux/%{__policy_tree}/src/policy/file_contexts/program/php-java-bridge.fc
echo "SECURITY ENHANCED LINUX"
echo "-----------------------"
echo "You are running a SELinx system. Please install the policy sources:"
echo "rpm -i selinux-policy-%{__policy_tree}-sources-*.rpm"
echo "sh %{_docdir}/%{name}-%{version}/security/update_policy.sh \\"
echo " /etc/selinux/%{__policy_tree}/src/policy"
echo "Please see INSTALL and README documents for more information."
echo
fi
fi
echo "PHP/Java Bridge installed."
echo "Now install the tomcat or J2EE back-end or the native (lucene/itext) libs."
echo
exit 0
%post tomcat
if test -f /etc/selinux/config; then
if test -d /etc/selinux/%{__policy_tree}/modules; then
/sbin/service httpd stop > /dev/null 2>&1
/sbin/service tomcat5 stop > /dev/null 2>&1
%{_sbindir}/semodule -i %{_docdir}/%{name}-tomcat-%{version}/security/module/php-java-bridge-tomcat.pp
/sbin/service httpd start > /dev/null 2>&1
/sbin/service tomcat5 start > /dev/null 2>&1
else
te=/etc/selinux/%{__policy_tree}/src/policy/domains/program/php-java-bridge.te
fc=/etc/selinux/%{__policy_tree}/src/policy/file_contexts/program/php-java-bridge.fc
echo "SECURITY ENHANCED LINUX"
echo "-----------------------"
echo "You are running a SELinx system. Please install the policy sources:"
echo "rpm -i selinux-policy-%{__policy_tree}-sources-*.rpm"
echo "sh %{_docdir}/%{name}-tomcat-%{version}/security/update_policy.sh \\"
echo " /etc/selinux/%{__policy_tree}/src/policy"
echo "Please see INSTALL and README documents for more information."
echo
fi
fi
if test -d /var/www/html && ! test -e /var/www/html/JavaBridge; then
ln -fs %{tomcat_webapps}/JavaBridge /var/www/html/;
fi
echo "PHP/Java Bridge tomcat back-end installed. Start with:"
echo "service tomcat5 restart"
echo "service httpd restart"
echo
exit 0
%post devel
mkdir -p %{_exec_prefix}/java/packages/lib/ext/ 2>/dev/null
ln -fs %{shared_java}/JavaBridge.jar %{_exec_prefix}/java/packages/lib/ext/
ln -fs %{shared_java}/php-script.jar %{_exec_prefix}/java/packages/lib/ext/
exit 0
%preun
if [ $1 = 0 ]; then
/sbin/service httpd stop > /dev/null 2>&1
if test -d /etc/selinux/%{__policy_tree}/modules; then
%{_sbindir}/semodule -r javabridge
fi
/sbin/service httpd start > /dev/null 2>&1
fi
%preun tomcat
if [ $1 = 0 ]; then
if test -e /var/www/html/JavaBridge && test -e %{tomcat_webapps}/JavaBridge && test %{tomcat_webapps}/JavaBridge -ef /var/www/html/JavaBridge; then
rm -f /var/www/html/JavaBridge;
fi
rm -rf %{tomcat_webapps}/JavaBridge %{tomcat_webapps}/work/*
if test -d /etc/selinux/%{__policy_tree}/modules; then
%{_sbindir}/semodule -r javabridge_tomcat
fi
fi
%preun devel
if [ $1 = 0 ]; then
rm -f %{_exec_prefix}/java/packages/lib/ext/JavaBridge.jar %{_exec_prefix}/java/packages/lib/ext/php-java.jar
fi
%files -f filelist
%defattr(-,root,root)
%attr(6111,apache,apache) %{_libdir}/php/modules/RunJavaBridge
%attr(755,root,root) %{_libdir}/php/modules/JavaBridge.jar
%attr(755,root,root) %{shared_java}/JavaBridge.jar
%doc README FAQ.html COPYING CREDITS NEWS test.php INSTALL.LINUX security
%files mono -f filelist-mono
%defattr(-,root,root)
%attr(-,root,root) /etc/php.d/mono.ini
%attr(111,root,root) %{_libdir}/php/modules/RunMonoBridge
%attr(755,root,root) %{_libdir}/php/modules/MonoBridge.exe
%doc README.MONO+NET COPYING CREDITS NEWS tests.mono+net
%files itext -f filelist-itext
%defattr(-,root,root)
%doc examples/office
%files lucene -f filelist-lucene
%defattr(-,root,root)
%doc examples/search
%files tomcat -f filelist-tomcat
%defattr(-,tomcat,tomcat)
%attr(-,root,root) /etc/php.d/java-servlet.ini
%doc %attr(-,root,root) README FAQ.html INSTALL.J2EE COPYING security
%files devel -f filelist-devel
%defattr(-,root,root)
%doc FAQ.html CREDITS README.GNU_JAVA README.MONO+NET ChangeLog README PROTOCOL.TXT COPYING server documentation examples tests.php5 php_java_lib NEWS INSTALL.LINUX INSTALL
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.