raven-rhel6/isp-php73/isp-php73.spec
2024-02-21 20:14:44 +06:00

524 lines
14 KiB
RPMSpec

%define php_ver 73
%define php_prefix /opt/php%{php_ver}
%define _default_patch_fuzz 2
%undefine _missing_build_ids_terminate_build
%if 0%{?rhel} >= 7
%define apxs /usr/bin/apxs
%else
%define apxs /usr/sbin/apxs
%endif
%bcond_without libgd
Summary: PHP scripting language for creating dynamic web sites
Name: isp-php%{php_ver}
Version: 7.3.33
Release: 1500%{?dist}
License: PHP
Group: Development/Languages
URL: http://www.php.net/
Source0: http://www.php.net/distributions/php-%{version}.tar.xz
Source1: php.conf
Source2: php.ini
Source3: macros.php
Source4: php%{php_ver}.conf
Source10: memcached-3.2.0.tgz
Source11: memcache-4.0.5.2.tgz
Source12: ioncube_loaders_lin_x86-64.tar.gz
# Build fixes
Patch2: php-5.3.0-install.patch
Patch3: php-5.2.4-norpath.patch
Patch4: php-5.3.0-phpize64.patch
Patch6: php-5.2.4-embed.patch
Patch7: php-5.3.0-recode.patch
#Patch8: php-5.4.7-libdb.patch
# Fixes for extensions
Patch26: php-5.3.3-odbc.patch
# Functional changes
Patch40: php-5.0.4-dlopen.patch
Patch42: php-5.3.1-systzdata-v7.patch
# Fixes for tests
Patch61: php-5.0.4-tests-wddx.patch
# Upstream fixes (100+)
# Backported from 7.4.16 - opcache and pcre.jit
Patch100: php-bug80682.patch
# Backported from 7.4.18 - pdo_odbc
Patch101: php-bug80783.patch
# Backported from 7.4.26 for pcre >= 10.38
Patch102: php-pcre1038.patch
# Security fixes (200+)
Patch200: php-bug81719.patch
Patch201: php-bug81720.patch
Patch202: php-bug81727.patch
Patch203: php-bug81726.patch
Patch204: php-bug81738.patch
Patch121: php_fpm_stop.patch
Patch122: php_fpm_service.patch
Patch123: memcache.patch
Patch124: disable_zts.patch
Patch130: libicu-fix.patch
BuildRequires: autoconf
BuildRequires: devtoolset-3-gcc-c++, devtoolset-3-gcc
BuildRequires: wget, tar, libxml2-devel, bzip2-devel
BuildRequires: curl-devel
BuildRequires: gmp-devel
BuildRequires: pam-devel, libstdc++-devel, openssl-devel
BuildRequires: sqlite-devel, zlib-devel, pcre-devel
BuildRequires: smtpdaemon, libedit-devel, libtool
BuildRequires: perl
BuildRequires: pkgconfig(icu-i18n) >= 71.0
BuildRequires: mysqlclient18-devel
BuildRequires: enchant-devel
BuildRequires: recode-devel, aspell-devel
BuildRequires: libtidy-devel, libxslt-devel
BuildRequires: net-snmp-devel, libxml2-devel, unixODBC-devel
BuildRequires: krb5-devel, cyrus-sasl-devel
BuildRequires: openldap-devel, libtool-ltdl-devel
%if %{with libgd}
BuildRequires: pkgconfig(gdlib) >= 2.3.3
%else
# Required to build the bundled GD library
BuildRequires: pkgconfig(zlib)
BuildRequires: pkgconfig(libjpeg)
BuildRequires: pkgconfig(libpng)
BuildRequires: pkgconfig(freetype2)
BuildRequires: pkgconfig(xpm)
BuildRequires: pkgconfig(libwebp)
BuildRequires: pkgconfig(libavif)
Provides: bundled(gd)
%endif
BuildRequires: mhash-devel
%if 0%{?rhel} < 7
BuildRequires: db4-devel
BuildRequires: libc-client-devel
%else
BuildRequires: libdb-devel
BuildRequires: uw-imap-static
%endif
BuildRequires: openldap-devel, unixODBC-devel
BuildRequires: libpq-devel, patch, ImageMagick6-devel
BuildRequires: httpd-devel
%if 0%{?rhel} >= 7
BuildRequires: systemd-devel
%endif
BuildRequires: freetds-devel
BuildRequires: libmemcached-devel
BuildRequires: libwebp-devel
BuildRequires: libssh2-devel
BuildRequires: bats
Requires: freetds
Requires: libpq >= 15
%description
PHP is an HTML-embedded scripting language. PHP attempts to make it
easy for developers to write dynamically generated webpages. PHP also
offers built-in database integration for several commercial and
non-commercial database management systems, so writing a
database-enabled webpage with PHP is fairly simple. The most common
use of PHP coding is probably as a replacement for CGI scripts.
%package mod-apache
Summary: Apache module
Requires: %{name}%{?_isa} = %{version}-%{release}
%description mod-apache
Apache module
%package fpm
Summary: Fpm service
Requires: %{name}%{?_isa} = %{version}-%{release}
%description fpm
PHP-fpm service %{version}
%package lsapi
Summary: LSAPI module
Requires: %{name}%{?_isa} = %{version}-%{release}
%description lsapi
LSAPI module %{version}
%prep
%setup -q -n php-%{version}
pushd ext
tar -xf %{SOURCE10}
mv memcached-3.2.0 memcached
tar -xf %{SOURCE11}
mv memcache-4.0.5.2 memcache
popd
tar -xf %{SOURCE12}
%patch2 -p1 -b .install
%patch3 -p1 -b .norpath
%patch4 -p1 -b .phpize64
%patch6 -p1 -b .embed
%patch7 -p1 -b .recode
#%patch8 -p1 -b .libdb
#%patch26 -p1 -b .pdoodbc
#%patch40 -p1 -b .dlopen
#%patch42 -p1 -b .systzdata
%patch61 -p1 -b .tests-wddx
# upstream patches
%patch100 -p1 -b .bug80682
%patch101 -p1 -b .bug80783
%patch102 -p1 -b .pcre1038
# security patches
%patch200 -p1 -b .bug81719
%patch201 -p1 -b .bug81720
%patch202 -p1 -b .bug81727
%patch203 -p1 -b .bug81726
%patch204 -p1 -b .bug81738
%patch121 -p1 -b .fpmstop
%patch122 -p1 -b .fpmservice
%patch123 -p1 -b .memcache
# Disable ZTS on high apache version
%patch124 -p1
%patch130 -p1 -b .libicu
%build
. /opt/rh/devtoolset-3/enable
./buildconf --force
CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -Wno-pointer-sign"
export CFLAGS
PREFIX=%{php_prefix}
syspref=/usr
LDFLAGS="-L${syspref}/%{_lib}/pgsql -Wl,-rpath=${syspref}/%{_lib}/pgsql -lpq $_LDFLAGS"
export LDFLAGS
EXTENSION_DIR=%{php_prefix}/lib/php/modules; export EXTENSION_DIR
PEAR_INSTALLDIR=%{php_prefix}/share/pear; export PEAR_INSTALLDIR
CONFIGURE_COMMON=" --prefix=${PREFIX} \
--cache-file=../config.cache \
--with-config-file-path=${PREFIX}/etc \
--with-config-file-scan-dir=${PREFIX}/etc/php.d \
--disable-debug \
--with-libdir=%{_lib} \
--with-pic \
--disable-rpath \
--with-bz2 \
%if %{with libgd}
--with-gd \
%else
--with-webp \
--with-jpeg \
--with-xpm \
--with-freetype \
--with-png \
%endif
--without-gdbm \
--with-gettext \
--with-gmp \
--with-iconv \
--with-openssl \
--with-pcre-regex \
--with-external-pcre \
--with-zlib \
--with-layout=GNU \
--enable-exif \
--enable-ftp \
--enable-sockets \
--with-kerberos \
--enable-shmop \
--enable-calendar \
--with-libxml-dir=${syspref} \
--enable-xml \
--with-system-tzdata \
--enable-pcntl \
--enable-mbregex \
--without-readline \
--with-libedit \
--with-db4=${syspref}"
CONFIGURE_DISABLED=" --disable-dom \
--disable-json \
--disable-pdo \
--enable-timezonedb=shared \
--disable-xmlreader \
--disable-xmlwriter \
--enable-dba=shared \
--disable-posix"
mkdir cgi apache2 fpm lsapi
cd cgi
mkdir -p ext/memcache/php7
../configure \
${CONFIGURE_COMMON} \
--with-imap=shared --with-imap-ssl \
--enable-mbstring=shared \
--with-gd=shared \
--enable-bcmath=shared \
--enable-dba=shared \
--with-xmlrpc=shared \
--with-ldap=shared --with-ldap-sasl \
--with-mysql=shared,${syspref} \
--enable-mysqlnd=shared \
--with-mysqli=shared \
--with-mysql-sock=/var/lib/mysql/mysql.sock \
--with-mysqli-sock=/var/lib/mysql/mysql.sock \
--enable-dom=shared \
--with-pgsql=shared,${syspref} \
--enable-wddx=shared \
--with-snmp=shared,${syspref} \
--enable-soap=shared \
--with-xsl=shared,${syspref} \
--enable-xmlreader=shared --enable-xmlwriter=shared \
--with-curl=shared,${syspref} \
--enable-pdo=shared \
--with-pdo-odbc=shared,unixODBC,${syspref} \
--with-pdo-mysql=shared \
--with-pdo-pgsql=shared,${syspref} \
--with-pdo-sqlite=shared,${syspref} \
--with-pdo-dblib=shared \
--enable-json=shared \
--enable-zip=shared --without-libzip \
--with-pspell=shared \
--with-tidy=shared,${syspref} \
--enable-sysvmsg=shared --enable-sysvshm=shared --enable-sysvsem=shared \
--enable-posix=shared \
--with-unixODBC=shared,${syspref} \
--with-recode=shared,${syspref} \
--with-imagick=shared,${syspref} \
--with-mhash=shared,${syspref} \
--enable-intl=shared,${syspref} \
--enable-htscanner=shared,${syspref} \
--enable-timezonedb=shared,${syspref} \
--with-libmemcached-dir=shared,${syspref} \
--enable-memcached=shared \
--enable-memcache=shared \
--with-ssh2=shared,${syspref}
make %{?_smp_mflags}
cd .. && cd apache2
../configure \
${CONFIGURE_COMMON} \
${CONFIGURE_DISABLED} \
--with-apxs2=%{apxs} \
--disable-cli \
--disable-cgi
make %{?_smp_mflags}
cd .. && cd fpm
../configure \
${CONFIGURE_COMMON} \
${CONFIGURE_DISABLED} \
--enable-fpm \
%if 0%{?rhel} >= 7
--with-fpm-systemd \
%endif
--disable-cli \
--disable-cgi
make %{?_smp_mflags}
cd .. && cd lsapi
../configure \
${CONFIGURE_COMMON} \
${CONFIGURE_DISABLED} \
--with-litespeed \
--disable-cli \
--disable-cgi
make %{?_smp_mflags}
cd ..
%install
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -Wno-pointer-sign"
export CFLAGS
make -C cgi install INSTALL_ROOT=$RPM_BUILD_ROOT
make -C fpm install INSTALL_ROOT=$RPM_BUILD_ROOT
make -C lsapi install INSTALL_ROOT=$RPM_BUILD_ROOT
install -m 755 -d $RPM_BUILD_ROOT/%{php_prefix}/lib/httpd/modules
install -m 755 apache2/libs/libphp7.so $RPM_BUILD_ROOT/%{php_prefix}/lib/httpd/modules
# apache load
install -m 755 -d $RPM_BUILD_ROOT/etc/httpd/php-available.d
install -m 644 %{SOURCE4} $RPM_BUILD_ROOT/etc/httpd/php-available.d
# # ZendOptimizer
# install -m 755 ZendGuardLoader/ZendGuardLoader.so $RPM_BUILD_ROOT/%{php_prefix}/lib/php/modules/
# install -m 755 ZendGuardLoader/opcache.so $RPM_BUILD_ROOT/%{php_prefix}/lib/php/modules/zend_opcache.so
# # Ioncube
install -m 755 ioncube/ioncube_loader_lin_7.3.so $RPM_BUILD_ROOT/%{php_prefix}/lib/php/modules/
ln -sf phar.phar $RPM_BUILD_ROOT/%{php_prefix}/bin/phar
# php.ini
mkdir -p $RPM_BUILD_ROOT/%{php_prefix}/etc
install -m 644 %{SOURCE2} $RPM_BUILD_ROOT/%{php_prefix}/etc/php.ini
# fpm.conf
cp $RPM_BUILD_ROOT/%{php_prefix}/etc/php-fpm.conf.default $RPM_BUILD_ROOT/%{php_prefix}/etc/php-fpm.conf
sed -i -r '/('"'"'|\[)www('"'"'|\])/Q' $RPM_BUILD_ROOT/%{php_prefix}/etc/php-fpm.conf
grep -qE "include=%{php_prefix}/etc/php-fpm.d/\*.conf" $RPM_BUILD_ROOT/%{php_prefix}/etc/php-fpm.conf || echo "include = %{php_prefix}/etc/php-fpm.d/*.conf" >> $RPM_BUILD_ROOT/%{php_prefix}/etc/php-fpm.conf
grep -qE "include=%{php_prefix}/etc/php-fpm.d/pool.d/\*.conf" $RPM_BUILD_ROOT/%{php_prefix}/etc/php-fpm.conf || echo "include=%{php_prefix}/etc/php-fpm.d/pool.d/*.conf" >> $RPM_BUILD_ROOT/%{php_prefix}/etc/php-fpm.conf
sed -i -r "s/^;(syslog.ident = ).*/\1php-fpm%{php_ver}/" $RPM_BUILD_ROOT/%{php_prefix}/etc/php-fpm.conf
sed -i -r "s/^;(error_log = ).*/\1syslog/" $RPM_BUILD_ROOT/%{php_prefix}/etc/php-fpm.conf
mkdir -p $RPM_BUILD_ROOT/%{php_prefix}/etc/php-fpm.d
mkdir -p $RPM_BUILD_ROOT/%{php_prefix}/etc/php-fpm.d/pool.d
# fpm service
%if 0%{?rhel} >= 7
install -d -m 755 %{buildroot}%{_unitdir}
sed -i -r 's|\$\{prefix\}|%{php_prefix}|g; s|\$\{exec_prefix\}|%{php_prefix}|g' fpm/sapi/fpm/php-fpm.service
install -m 644 fpm/sapi/fpm/php-fpm.service %{buildroot}%{_unitdir}/php-fpm%{php_ver}.service
%else
install -d -m 755 %{buildroot}%{_initrddir}
install -p -D -m 0755 fpm/sapi/fpm/init.d.php-fpm %{buildroot}%{_initrddir}/php-fpm%{php_ver}
sed -i -r "/### BEGIN/,/### END/s/php-fpm/php-fpm%{php_ver}/g" %{buildroot}%{_initrddir}/php-fpm%{php_ver}
%endif
# fpm var run
install -d -m 755 %{buildroot}%{php_prefix}/var/run
mkdir -p $RPM_BUILD_ROOT/%{php_prefix}/etc/php.d
mkdir -p $RPM_BUILD_ROOT/%{php_prefix}/etc/mods-available
for ext in $(find $RPM_BUILD_ROOT/%{php_prefix}/lib/php/modules/ -name '*.so' | grep -Evi 'zend|ioncube|opcache.so' | awk -F/ '{print $NF}' | sed 's/\.so$//'); do
echo "extension=${ext}.so" > $RPM_BUILD_ROOT/%{php_prefix}/etc/mods-available/${ext}.ini
done
echo "zend_extension=%{php_prefix}/lib/php/modules/ioncube_loader_lin_7.3.so" > $RPM_BUILD_ROOT/%{php_prefix}/etc/mods-available/ioncube.ini
#echo "zend_extension=%{php_prefix}/lib/php/modules/zend_opcache.so" >> $RPM_BUILD_ROOT/%{php_prefix}/etc/mods-available/zendopcache.ini
echo "zend_extension=%{php_prefix}/lib/php/modules/opcache.so" >> $RPM_BUILD_ROOT/%{php_prefix}/etc/mods-available/zendopcache.ini
#echo "zend_extension=%{php_prefix}/lib/php/modules/ZendGuardLoader.so" >> $RPM_BUILD_ROOT/%{php_prefix}/etc/mods-available/zendguardloader.ini
rm -rf $RPM_BUILD_ROOT/%{php_prefix}/lib/php/modules/*.a \
$RPM_BUILD_ROOT/\.channels* \
$RPM_BUILD_ROOT/\.depdb* \
$RPM_BUILD_ROOT/\.filemap \
$RPM_BUILD_ROOT/\.lock \
$RPM_BUILD_ROOT/\.registry
%check
installdir=%{buildroot} bats -t bats/test.bats
%post
if [ $1 -eq 1 ]; then
if [ -f /etc/sysconfig/clock ]; then
TZ=$(cat /etc/sysconfig/clock | sed "s|\"||g" | awk -F= '{print $2}')
elif [ -x /usr/bin/timedatectl ]; then
TZ=$(/usr/bin/timedatectl | awk '$1 ~ /Timezone:/ {print $2}')
test -z "${TZ}" && TZ=$(timedatectl | awk '$0 ~ /Time zone:/ {print $3}')
else
TZ=UTC
fi
if grep -qE "^date.timezone\s*=" %{php_prefix}/etc/php.ini ; then
sed -i -r "s|^date.timezone\s*=.*|date.timezone = ${TZ}|" %{php_prefix}/etc/php.ini
else
echo "date.timezone = ${TZ}" >> %{php_prefix}/etc/php.ini
fi
for ext in dom gd mbstring mysqlnd mysqli pdo pdo_mysql json curl zendopcache intl xmlreader xmlwriter zip ; do
case ${ext} in
mysqlnd|pdo)
extl=10-${ext}
;;
*)
extl=20-${ext}
;;
esac
if [ -e %{php_prefix}/etc/mods-available/${ext}.ini ]; then
ln -sf ../mods-available/${ext}.ini %{php_prefix}/etc/php.d/${extl}.ini
fi
done
else
if [ -f %{php_prefix}/etc/php.d/mysqli.ini ]; then
if [ ! -f %{php_prefix}/etc/php.d/10-mysqlnd.ini ] && [ ! -f %{php_prefix}/etc/php.d/mysqlnd.ini ]; then
ln -s ../mods-available/mysqlnd.ini %{php_prefix}/etc/php.d/10-mysqlnd.ini
fi
fi
fi
%postun
if [ $1 -eq 0 ]; then
find %{php_prefix}/etc/php.d -type l -delete
fi
%post fpm
%if 0%{?rhel} >= 7
%systemd_post php-fpm%{php_ver}.service
if [ $1 -ge 1 ] ; then
systemctl try-restart php-fpm%{php_ver}.service >/dev/null 2>&1 || :
fi
%endif
%preun fpm
%if 0%{?rhel} >= 7
%systemd_preun php-fpm%{php_ver}.service
%endif
%postun fpm
%if 0%{?rhel} >= 7
%systemd_postun_with_restart php-fpm%{php_ver}.service
%endif
%files
%{php_prefix}/bin/p*
%{php_prefix}/lib/php
%{php_prefix}/share/man/man1
%{php_prefix}/share/pear
%{php_prefix}/include
%config(noreplace) %{php_prefix}/etc/php.ini
%config(noreplace) %{php_prefix}/etc/pear.conf
%config(noreplace) %{php_prefix}/etc/mods-available/*.ini
%dir %{php_prefix}/etc/php.d
%dir %{php_prefix}/etc/mods-available
%files mod-apache
%{php_prefix}/lib/httpd/modules/*
%config(noreplace) /etc/httpd/php-available.d/php%{php_ver}.conf
%files fpm
%{php_prefix}/sbin/php-fpm
%dir %{php_prefix}/etc/php-fpm.d
%dir %{php_prefix}/etc/php-fpm.d/pool.d
%dir %{php_prefix}/var/run
%{php_prefix}/share/man/man8/php-fpm.8
%{php_prefix}/share/php/fpm/status.html
%{php_prefix}/etc/php-fpm.conf.default
%{php_prefix}/etc/php-fpm.d/www.conf.default
%config(noreplace) %{php_prefix}/etc/php-fpm.conf
%if 0%{?rhel} >= 7
%{_unitdir}/php-fpm%{php_ver}.service
%else
%{_initrddir}/php-fpm%{php_ver}
%endif
%files lsapi
%{php_prefix}/bin/lsphp