File php8.spec of Package php8
#
# spec file for package php8
#
# Copyright (c) 2021 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#
%global flavor @BUILD_FLAVOR@%{nil}
%define php_name php8
%if "%{flavor}" == "apache2"
%define pprefix apache2-mod_
%define psuffix %{nil}
%endif
%if "%{flavor}" == "embed" || "%{flavor}" == "fastcgi" || "%{flavor}" == "fpm"
%define pprefix %{nil}
%define psuffix -%{flavor}
%endif
%if "%{flavor}" == "test"
%define pprefix %{nil}
%define psuffix -test
%endif
%if "%{flavor}" == ""
%define pprefix %{nil}
%define psuffix %{nil}
%endif
%define debug_build 0
%define asan_build 0
%global apiver 20200930
%global zendver 20200930
%define extension_dir %{_libdir}/%{php_name}/extensions
%define php_sysconf %{_sysconfdir}/%{php_name}
%define build_firebird 0
%define build_sodium 1
%define build_argon2 0
%if 0%{?suse_version} >= 1500
%define build_argon2 1
%endif
#next line to allow build to finsih
%define _unpackaged_files_terminate_build 0
Name: %{pprefix}%{php_name}%{psuffix}
Version: 8.0.30
Release: 0
Summary: Interpreter for the PHP scripting language version 8
License: PHP-3.01
Group: Development/Libraries/PHP
URL: https://secure.php.net
#Source0: https://secure.php.net/distributions/php-%{version}.tar.xz
Source0: php-%{version}.tar.xz
Source1: mod_%{php_name}.conf
Source5: README.macros
Source6: macros.php
#Source8: https://secure.php.net/distributions/php-%{version}.tar.xz.asc
Source9: %{php_name}.keyring
Source11: %{php_name}.rpmlintrc
Source12: php-fpm.tmpfiles.d
Source100: build-test.sh
## SUSE specific patches
# adjust includedir
Patch0: php-phpize.patch
# reproducible builds: (D)eterministic archives; --enable-deterministic-archives is not used in binutils
Patch1: php-ar-flags.patch
# adjust includedir
Patch2: php-php-config.patch
# SUSE specific ini defaults
Patch3: php-ini.patch
# use of the system timezone database
Patch4: php-systzdata-v20.patch
# adjust upstream systemd unit to SUSE needs
Patch5: php-systemd-unit.patch
# PATCH-FEATURE-OPENSUSE use ordered input files for reproducible /usr/bin/phar.phar
Patch6: php-sort-filelist-phar.patch
## Bugfix patches
# 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
Patch20: php-crypt-tests.patch
# should be upstreamed, will do later
Patch22: php-date-regenerate-lexers.patch
# PATCH-FEATURE-UPSTREAM https://github.com/php/php-src/pull/6564
Patch19: php-build-reproducible-phar.patch
# https://github.com/php/php-src/commit/b3646440b1808abf0874b6f89027ce53ec5da03f
Patch23: php8-gd-removed-unused-constants.patch
# PATCH-FIX-UPSTREAM https://github.com/php/php-src/pull/14186
Patch24: php-fix-newer-versions-icu.patch
BuildRequires: apache-rpm-macros
BuildRequires: autoconf
BuildRequires: bison
BuildRequires: curl
BuildRequires: db-devel
BuildRequires: freetds-devel
BuildRequires: gcc-c++
BuildRequires: gmp-devel
BuildRequires: gpg2
BuildRequires: imap-devel
BuildRequires: libapparmor-devel
BuildRequires: libbz2-devel
BuildRequires: libtidy-devel
BuildRequires: libtiff-devel
BuildRequires: libtool
BuildRequires: lmdb-devel
BuildRequires: ncurses-devel
BuildRequires: net-snmp-devel
BuildRequires: openldap2-devel
BuildRequires: pkgconfig
BuildRequires: postfix
BuildRequires: postgresql-devel
BuildRequires: re2c
BuildRequires: tcpd-devel
BuildRequires: update-alternatives
BuildRequires: xz
%if 0%{?suse_version} <= 1500 && 0%{?sle_version} <= 150200
BuildRequires: pkgconfig(enchant)
%else
BuildRequires: pkgconfig(enchant-2)
%endif
BuildRequires: pkgconfig(gdlib) >= 2.1.0
BuildRequires: pkgconfig(icu-i18n)
BuildRequires: pkgconfig(icu-io)
BuildRequires: pkgconfig(icu-uc) >= 50.1
BuildRequires: pkgconfig(krb5)
BuildRequires: pkgconfig(krb5-gssapi)
BuildRequires: pkgconfig(libcurl) >= 7.29.0
BuildRequires: pkgconfig(libedit)
BuildRequires: pkgconfig(libpcre2-8) >= 10.30
BuildRequires: pkgconfig(libsasl2)
BuildRequires: pkgconfig(libxml-2.0) >= 2.9.0
BuildRequires: pkgconfig(libxslt) >= 1.1.0
BuildRequires: pkgconfig(libzip) >= 0.11
BuildRequires: pkgconfig(odbc)
BuildRequires: pkgconfig(oniguruma)
BuildRequires: libopenssl-1_1-devel
BuildRequires: pkgconfig(sqlite3) >= 3.7.4
BuildRequires: pkgconfig(zlib) >= 1.2.0.4
%if %{build_firebird}
# firebird-devel was merged into libfbclient2-devel for firebird 3
BuildRequires: firebird-devel
BuildRequires: libfbclient2-devel
%endif
%if %{build_sodium}
BuildRequires: pkgconfig(libsodium) >= 1.0.8
%endif
%if %{build_argon2}
BuildRequires: pkgconfig(libargon2)
%endif
%if "%{flavor}" == "test"
BuildRequires: apache-rex
BuildRequires: mod_php_any = %{version}
BuildRequires: php-cli = %{version}
BuildRequires: php-fpm = %{version}
%apache_rex_deps
%endif
%if "%{flavor}" == ""
Requires: php-sapi = %{version}
Requires: timezone
Recommends: php-ctype = %{version}
Recommends: php-dom = %{version}
Recommends: php-iconv = %{version}
Recommends: php-openssl = %{version}
Recommends: php-sqlite = %{version}
Recommends: php-tokenizer = %{version}
Recommends: php-xmlreader = %{version}
Recommends: php-xmlwriter = %{version}
# Recommends instead of Requires smtp_daemon bsc#1115213
Recommends: smtp_daemon
# Suggest php-* = %%{version} instead of php-* [bsc#1022158c#4]
Suggests: php-cli = %{version}
Suggests: php-gd = %{version}
Suggests: php-gettext = %{version}
Suggests: php-mbstring = %{version}
Suggests: php-mysql = %{version}
## Provides
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-json = %{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: zend = %{zendver}
# conflicts other php major versions with and should replace it
Conflicts: php < %{version}
Conflicts: php72
# mcrypt was removed in php 7.2
Obsoletes: php7-mcrypt
# json is now integral part of core, cannot be disabled
Obsoletes: php7-json
# xmlrpc moved to PECL
Obsoletes: php7-xmlrpc
%description
PHP is a server-side HTML embedded scripting language designed
primarily for web development but also used as a general-purpose
programming language.
This package contains the base files for all subpackages and
must be installed in order to use PHP. Additionally, extension
modules and server modules (e.g. for Apache) may be installed.
%package devel
# this is required by the installed development headers
Summary: PHP8 development files for C/C++ extensions
Group: Development/Libraries/PHP
Requires: %{php_name}-pear
Requires: %{php_name}-pecl
Requires: glibc-devel
Requires: php = %{version}
Requires: pkgconfig(libpcre2-8) >= 10.30
Requires: pkgconfig(libxml-2.0) >= 2.9.0
Provides: php-devel = %{version}
Conflicts: php-devel < %{version}
%description devel
PHP is a server-side HTML embedded scripting language designed
primarily for web development but also used as a general-purpose
programming language.
This package contains the C headers to build PHP extensions.
%endif
%if "%{flavor}" == "test"
Requires: php-cli = %{version}
%description
Run php upstream testsuite.
%endif
%if "%{flavor}" == ""
%package imap
Summary: IMAP protocol support for PHP
Group: Development/Libraries/PHP
Requires: php = %{version}
Provides: php-imap = %{version}
Obsoletes: php-imap < %{version}
%description imap
These functions enable you to operate with the IMAP protocol, as well
as the NNTP, POP3 and local mailbox access methods.
%endif
%prep
%setup -q -n php-%{version}
cp %{SOURCE5} .
%autopatch -p1 -v
# use system pcre2
rm -r ext/pcre/pcre2lib
# get parsers regenerated
for parser in $(find -type f -name "*.re");do
rm -v ${parser%.*}.c
done
# 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
# regenerate configure etc.
./buildconf --force
# export flags
CFLAGS="%{optflags} -O3 -fPIE -fPIC -DPIC -D_GNU_SOURCE -fno-strict-aliasing"
CXXFLAGS="%{optflags} -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
%if %{debug_build}
CFLAGS="$CFLAGS -Og"
CXXFLAGS="$CXXFLAGS -Og"
%endif
export CFLAGS
export CXXFLAGS
export LDFLAGS="-pie"
export NO_INTERACTION=true
# Totally fake, it wasnt and will never be reliable anyway.
export PHP_UNAME="Linux suse 2.6.36 #1 SMP 2011-02-21 10:34:10 +0100 x86_64 x86_64 x86_64 GNU/Linux"
# where to install extensions
export EXTENSION_DIR=%{extension_dir}
# Fix build-cli for arm and aarch64
export LIBS=-ltinfo
# build function
Build()
{
sapi=$1
shift
%configure \
--datadir=%{_datadir}/%{php_name} \
--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 \
--with-libxml \
--enable-session \
--with-external-pcre \
--enable-xml \
--enable-simplexml \
--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 \
--with-mhash \
--disable-phpdbg \
%if %{build_argon2}
--with-password-argon2=%{_usr} \
%endif
"$@" || { cat config.log; exit 1; }
# 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 -e 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' \
-e 's|^runpath_var=LD_RUN_PATH|runpath_var=LIBTOOL_IS_BROKED|g' \
libtool
# build mod_phpN.so instead of libphp.so
# rename does not suffice, see bsc#1089487
if [ $sapi == apache2 ]; then
sed -i 's/libphp/mod_%{php_name}/g' Makefile
fi
%if %{asan_build}
sed -i -e 's/\(^CFLAGS.*\)/\1 -fsanitize=address/' \
-e 's/\(^EXTRA_LIBS =.*\)/\1 -lasan/' \
Makefile
%endif
make %{?_smp_mflags}
}
%if "%{flavor}" == ""
Build cli \
--enable-cli \
--with-imap=shared \
--with-imap-ssl \
--disable-phar \
--disable-cgi \
--disable-all
# --enable-bcmath=shared \
# --enable-calendar=shared \
# --enable-ctype=shared \
# --enable-dom=shared \
# --enable-exif=shared \
# --enable-ftp=shared \
# --enable-mbstring=shared \
# --enable-mbregex \
# --enable-mysqlnd=shared \
# --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-fileinfo=shared \
# --with-zlib=shared \
# --with-bz2=shared \
# --with-curl=shared \
# --enable-gd=shared \
# --with-external-gd \
# --with-gettext=shared \
# --with-gmp=shared \
# --with-iconv=shared \
# --with-kerberos \
# --with-ldap=shared \
# --with-ldap-sasl \
# --with-libedit=shared \
# --with-mysql-sock=%{_rundir}/mysql/mysql.sock \
# --with-mysqli=shared,mysqlnd \
# --with-unixODBC=shared,%{_usr} \
# --with-openssl=shared \
# --with-pgsql=shared,%{_usr} \
# --enable-phar=shared \
# --with-enchant=shared \
# --with-snmp=shared \
# --enable-xmlreader=shared \
# --enable-xmlwriter=shared \
# --with-xsl=shared \
# --with-tidy=shared,%{_usr} \
# --enable-dba=shared \
# --with-db4=%{_usr} \
# --with-lmdb=%{_usr} \
# --without-gdbm \
# --with-cdb \
# --enable-pdo=shared \
# --with-pdo-sqlite=shared \
# --with-sqlite3=shared \
# --with-pdo-mysql=shared,mysqlnd \
#%if %{build_firebird}
# --with-pdo-firebird=shared \
#%endif
# --with-pdo-pgsql=shared,%{_usr} \
# --with-pdo-odbc=shared,unixODBC,%{_usr} \
#%if %{build_sodium}
# --with-sodium=shared \
#%endif
# --enable-opcache=shared \
# --with-zip=shared \
# --enable-intl=shared \
# --disable-cgi
%endif
%check
%if %{asan_build}
# no need for ASAN build
exit 0
%endif
%if "%{flavor}" == "test"
# Run tests, using the CLI SAPI
export NO_INTERACTION=1 REPORT_EXIT_STATUS=1 LANG=POSIX LC_ALL=POSIX
unset TZ
# We save results for further investigation for QA
TEST_PHP_EXECUTABLE=/usr/bin/php php run-tests.php | tee testresults.txt || 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
# Apache HTTPD runnable examples test
%apache_rex_check -m libs mod_php-basic
%apache_rex_check -m libs -b sapi/fpm mod_proxy_fcgi-php-fpm mod_proxy_fcgi-php-fpm-auth-RewriteRule mod_proxy_fcgi-php-fpm-CGIPassAuth
exit 0
%endif
%if "%{flavor}" == ""
# check if we link against system libcrypt
if [ -z "$(ldd sapi/cli/php | grep libcrypt.so)" ]; then
echo 'php does not link against system libcrypt.'
exit 1
fi
# check if we link against system libgd
#if [ -z "$(ldd modules/gd.so | grep libgd.so)" ]; then
# echo 'php-gd does not link against system libgd.'
# exit 1
#fi
%endif
%install
# do the actual installation
%if "%{flavor}" == ""
make install INSTALL_ROOT=%{buildroot}
# generate php.ini from php.ini-production:
install -dm 755 %{buildroot}%{_datadir}/php
install -dm 755 %{buildroot}%{_datadir}/%{php_name}
install -dm 755 %{buildroot}%{php_sysconf}/conf.d
install -dm 755 %{buildroot}%{php_sysconf}/cli
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
# prepare configuration files for each extension
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##*/}
echo "; comment out next line to disable $ext extension in php" > %{buildroot}%{php_sysconf}/conf.d/$ext.ini
zend_=''
if [ $ext == "opcache" ]; then
# https://secure.php.net/manual/en/opcache.installation.php
zend_='zend_'
fi
echo "${zend_}extension=$ext.so" >> %{buildroot}%{php_sysconf}/conf.d/$ext.ini
done
# fix symlink (bnc#734176)
ln -s %{_bindir}/php %{buildroot}%{_bindir}/%{php_name}
# install the macros file:
install -d %{buildroot}%{_rpmconfigdir}/macros.d
sed -e "s/@PHP_APIVER@/%{apiver}/;s/@PHP_ZENDVER@/%{zendver}/" %{SOURCE6} > macros.php
install -m 644 -c macros.php %{buildroot}%{_rpmconfigdir}/macros.d/macros.php
# install missing SAPI headers for embed
install -d %{buildroot}%{_includedir}/%{php_name}/sapi/embed
install -m 644 sapi/embed/php_embed.h %{buildroot}%{_includedir}/%{php_name}/sapi/embed/php_embed.h
# mysqlnd must be loaded before mysqli (undefined symbol: mysqlnd_global_stats)
#mv %{buildroot}%{php_sysconf}/conf.d/{,_}mysqlnd.ini
%endif
%if "%{flavor}" == ""
%files
%defattr(-, root, root)
%doc README.md CODING_STANDARDS.md EXTENSIONS NEWS UPGRADING CONTRIBUTING.md README.REDIST.BINS UPGRADING.INTERNALS
%license LICENSE
%dir %{_datadir}/php
%dir %{_datadir}/%{php_name}
%dir %{_libdir}/%{php_name}
%dir %{extension_dir}
%dir %{php_sysconf}
%dir %{php_sysconf}/conf.d
#%files cli
#%defattr(-, root, root)
#%config(noreplace) %{php_sysconf}/cli/php.ini
#%dir %{php_sysconf}/cli
#%{_bindir}/php
#%{_bindir}/%{php_name}
#%{_mandir}/man1/php.1%{?ext_man}
%files devel
%defattr(-, root, root)
%doc README.macros
%{_bindir}/phpize
%{_bindir}/php-config
%{_datadir}/%{php_name}/build
%{_includedir}/%{php_name}
%{_mandir}/man1/phpize.1%{?ext_man}
%{_mandir}/man1/php-config.1%{?ext_man}
%{_rpmconfigdir}/macros.d/macros.php
%endif
%if "%{flavor}" == ""
%files imap
%defattr(-, root, root)
%{extension_dir}/imap.so
%config(noreplace) %{php_sysconf}/conf.d/imap.ini
%endif
%if "%{flavor}" == "test"
%files
%defattr(-, root, root)
%doc testresults.txt
%endif
%changelog