LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File php56.spec of Package php56-zts (Project home:zhyravskiy_o)

#
# spec file for package php5
#
# Copyright (c) 2017 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


# _without_ make_test by default
# use build-test.sh for testing!
%bcond_with make_test

# systemd first added in 12.1
%if 0%{suse_version} < 1210
%define _without_systemd 1
%endif

%bcond_with     firebird
%bcond_without  spell
%bcond_without  systemd

%global apiver            20131106
%global zendver           20131226
%define suhosin_version   0.9.38

%define pkg_name          php56-zts
%define extension_dir     %{_libdir}/%{pkg_name}/extensions
%define peardir           %{_datadir}/%{pkg_name}/PEAR
%define php_sysconf       %{_sysconfdir}/%{pkg_name}
%define _x11prefix        %(pkg-config --variable=prefix xft)
%define need_libxml2_hack %(if [ -e %{_includedir}/libxml/parser.h ]; then if grep -q XML_PARSE_OLDSAX %{_includedir}/libxml/parser.h; then echo 1; else echo 0; fi; else echo 0; fi)

Name:           php56-zts
Version:        5.6.33
Release:        0
Summary:        PHP5 Core Files
License:        PHP-3.01
Group:          Development/Languages/Other

Url:            http://www.php.net
Source0:        http://us2.php.net/distributions/php-%{version}.tar.xz
Source1:        php-suse-addons.tar.bz2
Source2:        https://download.suhosin.org/suhosin-%{suhosin_version}.tar.gz
Source4:        README.SUSE-pear
Source5:        README.macros
Source6:        macros.php
Source7:        php-fpm.init
Source8:        http://us3.php.net/distributions/php-%{version}.tar.xz.asc
Source9:        php5.keyring
Source10:       README.default_socket_timeout
Source100:      build-test.sh

## SUSE specific patches
Patch0:         php5-phpize.patch
Patch1:         php5-apache_sapi_install.patch
Patch2:         php5-php-config.patch
Patch3:         php5-ini.patch
Patch4:         php5-no-build-date.patch
Patch5:         php5-pts.patch
Patch6:         php5-openssl.patch
Patch7:         php5-systzdata-r12.patch
Patch8:         php5-systemd-unit.patch
Patch9:         php5-depdb-path.patch
Patch10:        php5-mbstring-missing-return.patch

## Bugfix patches
# this is from https://raw.github.com/NewEraCracker/suhosin-patches/, check for official
# one from suhosin git
Patch11:        php5-BNC-457056.patch
Patch12:        php5-cloexec.patch
Patch13:        php5-missing-extdeps.patch
# following patch is to fix configure tests for crypt; the aim is to have php
# built against glibc's crypt; problem is, that our glibc doesn't support extended
# DES, so as soon as upstream fixes this, don't forgot to remove extended DES
# from their checking as I indicated in crypt-tests.patch yet, or php will
# silently use his own implementation again
Patch14:        php5-crypt-tests.patch
# related to previous patch; !(defined(_REENTRANT) || defined(_THREAD_SAFE))
Patch16:        php5-format-string-issues.patch
Patch17:        php5-per-mod-log.patch
Patch18:        php5-apache24-updates.patch
Patch19:        php5-crypto-checks.patch
# https://bugs.php.net/bug.php?id=53007
Patch20:        php5-odbc-cmp-int-cast.patch
# https://bugs.php.net/bug.php?id=70461
Patch21:        php5-fix_net-snmp_disable_MD5.patch

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  apache-rpm-macros
BuildRequires:  apache2-devel
BuildRequires:  autoconf
BuildRequires:  bison
BuildRequires:  curl
BuildRequires:  curl-devel
BuildRequires:  cyrus-sasl-devel
BuildRequires:  db-devel
BuildRequires:  enchant-devel
BuildRequires:  freetype2-devel
BuildRequires:  gcc-c++
BuildRequires:  gd-devel
BuildRequires:  gmp-devel
BuildRequires:  imap-devel
BuildRequires:  krb5-devel
BuildRequires:  libapparmor-devel
BuildRequires:  libbz2-devel
BuildRequires:  libedit-devel
BuildRequires:  libevent-devel
BuildRequires:  libicu-devel
BuildRequires:  libjpeg-devel
BuildRequires:  libmcrypt-devel
BuildRequires:  libopenssl-devel
BuildRequires:  libpng-devel
BuildRequires:  libtidy-devel
BuildRequires:  libtiff-devel
BuildRequires:  libtool
BuildRequires:  libxslt-devel
BuildRequires:  ncurses-devel
BuildRequires:  net-snmp-devel
BuildRequires:  openldap2-devel
BuildRequires:  pam-devel
BuildRequires:  pcre-devel
BuildRequires:  pkgconfig
BuildRequires:  postfix
BuildRequires:  postgresql-devel
BuildRequires:  re2c
BuildRequires:  sqlite3-devel
BuildRequires:  tcpd-devel
BuildRequires:  unixODBC-devel
BuildRequires:  update-alternatives
BuildRequires:  xz

%if 0%{suse_version} > 1110
BuildRequires:  pkgconfig(vpx)
BuildRequires:  pkgconfig(xft)
BuildRequires:  pkgconfig(xpm)
%else
BuildRequires:  xorg-x11-devel
%endif

%if 0%{suse_version} > 1110
BuildRequires:  freetds-devel
%endif

%if 0%{suse_version} >= 1320
BuildRequires:  libzip-devel
%endif

%if %{with spell}
BuildRequires:  aspell-devel
%endif

%define build_firebird 0
%if %{with firebird}
%if 0%{suse_version} > 1210
# firebird-devel was merged into libfbclient2-devel for firebird 3
%if 0%{suse_version} <= 1320
BuildRequires:  firebird-devel
BuildRequires:  libfbclient2-devel
%else
BuildRequires:  libfbclient-devel
%endif
%define build_firebird 1
%endif
%endif

# 10.3 does not install sendmail binary with the minimal system
Requires:       smtp_daemon
Requires:       timezone

# I would like this to become a hard dependency, as PHP is
# documented to have this modules by default (no addtional libs are needed)
Recommends:     php56-ctype php56-dom php56-iconv php56-sqlite php56-tokenizer
Recommends:     php56-xmlreader php56-xmlwriter php56-json

# other highly reccommended extensions
# suggest php5-* instead of php-* [bsc#1022158c#4]
Suggests:       php56-mbstring php56-gd php5-pear php56-gettext php56-mysql php56-suhosin

## Provides
Provides:       php56 = %{version}
Provides:       php5 = %{version}
Provides:       php = %{version}
Provides:       php-api = %{apiver}
Provides:       php-zend-abi = %{zendver}
Provides:       php(api) = %{apiver}
Provides:       php(zend-abi) = %{zendver}

# builtin extensions
Provides:       php-date = %{version}
Provides:       php-filter = %{version}
Provides:       php-hash = %{version}
Provides:       php-mhash = %{version}
Provides:       php-pcre = %{version}
Provides:       php-reflection = %{version}
Provides:       php-session = %{version}
Provides:       php-simplexml = %{version}
Provides:       php-spl = %{version}
Provides:       php-xml = %{version}
Provides:       php56-date = %{version}
Provides:       php56-filter = %{version}
Provides:       php56-hash = %{version}
Provides:       php56-mhash = %{version}
Provides:       php56-pcre = %{version}
Provides:       php56-reflection = %{version}
Provides:       php56-session = %{version}
Provides:       php56-simplexml = %{version}
Provides:       php56-spl = %{version}
Provides:       php56-xml = %{version}
Provides:       zend = %{zendver}
# builtin, nowdays required for everything that uses sha2
Provides:       php5-hash = %{version}
Obsoletes:      php5-hash < %{version}
# Old extension, nowdays provided as a "wrapper" in in the hash extension for backward compat.
Provides:       php5-mhash = %{version}
Obsoletes:      php5-mhash < %{version}

