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

465 lines
13 KiB
RPMSpec

%global _rxprefix /opt/rx
%global _rxlibdir %{_rxprefix}/lib
%global _rxincludedir %{_rxprefix}/include
%define php_ver 72
%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
Summary: PHP scripting language for creating dynamic web sites
Name: isp-php%{php_ver}
Version: 7.2.34
Release: 1024%{?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
# 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
Patch121: php_fpm_stop.patch
Patch122: php_fpm_service.patch
Patch123: memcache.patch
Patch124: disable_zts.patch
Patch132: CVE-2021-21703.php-fpm.patch
%if 0%{?rhel} < 7
BuildRequires: autoconf2.69 m4_next
%else
BuildRequires: autoconf
%endif
BuildRequires: wget, tar, gcc
BuildRequires: gcc-c++, libxml2-devel, bzip2-devel
BuildRequires: curl-devel
BuildRequires: gmp6-devel
BuildRequires: pam-devel, libstdc++-devel, openssl-devel
BuildRequires: sqlite-devel, zlib-devel, pcre-devel
BuildRequires: smtpdaemon, libedit-devel, libtool
BuildRequires: perl
%if 0%{?rhel} < 8
BuildRequires: mysql-devel
%else
BuildRequires: mariadb-devel
%endif
BuildRequires: enchant-devel
BuildRequires: libicu-devel, recode-devel, aspell-devel
BuildRequires: libtidy-devel, libXpm-devel, libxslt-devel
BuildRequires: net-snmp-devel, libxml2-devel, unixODBC-devel
BuildRequires: postgresql-devel, krb5-devel, cyrus-sasl-devel
BuildRequires: openldap-devel, libtool-ltdl-devel, libXpm-devel
BuildRequires: libjpeg-devel, libpng-devel, freetype-devel
BuildRequires: mhash-devel
%if 0%{?rhel} < 7
BuildRequires: db4-devel
BuildRequires: libc-client-devel
BuildRequires: rx-openssl-devel
%else
BuildRequires: libdb-devel
BuildRequires: uw-imap-static
%endif
BuildRequires: openldap-devel, unixODBC-devel
BuildRequires: postgresql-devel, patch, ImageMagick-devel
BuildRequires: httpd-devel
%if 0%{?rhel} >= 7
BuildRequires: systemd-devel
%endif
BuildRequires: freetds-devel
BuildRequires: libmemcached-devel
BuildRequires: libwebp7-devel
BuildRequires: libssh2-devel
BuildRequires: bats
Requires: freetds
%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}
%prep
%setup -q -n php-%{version}
%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
%patch121 -p1 -b .fpmstop
%patch122 -p1 -b .fpmservice
#%patch123 -p1 -b .memcache
# Disable ZTS on high apache version
%patch124 -p1
# CVE-2021-21703 php-fpm
%patch132 -p1
%build
%if 0%{?rhel} < 7
. /etc/profile.d/modules.sh
module load autoconf
module load automake
module load m4
export PKG_CONFIG_PATH=%{_rxlibdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}
export LDFLAGS="-L%{_rxlibdir} -Wl,-rpath=%{_rxlibdir} $LDFLAGS"
%endif
./buildconf --force
CFLAGS="$RPM_OPT_FLAGS -I%{_rxincludedir} -fno-strict-aliasing -Wno-pointer-sign"
export CFLAGS
export SASL_LIBS="-lsasl2"
export SASL_CFLAGS=""
PREFIX=%{php_prefix}
syspref=/usr
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 \
--with-freetype-dir=${syspref} \
--with-png-dir=${syspref} \
--with-xpm-dir=${syspref} \
--with-webp-dir=${syspref} \
--enable-gd-native-ttf \
--without-gdbm \
--with-gettext \
--with-gmp \
--with-iconv \
--with-jpeg-dir=${syspref} \
--with-openssl \
--with-openssl-dir=%{_rxprefix} \
--with-pcre-regex \
--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 \
--without-db4"
CONFIGURE_DISABLED=" --disable-dom \
--disable-json \
--disable-pdo \
--enable-timezonedb=shared \
--disable-xmlreader \
--disable-xmlwriter \
--enable-dba=shared \
--disable-posix"
mkdir cgi apache2 fpm
cd cgi
mkdir -p ext/memcache/php7
../configure \
${CONFIGURE_COMMON} \
--with-imap=shared --with-imap-ssl=%{_rxprefix} \
--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 \
--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 \
--enable-htscanner=shared,${syspref} \
--enable-timezonedb=shared,${syspref} \
--with-ssh2=shared,${syspref} \
--enable-memcache=shared \
--enable-memcached=shared \
--with-libmemcached-dir=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 ..
%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
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.2.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.2.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
ln -sf ../mods-available/${ext}.ini %{php_prefix}/etc/php.d/${extl}.ini
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
%{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