An Open Access Peon

23 June 2009

Building xapian-bindings-php under Fedora Core 10

Fedora Core includes packages for Xapian, an Open Source Search Engine Library. Due to a licensing problem Fedora Core doesn't include the PHP bindings for Xapian. Regardless of licensing spats I need to use Xapian from PHP so worked out a patch for the spec file (below) and the steps needed to build the missing xapian-bindings-php RPM:

# rpm building dependencies
sudo yum -y install rpmbuild rpmdevtools autoconf automake libtool zlib-devel gcc-g++
# set up the RPM build tree (and macro file ~/.rpmmacros)
# dependencies for building xapian-bindings
sudo yum -y install xapian-core-devel python python-devel ruby ruby-devel php php-devel
# download source RPM
yumdownloader --source xapian-bindings-python
# install source file
rpm -ivh xapian-bindings-*
# copy the patch below to rpmbuild/SPECS/xapian-bindings.spec.diff
# patch the spec file
patch --dry-run -p0 -d rpmbuild/SPECS/ -i xapian-bindings.spec.diff && \
patch -p0 -d rpmbuild/SPECS/ -i xapian-bindings.spec.diff
# build all packages from the installed RPM spec file
rpmbuild -ba rpmbuild/SPECS/xapian-bindings.spec
# RPMs for your platform will be output to rpmbuild/RPMS/

I needed to do this to build a xapian-bindings-php RPM, which required patching of the spec file:

--- xapian-bindings.spec.orig 2008-12-08 13:20:55.000000000 +0000
+++ xapian-bindings.spec 2009-06-23 15:45:05.000000000 +0100
@@ -12,6 +12,7 @@
BuildRequires: python-devel >= 2.2
BuildRequires: autoconf automake libtool
BuildRequires: ruby-devel ruby
+BuildRequires: php-devel php
BuildRequires: xapian-core-devel == %{version}
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -42,11 +43,21 @@
indexing and search facilities to applications. This package provides the
files needed for developing Ruby scripts which use Xapian

+%package php
+Group: Developer/Libraries
+Summary: Files needed for developing PHP scripts which use Xapian
+%description php
+Xapian is an Open Source Probabilistic Information Retrieval framework. It
+offers a highly adaptable toolkit that allows developers to easily add advanced
+indexing and search facilities to applications. This package provides the
+files needed for developing Ruby scripts which use Xapian
%setup -q -n %{name}-%{version}

-%configure --with-python --with-ruby
+%configure --with-python --with-ruby --with-php
make %{?_smp_mflags}

@@ -59,6 +70,9 @@
mv %{buildroot}%{buildroot}/usr/share/doc/%{name}/python %{buildroot}/usr/share/doc/%{name}-python-%{version}
mv %{buildroot}%{buildroot}/usr/share/doc/%{name}/ruby %{buildroot}/usr/share/doc/%{name}-ruby-%{version}
rm -rf %{buildroot}%{buildroot}/usr/share/doc/%{name}/
+# Fix location of PHP 5 include file
+mkdir -p %{buildroot}/usr/share/php/
+mv %{buildroot}%{buildroot}/usr/share/php5/xapian.php %{buildroot}/usr/share/php/xapian.php

[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
@@ -74,6 +88,11 @@

+%files php
+%defattr(-, root, root)

* Mon Dec 08 2008 Adel Gadllah 1.0.9-1