# extensions that are no longer here
Obsoletes:      php5-dbase
Obsoletes:      php5-dbx
Obsoletes:      php5-dio
Obsoletes:      php5-fam
Obsoletes:      php5-filepro
Obsoletes:      php5-ncurses
Obsoletes:      php5-yp

# Don't mix these packages with php53-* from SLES 11 SP2
Conflicts:      php53

%description
This package contains the PHP 5 core files, including PHP binary (CLI)
and PHP configuration (php.ini). This package must be installed in
order to use PHP. Additionally, extension modules and server modules
(e.g. for Apache) may be installed.

Additional documentation is available in package php-doc.


%package devel
Summary:        Include files of PHP5
Group:          Development/Languages/C and C++
# this is required by the installed  development headers
Requires:       php56 = %{version}
Requires:       glibc-devel
Requires:       libxml2-devel
# this is needed for "pecl" functionality
Requires:       autoconf
Requires:       automake
Requires:       libtool
Requires:       pcre-devel
Provides:       pecl = %{version}
Provides:       php-devel = %{version}
Provides:       php56-devel = %{version}
Provides:       php-macros = 2.0
Obsoletes:      php-macros < 2.0

%description devel
PHP is a server-side, cross-platform, HTML embedded scripting language.
If you are completely new to PHP and want to get some idea of how it
works, have a look at the Introductory Tutorial.  Once you get beyond
that have a look at the example archive sites and some of the other
resources available in the Links section. PHP5 is the latest version.


%package pear
Summary:        PHP Extension and Application Repository
Group:          Development/Libraries/PHP
%if 0%{?suse_version} > 1110
BuildArch:      noarch
%endif
Requires:       php56-zlib = %{version}
Requires:       php-pear-Archive_Tar
Provides:       php-pear = %{version}
Provides:       php56-pear = %{version}

%description pear
PEAR is a code repository for PHP extensions and PHP library code
similar to TeX's CTAN and Perl's CPAN. This package provides an access
to the repository.

See http://pear.php.net/manual/ for more details.


%package pear-Archive_Tar
Summary:        Tar file management class
Group:          Productivity/Networking/Web/Servers
%if 0%{?suse_version} > 1110
BuildArch:      noarch
%endif
Requires:       php56-pear = %{version}
# php5-pear-Archive_Tar provides Tar.php, which is provided
# by pear package itself; php5-pear-Archive_Tar was dropped
# on version 1.3.10, install-pear-nozlib.phar
# provides 1.4.0 currently
Provides:       php-pear-Archive_Tar = 1.4.0
Provides:       php5-pear-Archive_Tar = 1.4.0
Obsoletes:      php-pear-Archive_Tar < 1.3.11

%description pear-Archive_Tar
This class provides handling of tar files in PHP.
It supports creating, listing, extracting and adding to tar files.
Gzip support is available if PHP has the zlib extension built-in orloaded. 
Bz2 compression is also supported with the bz2 extension loaded.


%package -n apache2-mod_php56
Summary:        PHP5 Module for Apache 2.0
Group:          Productivity/Networking/Web/Servers
Requires:       %{apache_mmn}
Requires:       php56 = %{version}
Requires:       apache2-prefork
PreReq:         apache2
Conflicts:      apache2-mod_php4
Provides:       mod_php_any = %{version}
Provides:       php-date = %{version}
Provides:       php-filter = %{version}
Provides:       php-pcre = %{version}
Provides:       php-reflection = %{version}
Provides:       php-session = %{version}
Provides:       php-simplexml = %{version}
Provides:       php-spl = %{version}
Provides:       php-xml = %{version}
Provides:       php56-date = %{version}
Provides:       php56-filter = %{version}
Provides:       php56-pcre = %{version}
Provides:       php56-reflection = %{version}
Provides:       php56-session = %{version}
Provides:       php56-simplexml = %{version}
Provides:       php56-spl = %{version}
Provides:       php56-xml = %{version}
Supplements:    packageand(%{apache_mmn}:php5)

%description -n apache2-mod_php56
PHP is a server-side, cross-platform HTML embedded scripting language.
If you are completely new to PHP and want to get some idea of how it
works, have a look at the Introductory tutorial. Once you get beyond
that, have a look at the example archive sites and some of the other
resources available in the links section.

Please refer to /usr/share/doc/packages/php5/README.SUSE for
information on how to load the module into the Apache webserver.


%package fastcgi
Summary:        FastCGI PHP5 Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       mod_php_any = %{version}
Provides:       php-cgi = %{version}
Provides:       php-date = %{version}
Provides:       php-fastcgi = %{version}
Provides:       php-filter = %{version}
Provides:       php-pcre = %{version}
Provides:       php-reflection = %{version}
Provides:       php-session = %{version}
Provides:       php-simplexml = %{version}
Provides:       php-spl = %{version}
Provides:       php-xml = %{version}
Provides:       php56-cgi = %{version}
Provides:       php56-date = %{version}
Provides:       php56-fastcgi = %{version}
Provides:       php56-filter = %{version}
Provides:       php56-pcre = %{version}
Provides:       php56-reflection = %{version}
Provides:       php56-session = %{version}
Provides:       php56-simplexml = %{version}
Provides:       php56-spl = %{version}
Provides:       php56-xml = %{version}

%description fastcgi
PHP is a server-side, cross-platform HTML embedded scripting language.
If you are completely new to PHP and want to get some idea of how it
works, have a look at the Introductory tutorial. Once you get beyond
that have a look at the example archive sites and some of the other
resources available in the links section.

Please refer to /usr/share/doc/packages/php5/README.FastCGI for
information on how to use this module.


%package fpm
Summary:        FastCGI Process Manager PHP5 Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       mod_php_any = %{version}
Provides:       php-date = %{version}
Provides:       php-filter = %{version}
Provides:       php-fpm = %{version}
Provides:       php-pcre = %{version}
Provides:       php-reflection = %{version}
Provides:       php-session = %{version}
Provides:       php-simplexml = %{version}
Provides:       php-spl = %{version}
Provides:       php-xml = %{version}
Provides:       php56-date = %{version}
Provides:       php56-filter = %{version}
Provides:       php56-fpm = %{version}
Provides:       php56-pcre = %{version}
Provides:       php56-reflection = %{version}
Provides:       php56-session = %{version}
Provides:       php56-simplexml = %{version}
Provides:       php56-spl = %{version}
Provides:       php56-xml = %{version}

%if %{with systemd}
%{systemd_requires}
BuildRequires:  pkgconfig(libsystemd)
%else
Requires(pre):  %insserv_prereq
%endif

%description fpm
PHP is a server-side, cross-platform HTML embedded scripting language.
If you are completely new to PHP and want to get some idea of how it
works, have a look at the Introductory tutorial. Once you get beyond
that have a look at the example archive sites and some of the other
resources available in the links section.

