Skip to content

Instantly share code, notes, and snippets.

@jtai
Created January 19, 2012 18:24
Show Gist options
  • Save jtai/1641656 to your computer and use it in GitHub Desktop.
Save jtai/1641656 to your computer and use it in GitHub Desktop.
RPM packaging for gearman 1.0.1 PECL extension based on IUS php53u-pecl-apc spec file
extension=gearman.so
%{!?__pecl: %{expand: %%global __pecl %{_bindir}/pecl}}
%{!?pecl_phpdir: %{expand: %%global pecl_phpdir %(%{__pecl} config-get php_dir 2> /dev/null || echo undefined)}}
%{?!pecl_xmldir: %{expand: %%global pecl_xmldir %{pecl_phpdir}/.pkgxml}}
%define php_extdir %(php-config --extension-dir 2>/dev/null || echo %{_libdir}/php4)
%global php_zendabiver %((echo 0; php -i 2>/dev/null | sed -n 's/^PHP Extension => //p') | tail -1)
%global php_version %((echo 0; php-config --version 2>/dev/null) | tail -1)
%define pecl_name gearman
%{?!_without_php_ver_tag: %define php_ver_tag .php%{php_major_version}}
%define real_name php-pecl-gearman
%define php_base php53u
Summary: Provides API for communicating with gearmand, and writing clients and workers
Name: %{php_base}-pecl-gearman
Version: 1.0.1
Release: 1.ign%{?dist}
License: PHP
Group: Development/Languages
Vendor: IGN Entertainment
URL: http://pecl.php.net/package/gearman
Source: http://pecl.php.net/get/gearman-%{version}.tgz
Source1: gearman.ini
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
Provides: %{real_name} = %{version}
BuildRequires: %{php_base}-devel %{php_base}-cli %{php_base}-pear
BuildRequires: libgearman-devel
Requires: %{php_base} >= 5.1.0-1
%if %{?php_zend_api}0
# Require clean ABI/API versions if available (Fedora)
Requires: %{php_base}(zend-abi) = %{php_zend_api}
Requires: %{php_base}(api) = %{php_core_api}
Requires: %{php_base}-pear
%else
Requires: %{php_base}-zend-abi = %{php_zendabiver}
%endif
Provides: php-pecl(%{pecl_name}) = %{version}
Requires(post): %{__pecl}
Requires(postun): %{__pecl}
%description
This extension uses libgearman library to provide API for communicating with
gearmand, and writing clients and workers.
%prep
%setup -q -n %{pecl_name}-%{version}
%build
%{_bindir}/phpize
%configure --with-php-config=%{_bindir}/php-config
%{__make} %{?_smp_mflags}
%install
%{__rm} -rf %{buildroot}
%{__make} install INSTALL_ROOT=%{buildroot}
# Install the package XML file
%{__mkdir_p} %{buildroot}%{pecl_xmldir}
%{__install} -m 644 ../package.xml %{buildroot}%{pecl_xmldir}/%{pecl_name}.xml
# Drop in the bit of configuration
%{__mkdir_p} %{buildroot}%{_sysconfdir}/php.d
%{__install} -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/php.d/gearman.ini
%post
%{__pecl} install --nodeps --soft --force --register-only --nobuild %{pecl_xmldir}/%{pecl_name}.xml >/dev/null || :
%postun
if [ $1 -eq 0 ] ; then
%{__pecl} uninstall --nodeps --ignore-errors --register-only %{pecl_name} >/dev/null || :
fi
%clean
%{__rm} -rf %{buildroot}
%files
%defattr(-, root, root, 0755)
%doc CREDITS ChangeLog LICENSE README examples
%config(noreplace) %{_sysconfdir}/php.d/gearman.ini
%{php_extdir}/gearman.so
%{pecl_xmldir}/%{pecl_name}.xml
%changelog
* Thu Jan 19 2012 Jonathan Tai <[email protected]> - 1.0.1-1.ign
- Initial version based on IUS php53u-pecl-apc spec file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment