From f721d8af3709bca491b118a604a729b115961e24 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 11 Dec 2013 11:08:24 +0100 Subject: php-pecl-mosquitto: 0.2.1 (alpha) New package -a --- Makefile | 4 ++ php-pecl-mosquitto.spec | 181 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 185 insertions(+) create mode 100644 Makefile create mode 100644 php-pecl-mosquitto.spec diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..13af741 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +SRCDIR := $(shell pwd) +NAME := $(shell basename $(SRCDIR)) +include ../../../common/Makefile + diff --git a/php-pecl-mosquitto.spec b/php-pecl-mosquitto.spec new file mode 100644 index 0000000..363f243 --- /dev/null +++ b/php-pecl-mosquitto.spec @@ -0,0 +1,181 @@ +# spec file for php-pecl-mosquitto +# +# Copyright (c) 2013 Remi Collet +# License: CC-BY-SA +# http://creativecommons.org/licenses/by-sa/3.0/ +# +# Please, preserve the changelog entries +# +%{?scl: %scl_package php-pecl-mosquitto} +%{!?php_incldir: %global php_incldir %{_includedir}/php} +%{!?__pecl: %global __pecl %{_bindir}/pecl} +%{!?__php: %global __php %{_bindir}/php} + +%global with_zts 0%{?__ztsphp:1} +%global pecl_name mosquitto +%global proj_name Mosquitto + +Summary: Extension for libmosquitto +Name: %{?scl_prefix}php-pecl-%{pecl_name} +Version: 0.2.1 +Release: 1%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')} +License: BSD +Group: Development/Languages +URL: http://pecl.php.net/package/%{proj_name} +Source0: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz + +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +BuildRequires: %{?scl_prefix}php-devel > 5.3 +BuildRequires: %{?scl_prefix}php-pear +BuildRequires: mosquitto-devel + +Requires(post): %{__pecl} +Requires(postun): %{__pecl} +Requires: %{?scl_prefix}php(zend-abi) = %{php_zend_api} +Requires: %{?scl_prefix}php(api) = %{php_core_api} + +Provides: %{?scl_prefix}php-%{pecl_name} = %{version} +Provides: %{?scl_prefix}php-%{pecl_name}%{?_isa} = %{version} +Provides: %{?scl_prefix}php-pecl(%{pecl_name}) = %{version} +Provides: %{?scl_prefix}php-pecl(%{pecl_name})%{?_isa} = %{version} + +%if 0%{!?scl:1} +# Other third party repo stuff +%if "%{php_version}" > "5.4" +Obsoletes: php53-pecl-%{pecl_name} +Obsoletes: php53u-pecl-%{pecl_name} +Obsoletes: php54-pecl-%{pecl_name} +%endif +%if "%{php_version}" > "5.5" +Obsoletes: php55u-pecl-%{pecl_name} +%endif +%endif + +%if 0%{?fedora} < 20 +# Filter shared private +%{?filter_provides_in: %filter_provides_in %{_libdir}/.*\.so$} +%{?filter_setup} +%endif + + +%description +Mosquitto provides support for the MQTT protocol, including publishing, +subscribing, and an event loop. + + +%prep +%setup -q -c +mv %{proj_name}-%{version} NTS + +cd NTS +# https://github.com/mgdm/Mosquitto-PHP/commit/8543020365356c817c48a13aa90079692b4a14a9 +sed -e '/PHP_ADD_LIBRARY_WITH_PATH/s/lib/$PHP_LIBDIR/' -i config.m4 + +# Sanity check, really often broken +extver=$(sed -n '/#define PHP_MOSQUITTO_VERSION/{s/.* "//;s/".*$//;p}' php_mosquitto.h) +if test "x${extver}" != "x%{version}%{?prever:-%{prever}}"; then + : Error: Upstream extension version is ${extver}, expecting %{version}%{?prever:-%{prever}}. + exit 1 +fi +cd .. + +%if %{with_zts} +# Duplicate source tree for NTS / ZTS build +cp -pr NTS ZTS +%endif + +# Create configuration file +cat << 'EOF' | tee %{pecl_name}.ini +; Enable %{summary} +extension=%{pecl_name}.so + +EOF + + +%build +cd NTS +%{_bindir}/phpize +%configure \ + --with-lib-dir=%{_lib} \ + --with-php-config=%{_bindir}/php-config +make %{?_smp_mflags} + +%if %{with_zts} +cd ../ZTS +%{_bindir}/zts-phpize +%configure \ + --with-lib-dir=%{_lib} \ + --with-php-config=%{_bindir}/zts-php-config +make %{?_smp_mflags} +%endif + + +%install +rm -rf %{buildroot} + +make -C NTS install INSTALL_ROOT=%{buildroot} + +# install config file +install -D -m 644 %{pecl_name}.ini %{buildroot}%{php_inidir}/%{pecl_name}.ini + +# Install XML package description +install -D -m 644 package.xml %{buildroot}%{pecl_xmldir}/%{name}.xml + +%if %{with_zts} +make -C ZTS install INSTALL_ROOT=%{buildroot} + +install -D -m 644 %{pecl_name}.ini %{buildroot}%{php_ztsinidir}/%{pecl_name}.ini +%endif + +# Test & Documentation +for i in $(grep 'role="doc"' package.xml | sed -e 's/^.*name="//;s/".*$//') +do install -Dpm 644 NTS/$i %{buildroot}%{pecl_docdir}/%{pecl_name}/$i +done + + +%post +%{pecl_install} %{pecl_xmldir}/%{name}.xml >/dev/null || : + + +%postun +if [ $1 -eq 0 ] ; then + %{pecl_uninstall} %{pecl_name} >/dev/null || : +fi + + +%check +cd NTS +: Minimal load test for NTS extension +%{__php} --no-php-ini \ + --define extension=modules/%{pecl_name}.so \ + --modules | grep %{pecl_name} + +%if %{with_zts} +cd ../ZTS +: Minimal load test for ZTS extension +%{__ztsphp} --no-php-ini \ + --define extension=modules/%{pecl_name}.so \ + --modules | grep %{pecl_name} +%endif + + +%clean +rm -rf %{buildroot} + + +%files +%defattr(-,root,root,-) +%doc %{pecl_docdir}/%{pecl_name} +%{pecl_xmldir}/%{name}.xml +%config(noreplace) %{php_inidir}/%{pecl_name}.ini +%{php_extdir}/%{pecl_name}.so + +%if %{with_zts} +%config(noreplace) %{php_ztsinidir}/%{pecl_name}.ini +%{php_ztsextdir}/%{pecl_name}.so +%endif + + +%changelog +* Wed Dec 11 2013 Remi Collet - 0.2.1-1 +- initial package, version 0.2.1 (alpha) -- cgit