summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--LICENSE26
-rw-r--r--Makefile4
-rw-r--r--config.m455
-rw-r--r--php-pecl-varnish.spec167
4 files changed, 252 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..971d7ec
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,26 @@
+Copyright (c) 2011-2013 Anatol Belski
+All rights reserved.
+
+Author: Anatol Belski <ab@php.net>
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
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/config.m4 b/config.m4
new file mode 100644
index 0000000..eceb62d
--- /dev/null
+++ b/config.m4
@@ -0,0 +1,55 @@
+ PHP_ARG_WITH(varnish, for varnish support,
+ [ --with-varnish Include varnish support])
+
+if test "$PHP_VARNISH" != "no"; then
+
+ AC_CHECK_HEADER(fcntl.h)
+ AC_CHECK_HEADER(sys/types.h)
+ AC_CHECK_HEADER(sys/socket.h)
+ AC_CHECK_HEADER(netinet/in.h)
+ AC_CHECK_HEADER(arpa/inet.h)
+ AC_CHECK_HEADER(netdb.h)
+
+ dnl # --with-varnish -> check with-path
+ SEARCH_PATH="$PHP_VARNISH /usr/local /usr"
+ SEARCH_FOR="varnishapi.h"
+ AC_MSG_CHECKING([for varnish files in default path])
+ for i in $SEARCH_PATH ; do
+ if test -r $i/include/varnish/$SEARCH_FOR; then
+ VARNISH_INCDIR=$i/include/varnish
+ VARNISH_LIBDIR=$i/$PHP_LIBDIR
+ elif test -r $i/include/$SEARCH_FOR; then
+ VARNISH_INCDIR=$i/include
+ VARNISH_LIBDIR=$i/$PHP_LIBDIR
+ fi
+ done
+
+ if test -z "$VARNISH_INCDIR"; then
+ AC_MSG_RESULT([not found])
+ AC_MSG_ERROR([Please reinstall the varnish distribution])
+ else
+ AC_MSG_RESULT(headers found in $VARNISH_INCDIR)
+ fi
+
+ PHP_ADD_INCLUDE($VARNISH_INCDIR)
+ AC_CHECK_HEADER([$VARNISH_INCDIR/varnishapi.h], [], AC_MSG_ERROR('varnishapi.h' header not found))
+ AC_CHECK_HEADER([$VARNISH_INCDIR/vcli.h], [], AC_MSG_ERROR('vcli.h' header not found))
+ AC_CHECK_HEADER([$VARNISH_INCDIR/vsl.h], [], AC_MSG_ERROR('vsl.h' header not found))
+
+ LIBNAME=varnishapi
+ LIBSYMBOL=VSM_New
+
+ PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
+ [
+ PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $VARNISH_LIBDIR, VARNISH_SHARED_LIBADD)
+ AC_DEFINE(HAVE_VARNISHAPILIB,1,[ ])
+ ],[
+ AC_MSG_ERROR([wrong varnishapi lib version or lib not found])
+ ],[
+ -L$VARNISH_LIBDIR -lm
+ ])
+
+ PHP_SUBST(VARNISH_SHARED_LIBADD)
+
+ PHP_NEW_EXTENSION(varnish, varnish.c adm.c varnish_lib.c sha2.c exception.c stat.c log.c, $ext_shared)
+fi
diff --git a/php-pecl-varnish.spec b/php-pecl-varnish.spec
new file mode 100644
index 0000000..e5e9987
--- /dev/null
+++ b/php-pecl-varnish.spec
@@ -0,0 +1,167 @@
+# spec file for php-pecl-varnish
+#
+# Copyright (c) 2013 Remi Collet
+# License: CC-BY-SA
+# http://creativecommons.org/licenses/by-sa/3.0/
+#
+# Please, preserve the changelog entries
+#
+%{!?php_inidir: %{expand: %%global php_inidir %{_sysconfdir}/php.d}}
+%{!?__pecl: %{expand: %%global __pecl %{_bindir}/pecl}}
+
+%global with_zts 0%{?__ztsphp:1}
+%global pecl_name varnish
+
+Summary: Varnish Cache bindings
+Name: php-pecl-%{pecl_name}
+Version: 1.0.0
+Release: 1%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}
+License: BSD
+Group: Development/Languages
+URL: http://pecl.php.net/package/%{pecl_name}
+Source0: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz
+
+# will be in next version
+# http://svn.php.net/viewvc/pecl/varnish/trunk/LICENSE?view=co
+Source1: LICENSE
+# http://svn.php.net/viewvc/pecl/varnish/trunk/config.m4?view=co
+Source2: config.m4
+
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildRequires: php-devel > 5.3
+BuildRequires: php-pear
+BuildRequires: varnish-libs-devel > 3
+
+Requires(post): %{__pecl}
+Requires(postun): %{__pecl}
+Requires: php(zend-abi) = %{php_zend_api}
+Requires: php(api) = %{php_core_api}
+
+Provides: php-%{pecl_name} = %{version}
+Provides: php-%{pecl_name}%{?_isa} = %{version}
+Provides: php-pecl(%{pecl_name}) = %{version}
+Provides: php-pecl(%{pecl_name})%{?_isa} = %{version}
+
+# Filter shared private
+%{?filter_provides_in: %filter_provides_in %{_libdir}/.*\.so$}
+%{?filter_setup}
+
+%description
+Varnish Cache is an open source, state of the art web application accelerator.
+
+The extension makes it possible to interact with a running varnish instance
+through TCP socket or shared memory.
+
+
+%prep
+%setup -q -c
+mv %{pecl_name}-%{version} NTS
+
+cd NTS
+cp %{SOURCE1} %{SOURCE2} .
+
+# Sanity check, really often broken
+extver=$(sed -n '/#define PHP_VARNISH_EXT_VERSION/{s/.* "//;s/".*$//;p}' php_varnish.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 > %{pecl_name}.ini << 'EOF'
+; Enable %{pecl_name} extension module
+extension=%{pecl_name}.so
+EOF
+
+
+%build
+cd NTS
+%{_bindir}/phpize
+%configure \
+ --with-libdir=%{_lib} \
+ --with-php-config=%{_bindir}/php-config
+make %{?_smp_mflags}
+
+%if %{with_zts}
+cd ../ZTS
+%{_bindir}/zts-phpize
+%configure \
+ --with-libdir=%{_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
+
+
+%post
+%{pecl_install} %{pecl_xmldir}/%{name}.xml >/dev/null || :
+
+
+%postun
+if [ $1 -eq 0 ] ; then
+ %{pecl_uninstall} %{pecl_name} >/dev/null || :
+fi
+
+
+%check
+: Minimal load test for NTS extension
+php --no-php-ini \
+ --define extension=NTS/modules/%{pecl_name}.so \
+ --modules | grep %{pecl_name}
+
+%if %{with_zts}
+: Minimal load test for ZTS extension
+%{__ztsphp} --no-php-ini \
+ --define extension=ZTS/modules/%{pecl_name}.so \
+ --modules | grep %{pecl_name}
+%endif
+
+# Don't run upstream test suite which requires some varnish
+# server and configuration
+
+
+%clean
+rm -rf %{buildroot}
+
+
+%files
+%defattr(-,root,root,-)
+%doc NTS/{CREDITS,LICENSE}
+%{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
+* Mon Sep 30 2013 Remi Collet <remi@fedoraproject.org> - 1.0.0-1
+- initial package