Please refer to /usr/share/doc/packages/php5/README.FastCGI for
information on how to use this module.


%package bcmath
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-bcmath = %{version}
Provides:       php56-bcmath = %{version}

%description bcmath
Binary Calculator which supports numbers of any size and precision,
represented as strings.


%package bz2
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-bz2 = %{version}
Provides:       php56-bz2 = %{version}

%description bz2
PHP functions to read and write bzip2 (.bz2) compressed files.


%package calendar
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-calendar = %{version}
Provides:       php56-calendar = %{version}

%description calendar
PHP functions for converting between different calendar formats.


%package ctype
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-ctype = %{version}
Provides:       php56-ctype = %{version}

%description ctype
PHP functions for checking whether a character or string falls into a
certain character class according to the current locale.


%package curl
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-curl = %{version}
Provides:       php56-curl = %{version}

%description curl
PHP interface to libcurl that allows you to connect to and communicate
with servers of many different types, using protocols of many different
types.


%package dba
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-dba = %{version}
Provides:       php56-dba = %{version}

%description dba
This is a general abstraction layer for several file-based databases.
As such, functionality is limited to a common subset of features
supported by modern databases such as Sleepycat Software's DB2. (This
is not to be confused with IBM's DB2 software, which is supported
through the ODBC functions.)


%package dom
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-dom = %{version}
Provides:       php56-dom = %{version}

%description dom
This module adds DOM support.


%package enchant
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-enchant = %{version}
Provides:       php56-enchant = %{version}

%description enchant
Enchant is the PHP binding for the Enchant library. Enchant steps in to provide uniformity and conformity on top of all spelling libraries, and implements certain features that may be lacking in any individual provider library. Everything should "just work" for any and every definition of "just working."


%package exif
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Requires:       php56-mbstring = %{version}
Provides:       php-exif = %{version}
Provides:       php56-exif = %{version}

%description exif
PHP functions for extracting EXIF (metadata from images) information
stored in headers of JPEG and TIFF images.


%package fileinfo
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-fileinfo = %{version}
Provides:       php56-fileinfo = %{version}

%description fileinfo
The functions in this module try to guess the content type and encoding of a file by looking for certain magic byte sequences at specific positions within the file. While this is not a bullet proof approach the heuristics used do a very good job.


%package ftp
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Requires:       php56-openssl = %{version}
Provides:       php-ftp = %{version}
Provides:       php56-ftp = %{version}

%description ftp
PHP functions for access to file servers speaking the File Transfer
Protocol (FTP) as defined in rfc959.


%package gd
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-gd = %{version}
Provides:       php56-gd = %{version}

%description gd
PHP functions to create and manipulate image files in a variety of
different image formats, including GIF, PNG, JPEG, WBMP, and XPM. Even
more convenient: PHP can output image streams directly to a browser.


%package gettext
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-gettext = %{version}
Provides:       php56-gettext = %{version}

%description gettext
PHP functions that implement an NLS (Native Language Support) API which
can be used to internationalize your PHP applications.


%package gmp
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-gmp = %{version}
Provides:       php56-gmp = %{version}

%description gmp
PHP functions for work with arbitrary-length integers using the GNU MP
library.


%package iconv
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-iconv = %{version}
Provides:       php56-iconv = %{version}

%description iconv
PHP interface to iconv character set conversion facility.


%package imap
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-imap = %{version}
Provides:       php56-imap = %{version}

%description imap
PHP functions in this extension are not limited to the IMAP protocol,
despite their name. The underlying c-client library also supports NNTP,
POP3 and local mailbox access methods.


%package intl
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-intl = %{version}
Provides:       php56-intl = %{version}

%description intl
Internationalization extension (further is referred as Intl) is a wrapper for ICU library, enabling PHP programmers to perform UCA-conformant collation and date/time/number/currency formatting in their scripts.


%package json
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-json = %{version}
Provides:       php56-json = %{version}

%description json
Support for JSON (JavaScript Object Notation) serialization.


%package ldap
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Requires:       php56-openssl = %{version}
Provides:       php-ldap = %{version}
Provides:       php56-ldap = %{version}

%description ldap
PHP interface to Lightweight Directory Access Protocol (LDAP).


%package mbstring
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-mbstring = %{version}
Provides:       php56-mbstring = %{version}

%description mbstring
This extension provides multi-byte character safe string functions and
other utility functions such as conversion functions.


%package mcrypt
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-mcrypt = %{version}
Provides:       php56-mcrypt = %{version}

%description mcrypt
PHP interface to the mcrypt library, which supports a wide variety of
block algorithms.


%package mssql
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-mssql = %{version}
Provides:       php56-mssql = %{version}
Provides:       php_any_db = %{version}

%description mssql
PHP functions for access to MSSQL database servers.


%package mysql
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Requires:       php56-pdo = %{version}
Provides:       php-mysql = %{version}
Provides:       php56-mysql = %{version}
Provides:       php56-mysqli = %{version}
Provides:       php5-mysqli = %{version}
Provides:       php5-pdo_mysql = %{version}
Provides:       php_any_db = %{version}
Obsoletes:      php5-mysqli < %{version}
Obsoletes:      php5-pdo_mysql < %{version}

%description mysql
PHP functions for access to MySQL database servers.


%if %{build_firebird}
%package firebird
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Requires:       php56-pdo = %{version}
Provides:       php-firebird = %{version}
Provides:       php56-firebird = %{version}
Provides:       php5-interbase = %{version}
Provides:       php5-pdo_firebird = %{version}
Provides:       php_any_db = %{version}
Obsoletes:      php5-interbase < %{version}
Obsoletes:      php5-pdo_firebird < %{version}

%description firebird
PHP functions for access to firebird database servers.
%endif

%package odbc
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Requires:       php56-pdo = %{version}
Provides:       php-odbc = %{version}
Provides:       php56-odbc = %{version}
Provides:       php-pdo_odbc = %{version}

%description odbc
This module adds ODBC support.


%package opcache
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-opcache = %{version}
Provides:       php56-opcache = %{version}

%description opcache
The Zend OPcache provides faster PHP execution through
opcode caching and optimization.


%package openssl
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-openssl = %{version}
Provides:       php56-openssl = %{version}

%description openssl
This module adds OpenSSL support.


%package pcntl
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-pcntl = %{version}
Provides:       php56-pcntl = %{version}

%description pcntl
This module will attempt to implement all features related to process
spawning and control (fork(), waitpid(), signal(), WIF's, etc). This is
extremley experimental, with hope to become stable on most UNIX's. I
greatly appreciate any feedback, fixes, and or suggestions on how to
improve/better implement this functionality.


%package phar
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-phar = %{version}
Provides:       php56-phar = %{version}

%description phar
The phar extension provides a way to put entire PHP applications into a
single file called a "phar" (PHP Archive) for easy distribution and installation.


%package pdo
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-pdo = %{version}
Provides:       php56-pdo = %{version}

%description pdo
PHP Data Objects - Data Access Abstraction

- light-weight
- provides common API for common database operations
- keeps majority of PHP specific stuff in the PDO core (such as
persistent resource management); drivers should only have to worry
about getting the data and not about PHP internals.


%package pgsql
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Requires:       php56-pdo = %{version}
Provides:       php-pgsql = %{version}
Provides:       php56-pgsql = %{version}
Provides:       php5-pdo_pgsql = %{version}
Provides:       php_any_db = %{version}
Obsoletes:      php5-pdo_pgsql < %{version}

%description pgsql
PHP functions for access to PostgreSQL database servers. It includes
both traditional pgsql and pdo_pgsql drivers.


%package posix
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-posix = %{version}
Provides:       php56-posix = %{version}

%description posix
This module allows to use POSIX-like functions in PHP.


%if %{with spell}
%package pspell
Summary:        PHP5 pspell extension
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Requires:       aspell-en
Provides:       php-pspell = %{version}
Provides:       php56-pspell = %{version}

%description pspell
PHP interface to the aspell, which provides spell checking
functionality.
%endif

%package readline
Summary:        PHP5 readline extension
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-readline = %{version}
Provides:       php56-readline = %{version}

%description readline
PHP interface to libedit, which provides editable command line as well
as PHP interactive mode (php -a)


%package shmop
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-shmop = %{version}
Provides:       php56-shmop = %{version}

%description shmop
PHP functions to read, write, create and delete UNIX shared memory
segments.


%package snmp
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-snmp = %{version}
Provides:       php56-snmp = %{version}

%description snmp
PHP functions for SNMP.


%package soap
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-soap = %{version}
Provides:       php56-soap = %{version}

%description soap
This module provides SOAP support.

SOAP extension can be used to write SOAP Servers and Clients. It
supports subsets of SOAP 1.1, SOAP 1.2 and WSDL 1.1 specifications.


%package sockets
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-sockets = %{version}
Provides:       php56-sockets = %{version}

%description sockets
A low-level interface to the socket communication functions based on
the popular BSD sockets, providing the possibility to act as a socket
server as well as a client. This extension is experimental!


%package sqlite
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Requires:       php56-pdo = %{version}
Provides:       php-sqlite = %{version}
Provides:       php56-sqlite = %{version}
Provides:       php-sqlite3 = %{version}
Provides:       php5-pdo_sqlite = %{version}
Provides:       php5-sqlite3 = %{version}

%description sqlite
This is an extension for the SQLite Embeddable SQL Database Engine.
http://www.sqlite.org/

SQLite is a C library that implements an embeddable SQL database
engine. Programs that link with the SQLite library can have SQL
database access without running a separate RDBMS process.

SQLite is not a client library used to connect to a big database
server. SQLite is the server. The SQLite library reads and writes
directly to and from the database files on disk.

This package includes sqlite and pdo_sqlite modules for sqlite version
2 and 3 respectively.


%package suhosin
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-suhosin = %{suhosin_version}
Provides:       php56-suhosin = %{suhosin_version}

%description suhosin
Suhosin is an advanced protection system for PHP installations. It was
designed to protect servers and users from known and unknown flaws in
PHP applications and the PHP core.

Suhosin is binary compatible to normal PHP installation, which means it
is compatible to 3rd party binary extension like ZendOptimizer.


%package sysvmsg
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-sysvmsg = %{version}
Provides:       php56-sysvmsg = %{version}

%description sysvmsg
This module provides System V IPC support.


%package sysvsem
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-sysvsem = %{version}
Provides:       php56-sysvsem = %{version}

%description sysvsem
PHP interface for System V semaphores.


%package sysvshm
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-sysvshm = %{version}
Provides:       php56-sysvshm = %{version}

%description sysvshm
PHP interface for System V shared memory.


%package tidy
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-tidy = %{version}
Provides:       php56-tidy = %{version}

%description tidy
Tidy is an extension based on Libtidy (http://tidy.sf.net/) and allows
a PHP developer to clean, repair, and traverse HTML, XHTML, and XML
documents -- including ones with embedded scripting languages such as
PHP or ASP within them using OO constructs.


%package tokenizer
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-tokenizer = %{version}
Provides:       php56-tokenizer = %{version}

%description tokenizer
The tokenizer functions provide an interface to the PHP tokenizer
embedded in the Zend Engine. Using these functions you may write your
own PHP source analyzing or modification tools without having to deal
with the language specification at the lexical level.


%package wddx
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-wddx = %{version}
Provides:       php56-wddx = %{version}

%description wddx
PHP functions for Web Distributed Data Exchange.


%package xmlrpc
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-xmlrpc = %{version}
Provides:       php56-xmlrpc = %{version}

%description xmlrpc
This module adds XMLRPC-EPI support.


%package xsl
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Requires:       php56-dom = %{version}
Provides:       php-xsl = %{version}
Provides:       php56-xsl = %{version}

%description xsl
This module adds new XSL support to PHP.


%package xmlreader
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Requires:       php56-dom = %{version}
Provides:       php-xmlreader = %{version}
Provides:       php56-xmlreader = %{version}

%description xmlreader
XMLReader represents a reader that provides non-cached, forward-only
access to XML data. It is based upon the xmlTextReader API from libxml.


%package xmlwriter
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-xmlwriter = %{version}
Provides:       php56-xmlwriter = %{version}

%description xmlwriter
XMLWriter wraps the libxml xmlWriter API. Represents a writer that
provides a non-cached, forward-only means of generating streams or
files containing XML data.


%package zip
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-zip = %{version}
Provides:       php56-zip = %{version}

%description zip
Zip is an extension to create, modify and read zip files.


%package zlib
Summary:        PHP5 Extension Module
Group:          Development/Libraries/PHP
Requires:       php56 = %{version}
Provides:       php-zlib = %{version}
Provides:       php56-zlib = %{version}

%description zlib
PHP functions to read and write gzip (.gz) compressed files.


%prep
echo %{apache_mmn}
%setup -q -n php-%{version} -a 1
%{__tar} xf %{S:2} -C ext
%{__mv} ext/suhosin-%{suhosin_version} ext/suhosin
%{__cp} %{S:4} pear/README.SUSE
%{__cp} %{S:5} .
%{__cp} %{S:10} .

%patch0
%patch1
%patch2
%patch3
%patch4
%patch5
%patch6
%patch7
%patch8 -p1
%patch10
%if %{need_libxml2_hack}
echo "*** APPLY LIBXML2.7 FIX ***"
%patch11
%else
echo "*** SKIPPING LIBMXL2.7 FIX ***"
%endif
%patch12
%patch13
%patch14
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19
%patch20
%patch21 -p1

# Safety check for API version change.
vapi=`sed -n '/#define PHP_API_VERSION/{s/.* //;p}' main/php.h`
if test "x${vapi}" != "x%{apiver}"; then
    : Error: Upstream API version is now ${vapi}, expecting %{apiver}.
    : Update the apiver macro and rebuild.
    exit 1
fi
vzend=`sed -n '/#define ZEND_MODULE_API_NO/{s/^[^0-9]*//;p;}' Zend/zend_modules.h`
if test "x${vzend}" != "x%{zendver}"; then
    : Error: Upstream Zend ABI version is now ${vzend}, expecting %{zendver}.
    : Update the zendver macro and rebuild.
    exit 1
fi

%build
chmod 644 README.namespaces UPGRADING
# aclocal workaround - to be improved
cat `aclocal --print-ac-dir`/{libtool,ltoptions,ltsugar,ltversion,lt~obsolete}.m4 >>aclocal.m4

# Force use of system libtool:
libtoolize --force --copy
cat `aclocal --print-ac-dir`/{libtool,ltoptions,ltsugar,ltversion,lt~obsolete}.m4 >build/libtool.m4

# Regenerate configure scripts (patches change config.m4's)
touch configure.in
# we build three SAPI
%{__mkdir_p} build-apache2
%{__mkdir_p} build-fpm
%{__mkdir_p} build-fastcgi
%{__mkdir_p} build-cli

for parser in `find -name "*.re"`;do
    re2c --no-generation-date -gi "$parser" > ${parser%.*}.c
done

%{__rm} -r ext/pcre/pcrelib

# regenerate configure etc.
# workaround: suhosin-patch updates timestamp of configure, confusing buildconf
%{__rm} configure
./buildconf --force

# export flags
CFLAGS="$RPM_OPT_FLAGS -O3 -fPIE -fPIC -DPIC -D_GNU_SOURCE -fno-strict-aliasing"
CXXFLAGS="$RPM_OPT_FLAGS -O3 -fPIE -fPIC -DPIC -D_GNU_SOURCE -fno-strict-aliasing"
%if %{build_firebird}
CFLAGS="$CFLAGS -I/usr/include/firebird"
CXXFLAGS="$CXXFLAGS -I/usr/include/firebird"
%endif
export CFLAGS
export CXXFLAGS
export LDFLAGS="-pie"
export NO_INTERACTION=true
# where to install extensions
EXTENSION_DIR=%{extension_dir}
export EXTENSION_DIR
export PHP_MYSQLND_ENABLED=yes
export PHP_MYSQLND_COMPRESSION_SUPPORT=yes
# fix build-cli: libc-client.so needs -lssl
export IMAP_SHARED_LIBADD='-lssl'

# build function
Build()
{
    sapi=$1
    pushd build-$1
    shift
    ../configure \
        --prefix=%{_prefix} \
        --datadir=%{_datadir}/%{pkg_name} \
        --mandir=%{_mandir} \
        --bindir=%{_bindir} \
        --with-libdir=%{_lib} \
        --includedir=%{_includedir} \
        --sysconfdir=%{php_sysconf}/$sapi \
        --with-config-file-path=%{php_sysconf}/$sapi \
        --with-config-file-scan-dir=%{php_sysconf}/conf.d \
        --enable-libxml \
       	--enable-maintainer-zts \
        --enable-session \
%if 0%{?suse_version} > 1010
        --with-pcre-regex=%{_usr} \
%else
        --with-pcre-regex \
%endif
        --enable-xml \
        --enable-simplexml \
        --enable-spl \
        --enable-filter \
        --disable-debug \
        --enable-inline-optimization \
        --disable-rpath \
        --disable-static \
        --enable-shared \
        --with-pic \
        --with-gnu-ld \
        --enable-re2c-cgoto \
        --with-system-tzdata=%{_datadir}/zoneinfo \
        --enable-hash \
        --with-mhash \
%if 0%{suse_version} >= 1320
        --with-libzip \
%endif
        "$@" || cat config.log
    # Some modules are builtin, reasons:
    #  - libxml can not be shared (and is needed by PEAR)
    #  - spl doesn't build shared
    #  - simplexml is needed by spl
    #  - session need to be builtin, otherwise sqlite and other session engines fail
    #  - pcre is needed for PEAR
    #  - filter is builtin due security reasons
    # We have still have harcoded RPATH in some modules
    %{__sed} -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
    %{__sed} -i 's|^runpath_var=LD_RUN_PATH|runpath_var=LIBTOOL_IS_BROKED|g' libtool
    %{__make} %{?jobs:-j%jobs PHP_PEAR_PHP_BIN=%{_bindir}/php}
    popd
}

# perform all builds
# apache2 sapi
Build apache2 \
    --with-apxs2=%{apache_apxs} \
    --disable-all \
    --disable-cli

# fast-cgi sapi
Build fastcgi \
    --enable-force-cgi-redirect \
    --disable-discard-path \
    --enable-fastcgi \
    --bindir=%{_bindir} \
    --disable-cli \
    --disable-all

Build fpm \
%if %{with systemd}
    --with-fpm-systemd \
%endif
    --enable-fpm \
    --bindir=%{_bindir} \
    --disable-cli \
    --disable-all \
    --localstatedir=/var

# cli sapi with all shared modules
# Hack the built configure to also link ncurses together with libedit.
# this is reported upstream bug http://bugs.php.net/bug.php?id=21153
sed -i "s/-ledit/-ledit -lncurses/g" configure
Build cli \
    --enable-cli \
    --with-pear=%{peardir} \
    --enable-bcmath=shared \
    --enable-calendar=shared \
    --enable-ctype=shared \
    --enable-dom=shared \
    --enable-exif=shared \
    --enable-ftp=shared \
    --enable-mbstring=shared \
    --enable-mbregex \
    --enable-pcntl=shared \
    --enable-posix=shared \
    --enable-shmop=shared \
    --enable-soap=shared \
    --enable-sockets=shared \
    --enable-sysvmsg=shared \
    --enable-sysvsem=shared \
    --enable-sysvshm=shared \
    --enable-tokenizer=shared \
    --enable-wddx=shared \
    --enable-fileinfo=shared \
    --with-zlib=shared \
    --with-bz2=shared \
    --with-curl=shared \
%if 0%{suse_version} >= 1320
    --with-gd=shared,%{_usr} \
%else
    --with-gd=shared \
%endif
    --enable-gd-native-ttf \
    --with-xpm-dir=%{_x11prefix} \
    --with-freetype-dir=%{_usr} \
    --with-png-dir=%{_usr} \
    --with-jpeg-dir=%{_usr} \
    --with-zlib-dir=%{_usr} \
%if 0%{suse_version} > 1110
    --with-vpx-dir=%{_usr} \
%endif
    --with-gettext=shared \
    --with-gmp=shared \
    --with-iconv=shared \
    --with-imap=shared \
    --with-kerberos \
    --with-imap-ssl \
    --enable-json=shared \
    --with-ldap=shared \
    --with-ldap-sasl=%{_usr} \
    --with-libedit=shared,%{_usr} \
    --with-mcrypt=shared \
    --with-mysql=shared,mysqlnd \
%if %{build_firebird}
    --with-interbase=shared \
%endif
%if 0%{?suse_version} > 1110
    --with-mysql-sock=/var/run/mysql/mysql.sock \
%else
    --with-mysql-sock=/var/lib/mysql/mysql.sock \
%endif
    --with-mysqli=shared,mysqlnd \
    --with-unixODBC=shared,%{_usr} \
    --with-openssl=shared \
    --with-pgsql=shared,%{_usr} \
    --enable-phar=shared \
%if %{with spell}
    --with-pspell=shared \
    --with-enchant=shared,%{_usr} \
%endif
    --with-snmp=shared \
    --with-xmlrpc=shared \
    --enable-xmlreader=shared \
    --enable-xmlwriter=shared \
    --with-xsl=shared \
    --with-tidy=shared,%{_usr} \
    --enable-dba=shared \
    --with-db4=%{_usr} \
    --without-gdbm \
    --with-cdb \
    --with-inifile \
    --with-flatfile \
    --enable-pdo=shared \
    --with-pdo_sqlite=shared,%{_usr} \
    --with-sqlite3=shared,%{_usr} \
    --enable-sqlite-utf8 \
    --with-pdo-mysql=shared,mysqlnd \
%if %{build_firebird}
    --with-pdo-firebird=shared \
%endif
    --with-pdo-pgsql=shared,%{_usr} \
    --with-pdo-odbc=shared,unixODBC,%{_usr} \
    --enable-zip=shared \
    --enable-suhosin=shared \
    --enable-intl=shared,%{_usr} \
%if 0%{suse_version} > 1110
    --with-mssql=shared,%{_usr} \
%endif
    --disable-cgi
# things that currently do not compile:
# extensions:
#    --with-recode=shared \ error: recode extension can not be configured together with: imap mysql yaz
#disabled extensions
#    --enable-embedded-mysqli \

%check
cd build-cli
# check if we link against system libcrypt
if [ -z "$(ldd sapi/cli/php | grep libcrypt.so)" ]; then
    echo 'php do not link against system libcrypt.'
    exit 1
fi

# Run tests, using the CLI SAPI
%if %{with make_test}
export NO_INTERACTION=1 REPORT_EXIT_STATUS=1 LANG=POSIX LC_ALL=POSIX
unset TZ
%{__make} test || true
set +x
for f in `find .. -name "*.diff" -type f -print`; do
    echo "TEST FAILURE: $f --"
    cat "$f"
    echo "-- $f result ends."
done
set -x
unset NO_INTERACTION REPORT_EXIT_STATUS
%endif
# apache module test
set +x
exit_code=0
mkdir -p %{apache_test_module_dir}/htdocs
echo '<?php phpinfo(); ?>' > %{apache_test_module_dir}/htdocs/index.php
%apache_test_module_start_apache -m php5 -i php5.conf
%apache_test_module_curl -d /index.php -o %{apache_test_module_dir}/php5.txt
echo
echo 'Testing phpinfo() output'
grep 'PHP API.*%{apiver}' %{apache_test_module_dir}/php5.txt || exit_code=1
if [ $exit_code -eq 0 ]; then
  echo 'SUCCESS'
else
  echo 'FAILED'
fi
%apache_test_module_stop_apache
set -x
exit $exit_code

%install
# install function
Install()
{
    pushd build-$1
    %{__make} install INSTALL_ROOT=%{buildroot} PHP_PEAR_PHP_BIN=%{_bindir}/php
    popd
}

# do the actual installation
Install apache2

#need it for yast module
%{__mv} %{buildroot}%{apache_libexecdir}/libphp5.so %{buildroot}%{apache_libexecdir}/mod_php5.so
Install fastcgi
Install cli
Install fpm

# generate php.ini from php.ini-production:
%{__install} -d -m 755 %{buildroot}/%{php_sysconf}/conf.d
%{__install} -d -m 755 %{buildroot}/%{php_sysconf}/apache2
%{__install} -d -m 755 %{buildroot}/%{php_sysconf}/cli
%{__install} -d -m 755 %{buildroot}/%{php_sysconf}/fastcgi
%{__install} -d -m 755 %{buildroot}/%{php_sysconf}/fpm
%{__sed} "s=@extdir@=%{extension_dir}=" php.ini-production \
    > %{buildroot}/%{php_sysconf}/apache2/php.ini
%{__sed} "s=@extdir@=%{extension_dir}=" php.ini-production \
    | %{__sed} -r 's/^(html_errors|implicit_flush|max_execution_time|register_argc_argv)/;\1/' \
    > %{buildroot}/%{php_sysconf}/cli/php.ini
%{__sed} "s=@extdir@=%{extension_dir}=" php.ini-production \
    > %{buildroot}/%{php_sysconf}/fastcgi/php.ini

# prepare configuration files for each extension
extern_modules=""
for f in %{buildroot}%{extension_dir}/*; do
    if test ${f##*.} = a; then
        %{__rm} $f
        continue
    fi
    if test ${f##*.} = so; then
        f=${f%.so}
    fi
    ext=${f##*/}
    extern_modules="$extern_modules $ext"
    echo "; comment out next line to disable $ext extension in php" > %{buildroot}/%{php_sysconf}/conf.d/$ext.ini
    zend_=''
    if [ $ext == "opcache" ]; then
      # http://php.net/manual/en/opcache.installation.php
      zend_='zend_'
    fi
    echo "${zend_}extension=$ext.so" >> %{buildroot}/%{php_sysconf}/conf.d/$ext.ini
done

#suhosin configuration
%{__install} -m 644 ext/suhosin/suhosin.ini %{buildroot}/%{php_sysconf}/conf.d/suhosin.ini

# list of builtin modules
builtin_modules=`./build-cli/sapi/cli/php -m | grep -E -v '^(\[.*)?$' | sort | tr '\n' ' '`

# update readme
%{__sed} "s=@EXTERN_MODULES@=$extern_modules=;s=@BUILTIN_MODULES@=$builtin_modules=" php-suse-addons/README.SUSE > README.SUSE

# apache configuration
%{__mkdir_p} %{buildroot}%{apache_sysconfdir}/conf.d
%{__install} -m 644 php-suse-addons/sysconfig.apache2 %{buildroot}/%{apache_sysconfdir}/conf.d/%{pkg_name}.conf

# directory for sessions
%{__install} -d %{buildroot}/var/lib/%{pkg_name}

# documentation
%{__mv} sapi/cli/README README.CLI
%{__mv} sapi/cgi/README.FastCGI README.FastCGI
%{__rm} -rf %{buildroot}/{.channels,.depdb*,.filemap,.lock,usr/bin/peardev}
%{__install} -d -m 0755 %{buildroot}/%{peardir}/test

# for pear XML files
%{__install} -d -m 0755 %{buildroot}/var/lib/pear

# provide compat symlink
%{__mkdir_p} %{buildroot}/srv/www/cgi-bin
%{__ln_s} /usr/bin/php-cgi %{buildroot}/srv/www/cgi-bin/php

#fix symlink
sed -i -e "s@$RPM_BUILD_DIR/php-%{version}/build-cli/sapi/cli/php@php@g" %{buildroot}%{_bindir}/phar.phar
rm %{buildroot}%{_bindir}/phar
%{__ln_s} -f %{_bindir}/phar.phar %{buildroot}%{_bindir}/phar

# CVE-2014-5459, bnc#893849; couldn't find a way to use PHP_PEAR_CACHE_DIR 
# (install-pear is checking if the directory is writable by current user?;
#  unfortunately ENOTIME to figure out)
%{__sed} -i 's@15:"/tmp/pear/cache"@19:"/var/cache/php-pear"@' %{buildroot}%{php_sysconf}/cli/pear.conf
grep -c '/var/cache/php-pear' %{buildroot}%{php_sysconf}/cli/pear.conf || exit 1
# after the update for php 5.6.15 landed in Tumbleweed, almost all PEAR
# packages building against broke. The metadata generated when building
# the PEAR package gets written to /.<meta> instead of
# /usr/share/php5/PEAR/.<meta>, probably caused by the new PEAR option
# "metadata_dir" that was added in PEAR 1.10.0. Our specs suspect the data
# to be in the peardir (where is normally belongs).
# This option is not set in the current php5 package, but maybe providing
# a default value for this would resolve the issue for the +100 packages.
pd=%{peardir}
%{__sed} -i "s@\"metadata_dir\";s:0:\"\"@\"metadata_dir\";s:${#pd}:\"${pd}\"@" %{buildroot}%{php_sysconf}/cli/pear.conf
grep -c "\"metadata_dir\";s:${#pd}:\"${pd}\""  %{buildroot}%{php_sysconf}/cli/pear.conf || exit 1

# Install the macros file:
install -d $RPM_BUILD_ROOT%{_sysconfdir}/rpm
sed -e "s/@PHP_APIVER@/%{apiver}/;s/@PHP_ZENDVER@/%{zendver}/" \
    < $RPM_SOURCE_DIR/macros.php > macros.php
install -m 644 -c macros.php \
           $RPM_BUILD_ROOT%{_sysconfdir}/rpm/macros.php

#install fpm init script.
%if %{with systemd}
install -D -m 0644 ./build-fpm/sapi/fpm/php-fpm.service %{buildroot}%{_unitdir}/php-fpm.service
%if 0%{suse_version} > 1220
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rcphp-fpm
%else
ln -s /sbin/service %{buildroot}%{_sbindir}/rcphp-fpm
%endif
%else
install -d %{buildroot}%{_sysconfdir}/init.d
install -m 755 -c %{S:7} %{buildroot}%{_sysconfdir}/init.d/php-fpm
ln -s %{_sysconfdir}/init.d/php-fpm %{buildroot}%{_sbindir}/rcphp-fpm
%endif
# pear installer installs .depdb{,lock} files into %{buildroot}%{peardir}
# along with .lock, .registry when metadata_dir is not set but does not 
# install them if metadata_dir is set; our Horde packages expect them there 
# though, (they rm them without -f) so always install them along
cd %{buildroot}/%{peardir}
patch -p0 < %{PATCH9}

%post -n apache2-mod_php56
#some distro versions does not have this tool.
if [ -x /usr/sbin/a2enmod ]; then
    if a2enmod -q php4 && ! a2enmod -q php5; then
        a2dismod php4
        a2enmod php5
    fi
fi

%preun -n apache2-mod_php56
if [ "$1" = "0" ]; then
    if [ -x /usr/sbin/a2enmod ]; then
        if a2enmod -q php5; then
            a2dismod php5
        fi
    fi
fi

%if %{with systemd}
%pre fpm
%service_add_pre php-fpm.service

%postun fpm
%service_del_postun php-fpm.service

%preun fpm
%service_del_preun php-fpm.service

%post fpm
%service_add_post php-fpm.service
%else
%postun fpm
%restart_on_update php-fpm
%insserv_cleanup

%preun fpm
%stop_on_removal php-fpm

%post fpm
%{fillup_and_insserv -f php-fpm}
%endif

%postun -n apache2-mod_php56
# request restart apache instanaces (which loaded php5) after apache2-mod_php56 package update
if [ $1 -eq 1 ]; then
  %apache_request_restart -m php5
fi

%posttrans -n apache2-mod_php56
# restart apache instances which have this module after zypper or rpm transaction, if not
# have restarted already in other posttrans
%apache_restart_if_needed

%files
%defattr(-, root, root)
%doc README* CODING_STANDARDS CREDITS EXTENSIONS LICENSE NEWS UPGRADING
%doc php-suse-addons/test.php5
%doc %{_mandir}/man1/*
%dir %{php_sysconf}
%dir %{php_sysconf}/conf.d
%dir %{php_sysconf}/cli
%config(noreplace) %{php_sysconf}/cli/php.ini
%{_bindir}/php
%dir %{_libdir}/%{pkg_name}
%dir %{extension_dir}
%dir %{_datadir}/%{pkg_name}
%attr(0755, wwwrun, root) %dir /var/lib/%{pkg_name}

%files devel
%defattr(-, root, root)
%doc README.macros
%{_includedir}/%{pkg_name}
%{_bindir}/phpize
%{_bindir}/php-config
%{_bindir}/pecl
%{_datadir}/%{pkg_name}/build
%config %{_sysconfdir}/rpm/macros.php

%files pear
%defattr(-, root, root)
%doc pear/README.SUSE
%{_bindir}/pear
%config(noreplace) %{php_sysconf}/cli/pear.conf
%{peardir}
%exclude %{peardir}/Archive/Tar.php
%exclude %{peardir}/doc/Archive_Tar
%dir /var/lib/pear

%files pear-Archive_Tar
%defattr(-, root, root)
%dir %{peardir}/Archive
%{peardir}/Archive/Tar.php
%{peardir}/doc/Archive_Tar

%files fastcgi
%defattr(-, root, root)
%{_bindir}/php-cgi
/srv/www/cgi-bin/php
%dir %{php_sysconf}/fastcgi
%config(noreplace) %{php_sysconf}/fastcgi/php.ini

%files fpm
%defattr(-, root, root)
%{_sbindir}/php-fpm
%dir %{php_sysconf}/fpm
%config %{php_sysconf}/fpm/php-fpm.conf.default
%{_mandir}/man8/php-fpm.8.gz
%{_sbindir}/rcphp-fpm
%dir %{_datadir}/%{pkg_name}/fpm
%{_datadir}/%{pkg_name}/fpm/status.html
%if %{with systemd}
%{_unitdir}/php-fpm.service
%else
%config /etc/init.d/php-fpm
%endif

%files -n apache2-mod_php56
%defattr(-,root,root)
%{apache_libexecdir}/mod_php5.so
%dir %{php_sysconf}/apache2
%config(noreplace) %{php_sysconf}/apache2/php.ini
%config(noreplace) %{apache_sysconfdir}/conf.d/%{pkg_name}.conf

%files bcmath
%defattr(644,root,root,755)
%{extension_dir}/bcmath.so
%config(noreplace) %{php_sysconf}/conf.d/bcmath.ini

%files bz2
%defattr(644,root,root,755)
%{extension_dir}/bz2.so
%config(noreplace) %{php_sysconf}/conf.d/bz2.ini

%files calendar
%defattr(644,root,root,755)
%{extension_dir}/calendar.so
%config(noreplace) %{php_sysconf}/conf.d/calendar.ini

%files ctype
%defattr(644,root,root,755)
%{extension_dir}/ctype.so
%config(noreplace) %{php_sysconf}/conf.d/ctype.ini

%files curl
%defattr(644,root,root,755)
%{extension_dir}/curl.so
%config(noreplace) %{php_sysconf}/conf.d/curl.ini

%files dba
%defattr(644,root,root,755)
%{extension_dir}/dba.so
%config(noreplace) %{php_sysconf}/conf.d/dba.ini

%files dom
%defattr(644,root,root,755)
%{extension_dir}/dom.so
%config(noreplace) %{php_sysconf}/conf.d/dom.ini

%files enchant
%defattr(644,root,root,755)
%{extension_dir}/enchant.so
%config(noreplace) %{php_sysconf}/conf.d/enchant.ini

%files exif
%defattr(644,root,root,755)
%{extension_dir}/exif.so
%config(noreplace) %{php_sysconf}/conf.d/exif.ini

%files fileinfo
%defattr(644,root,root,755)
%{extension_dir}/fileinfo.so
%config(noreplace) %{php_sysconf}/conf.d/fileinfo.ini

%files ftp
%defattr(644,root,root,755)
%{extension_dir}/ftp.so
%config(noreplace) %{php_sysconf}/conf.d/ftp.ini

%files gd
%defattr(644,root,root,755)
%{extension_dir}/gd.so
%config(noreplace) %{php_sysconf}/conf.d/gd.ini

%files gettext
%defattr(644,root,root,755)
%{extension_dir}/gettext.so
%config(noreplace) %{php_sysconf}/conf.d/gettext.ini

%files gmp
%defattr(644,root,root,755)
%{extension_dir}/gmp.so
%config(noreplace) %{php_sysconf}/conf.d/gmp.ini

%files iconv
%defattr(644,root,root,755)
%{extension_dir}/iconv.so
%config(noreplace) %{php_sysconf}/conf.d/iconv.ini

%files imap
%defattr(644,root,root,755)
%{extension_dir}/imap.so
%config(noreplace) %{php_sysconf}/conf.d/imap.ini

%files intl
%defattr(644,root,root,755)
%{extension_dir}/intl.so
%config(noreplace) %{php_sysconf}/conf.d/intl.ini

%files json
%defattr(644,root,root,755)
%{extension_dir}/json.so
%config(noreplace) %{php_sysconf}/conf.d/json.ini

%files ldap
%defattr(644,root,root,755)
%{extension_dir}/ldap.so
%config(noreplace) %{php_sysconf}/conf.d/ldap.ini

%files mbstring
%defattr(644,root,root,755)
%{extension_dir}/mbstring.so
%config(noreplace) %{php_sysconf}/conf.d/mbstring.ini

%files mcrypt
%defattr(644,root,root,755)
%{extension_dir}/mcrypt.so
%config(noreplace) %{php_sysconf}/conf.d/mcrypt.ini

%if 0%{suse_version} > 1110

%files mssql
%defattr(644,root,root,755)
%{extension_dir}/mssql.so
%config(noreplace) %{php_sysconf}/conf.d/mssql.ini
%endif

%files mysql
%defattr(644,root,root,755)
%{extension_dir}/mysql.so
%config(noreplace) %{php_sysconf}/conf.d/mysql.ini
%{extension_dir}/mysqli.so
%config(noreplace) %{php_sysconf}/conf.d/mysqli.ini
%{extension_dir}/pdo_mysql.so
%config(noreplace) %{php_sysconf}/conf.d/pdo_mysql.ini

%if %{build_firebird}
%files firebird
%defattr(644,root,root,755)
%{extension_dir}/interbase.so
%config(noreplace) %{php_sysconf}/conf.d/interbase.ini
%{extension_dir}/pdo_firebird.so
%config(noreplace) %{php_sysconf}/conf.d/pdo_firebird.ini
%endif

%files odbc
%defattr(644,root,root,755)
%{extension_dir}/odbc.so
%config(noreplace) %{php_sysconf}/conf.d/odbc.ini
%{extension_dir}/pdo_odbc.so
%config(noreplace) %{php_sysconf}/conf.d/pdo_odbc.ini

%files opcache
%defattr(644,root,root,755)
%{extension_dir}/opcache.so
%config(noreplace) %{php_sysconf}/conf.d/opcache.ini

%files openssl
%defattr(644,root,root,755)
%{extension_dir}/openssl.so
%config(noreplace) %{php_sysconf}/conf.d/openssl.ini

%files phar
%defattr(644,root,root,755)
%{extension_dir}/phar.so
%config(noreplace) %{php_sysconf}/conf.d/phar.ini
%{_bindir}/phar
%{_bindir}/phar.phar

%files pcntl
%defattr(644,root,root,755)
%{extension_dir}/pcntl.so
%config(noreplace) %{php_sysconf}/conf.d/pcntl.ini

%files pdo
%defattr(644,root,root,755)
%{extension_dir}/pdo.so
%config(noreplace) %{php_sysconf}/conf.d/pdo.ini

%files pgsql
%defattr(644,root,root,755)
%{extension_dir}/pgsql.so
%config(noreplace) %{php_sysconf}/conf.d/pgsql.ini
%{extension_dir}/pdo_pgsql.so
%config(noreplace) %{php_sysconf}/conf.d/pdo_pgsql.ini

%files posix
%defattr(644,root,root,755)
%{extension_dir}/posix.so
%config(noreplace) %{php_sysconf}/conf.d/posix.ini

%if %{with spell}
%files pspell
%defattr(644,root,root,755)
%{extension_dir}/pspell.so
%config(noreplace) %{php_sysconf}/conf.d/pspell.ini
%endif

%files readline
%defattr(644,root,root,755)
%{extension_dir}/readline.so
%config(noreplace) %{php_sysconf}/conf.d/readline.ini

%files shmop
%defattr(644,root,root,755)
%{extension_dir}/shmop.so
%config(noreplace) %{php_sysconf}/conf.d/shmop.ini

%files snmp
%defattr(644,root,root,755)
%{extension_dir}/snmp.so
%config(noreplace) %{php_sysconf}/conf.d/snmp.ini

%files soap
%defattr(644,root,root,755)
%{extension_dir}/soap.so
%config(noreplace) %{php_sysconf}/conf.d/soap.ini

%files sockets
%defattr(644,root,root,755)
%{extension_dir}/sockets.so
%config(noreplace) %{php_sysconf}/conf.d/sockets.ini

%files sqlite
%defattr(644,root,root,755)
%{extension_dir}/pdo_sqlite.so
%config(noreplace) %{php_sysconf}/conf.d/pdo_sqlite.ini
%{extension_dir}/sqlite3.so
%config(noreplace) %{php_sysconf}/conf.d/sqlite3.ini

%files suhosin
%defattr(644,root,root,755)
%{extension_dir}/suhosin.so
%config(noreplace) %{php_sysconf}/conf.d/suhosin.ini

%files sysvmsg
%defattr(644,root,root,755)
%{extension_dir}/sysvmsg.so
%config(noreplace) %{php_sysconf}/conf.d/sysvmsg.ini

%files sysvsem
%defattr(644,root,root,755)
%{extension_dir}/sysvsem.so
%config(noreplace) %{php_sysconf}/conf.d/sysvsem.ini

%files sysvshm
%defattr(644,root,root,755)
%{extension_dir}/sysvshm.so
%config(noreplace) %{php_sysconf}/conf.d/sysvshm.ini

%files tidy
%defattr(644,root,root,755)
%{extension_dir}/tidy.so
%config(noreplace) %{php_sysconf}/conf.d/tidy.ini

%files tokenizer
%defattr(644,root,root,755)
%{extension_dir}/tokenizer.so
%config(noreplace) %{php_sysconf}/conf.d/tokenizer.ini

%files wddx
%defattr(644,root,root,755)
%{extension_dir}/wddx.so
%config(noreplace) %{php_sysconf}/conf.d/wddx.ini

%files xmlrpc
%defattr(644,root,root,755)
%{extension_dir}/xmlrpc.so
%config(noreplace) %{php_sysconf}/conf.d/xmlrpc.ini

%files xmlreader
%defattr(644,root,root,755)
%{extension_dir}/xmlreader.so
%config(noreplace) %{php_sysconf}/conf.d/xmlreader.ini

%files xmlwriter
%defattr(644,root,root,755)
%{extension_dir}/xmlwriter.so
%config(noreplace) %{php_sysconf}/conf.d/xmlwriter.ini

%files xsl
%defattr(644,root,root,755)
%{extension_dir}/xsl.so
%config(noreplace) %{php_sysconf}/conf.d/xsl.ini

%files zip
%defattr(644,root,root,755)
%{extension_dir}/zip.so
%config(noreplace) %{php_sysconf}/conf.d/zip.ini

%files zlib
%defattr(644,root,root,755)
%{extension_dir}/zlib.so
%config(noreplace) %{php_sysconf}/conf.d/zlib.ini

%changelog