Subject: [alpine-aports] [PATCH v4] testing/php7.1: fixes in extension depends tracking

From: Valery Kartel <[email-masked]>
Date: Fri, 24 Feb 2017 03:47:09 +0200

--
- rename submodule phar-phar -> phar-utils
- remade APKBUILD and sources from template-based to 7.1

---
v1 -> v2: fix 3rd party extension phpapi hook.

v2 -> v3: add -pecl subpkg. Provides an environment
          for building pecl extensions

v3 -> v4: switch from bundled to system-wide gd library
---
 testing/php7.1/APKBUILD                            | 75 +++++++++++-----------
 .../php7.1/{php-fpm.initd.in => php7.1-fpm.initd}  |  8 +--
 .../{php-fpm.logrotate.in => php7.1-fpm.logrotate} |  4 +-
 .../php7.1/{php-fpm.patch.in => php7.1-fpm.patch}  | 22 +++----
 ...includedir.patch.in => php7.1-includedir.patch} |  8 +--
 .../{php-module.conf.in => php7.1-module.conf}     |  2 +-
 6 files changed, 58 insertions(+), 61 deletions(-)
 rename testing/php7.1/{php-fpm.initd.in => php7.1-fpm.initd} (90%)
 rename testing/php7.1/{php-fpm.logrotate.in => php7.1-fpm.logrotate} (56%)
 rename testing/php7.1/{php-fpm.patch.in => php7.1-fpm.patch} (67%)
 rename testing/php7.1/{includedir.patch.in => php7.1-includedir.patch} (83%)
 rename testing/php7.1/{php-module.conf.in => php7.1-module.conf} (67%)

diff --git a/testing/php7.1/APKBUILD b/testing/php7.1/APKBUILD
index 451dc8c42c..66cd066f55 100644
--- a/testing/php7.1/APKBUILD
+++ b/testing/php7.1/APKBUILD
@@ -2,7 +2,7 @@
 # Maintainer: Valery Kartel <[email-masked]>
 pkgname=php7.1
 pkgver=7.1.2
-pkgrel=1
+pkgrel=2
 _apiver=20160303
 _suffix=${pkgname#php}
 _pkgreal=${pkgname%$_suffix}
@@ -16,17 +16,17 @@ depends_dev="$pkgname"
 replaces="$_pkgreal $_pkgreal-cli"
 provides="$replaces $pkgname-cli"
 makedepends="autoconf bison re2c apache2-dev libxml2-dev libxslt-dev libzip-dev bzip2-dev zlib-dev
-	aspell-dev enchant-dev expat-dev pcre-dev curl-dev gmp-dev icu-dev imap-dev
+	aspell-dev enchant-dev expat-dev pcre-dev curl-dev gmp-dev icu-dev imap-dev gd-dev
 	libical-dev libressl-dev openldap-dev net-snmp-dev db-dev krb5-dev gdbm-dev sqlite-dev
 	freetds-dev mariadb-dev postgresql-dev unixodbc-dev freetype-dev tidyhtml-dev libxpm-dev
 	libpng-dev libwebp-dev libjpeg-turbo-dev libmcrypt-dev recode-dev libedit-dev gettext-dev
 	"
 source="http://php.net/distributions/$_pkgreal-$pkgver.tar.bz2
-	$_pkgreal-module.conf.in
-	$_pkgreal-fpm.logrotate.in
-	$_pkgreal-fpm.initd.in
-	$_pkgreal-fpm.patch.in
-	includedir.patch.in
+	$pkgname-module.conf
+	$pkgname-fpm.logrotate
+	$pkgname-fpm.initd
+	$pkgname-fpm.patch
+	$pkgname-includedir.patch
 	install-pear.patch
 	getrandom.patch
 	"
@@ -43,28 +43,13 @@ done
 _prefix_opcache="zend_"
 _pkgdesc_opcache="Zend OPcache"
 subpackages="$pkgname-dev $pkgname-doc $pkgname-libs $pkgname-apache2 $pkgname-phpdbg
-	$pkgname-litespeed $pkgname-cgi $pkgname-fpm $pkgname-pear::noarch
-	$pkgname-phar-phar:_phar:noarch $subpackages $pkgname-config::noarch"
+	$pkgname-litespeed $pkgname-cgi $pkgname-fpm $pkgname-pear::noarch $pkgname-pecl::noarch
+	$pkgname-phar-utils:_phar:noarch $subpackages $pkgname-config::noarch"
 builddir="$srcdir/$_pkgreal-$pkgver"
 
 prepare() {
 	cd "$builddir"
 
-	local i
-	for i in $source; do
-		case $i in
-			*.patch.in)
-				msg "${i%.in} [$_suffix]"
-				sed "s/@_suffix@/$_suffix/g" "$srcdir/$i" \
-					| patch "${patch_args:--p1}" || return 1
-				;;
-			*.in)
-				msg "$i -> ${i%.in}"
-				sed "s/@_suffix@/$_suffix/g" "$srcdir/$i" > ${i%.in}
-				;;
-		esac
-	done
-
 	sed "$(($(grep -n 'Pool Definitions' sapi/fpm/php-fpm.conf.in | cut -d: -f1)+3)),\$d" \
 		-i sapi/fpm/php-fpm.conf.in
 	echo include=@php_fpm_sysconfdir@/php-fpm.d/*.conf >> sapi/fpm/php-fpm.conf.in
@@ -112,7 +97,7 @@ _build() {
 		--with-enchant=shared \
 		--enable-exif=shared \
 		--enable-ftp=shared \
-		--with-gd=shared --with-webp-dir=shared --with-jpeg-dir=shared --with-png-dir=shared --with-xpm-dir=shared \
+		--with-gd=shared,/usr --with-webp-dir=shared --with-jpeg-dir=shared --with-png-dir=shared --with-xpm-dir=shared \
 		--with-freetype-dir=shared --enable-gd-native-ttf --disable-gd-jis-conv \
 		--with-gettext=shared \
 		--with-gmp=shared \
@@ -236,7 +221,7 @@ apache2() {
 	cp "$builddir"/sapi/apache2handler/lib$_pkgreal*.so \
 		"$subpkgdir"/usr/lib/apache2/mod_$pkgname.so || return 1
 
-	install -Dm644 "$builddir"/$_pkgreal-module.conf \
+	install -Dm644 "$srcdir"/$pkgname-module.conf \
 		"$subpkgdir"/etc/apache2/conf.d/$pkgname-module.conf
 }
 
@@ -308,9 +293,9 @@ fpm() {
 			"$subpkgdir"/etc/$pkgname/$file || return 1
 	done
 
-	install -Dm755 "$builddir"/$_pkgreal-fpm.initd \
+	install -Dm755 "$srcdir"/$pkgname-fpm.initd \
 		"$subpkgdir"/etc/init.d/$_pkgreal-fpm$_suffix || return 1
-	install -Dm644 "$builddir"/$_pkgreal-fpm.logrotate \
+	install -Dm644 "$srcdir"/$pkgname-fpm.logrotate \
 		"$subpkgdir"/etc/logrotate.d/$_pkgreal-fpm$_suffix || return 1
 }
 
@@ -318,8 +303,8 @@ pear() {
 	local file
 	provides=$_pkgreal-pear
 	replaces=$provides
-	pkgdesc="$pkgdesc (extension and application repository)"
-	depends="$pkgname-dev $pkgname-xml"
+	pkgdesc="$pkgdesc (php extension and application repository)"
+	depends="$pkgname $pkgname-xml"
 
 	mkdir -p "$subpkgdir"/usr/bin \
 		"$subpkgdir"/etc/$pkgname
@@ -343,8 +328,16 @@ pear() {
 	done
 }
 
+pecl() {
+	provides=$_pkgreal-pecl
+	replaces=
+	pkgdesc="$pkgdesc (php extension community library)"
+	depends="$pkgname-pear $pkgname-dev autoconf gcc make musl-dev"
+	mkdir -p "$subpkgdir"
+}
+
 config() {
-	provides="phpapi=$_apiver"
+	provides="phpapi$_apiver"
 	replaces=
 	depends=
 	pkgdesc="$pkgdesc (common config)"
@@ -379,7 +372,7 @@ _phar() {
 }
 
 _extension() {
-	local dep
+	local dep deps
 	local name=${subpkgname#$pkgname-}
 	local index=$(eval echo \$_index_$name)
 	provides="$_pkgreal-$name"
@@ -390,12 +383,16 @@ _extension() {
 	: ${pkgdesc:=$(head -n1 "$builddir"/ext/$name/CREDITS)}
 	pkgdesc="PHP$_suffix extension: ${pkgdesc:-$name}"
 
-	for dep in $(grep -o "_DEP('$name'.*" "$builddir"/ext/$name/config.w32 | sed "s/[',);]//g"); do
+	[ -f "$builddir"/ext/$name/config.w32 ] && \
+		deps=$(grep -o "_DEP('$name'.*" "$builddir"/ext/$name/config.w32 | sed "s/[',);]//g")
+	[ -f "$builddir"/ext/$name/config.m4 ] && \
+		deps="$deps $(grep -o "_DEP($name,.*" "$builddir"/ext/$name/config.m4 | sed "s/[,)]//g")"
+	for dep in $(echo -e ${deps//[[:space:]]/\\n} | sort -u); do
 		[ -z "${_extensions##*$dep*}" ] && depends="$depends $pkgname-$dep"
 	done
 
 	: ${index:=$(echo $depends | wc -w)}
-	depends="$pkgname-config phpapi=$_apiver $depends"
+	depends="$pkgname-config phpapi$_apiver $depends"
 
 	mkdir -p "$subpkgdir"/usr/lib/$pkgname/modules \
 		"$subpkgdir"/etc/$pkgname/conf.d
@@ -408,10 +405,10 @@ _extension() {
 }
 
 sha512sums="b4a3492f4af92facd16e7dfb47ec16b43e4c5b25be193ff6e36418173893edb75ca4ca94767b643a6971d60578727fa1f67f20cc84b9a140cb1b9a367ec34a6f  php-7.1.2.tar.bz2
-e0f24eea250ed6a8c8286b2ed496a3feb1d9a2e399755f822387a4c26b34168bb346109c08d2b827d8230fe3103295d8b7f7b6bc09219e5b3ad4429271ece5d6  php-module.conf.in
-b25c0bcaae4ddc7e001a6484423dec48be8735168dc3ab7471f5a57ce631273f11514c924b368ff846fe9a04bd4e1c7f296f1c8527f6f239a79df84189841983  php-fpm.logrotate.in
-809e584304365412ecf80eb2ebb613439342e9a1faf36d0b04c76e60b1bf1345812799a16ffad76dbd3aa5f00c55329a051b308e451301d6e8d673813e37856b  php-fpm.initd.in
-2b3d60e4c57929a7bc1875c83472a6be1b7695a623893d108f905e742fe72ddf7fec7bf7a42b332ac33304434620a0317fd79d4ad707be886825d4b0fd96b938  php-fpm.patch.in
-c7841eef58e1203cb1eb97efff96427d560c1c8d9945286e95dbecc7ccac20e0a29a333194032af9696961c317876d5b971f282644167ba6fe7135e9ac86447e  includedir.patch.in
+2801d6e0656b0a9eb090c6a3eee711588515a600e1292a6ba5ce24302c57bb7feb128139c0eb7715af0ddc2f40a7a2832c6e4153fe4d3a467297957a4afb3123  php7.1-module.conf
+066db134f9cd4695caf62cbb970bd13cbcf8d074a8e378945e2c6e80d3b8f4125f7cee2ee5b379359881958955d9737eb24cbfdb72d11c19bd432101ee119501  php7.1-fpm.logrotate
+bf8bfbd33134acaa5395336005361519ded1062f461483c18cf69d0395c4fb950802fcfb186c9b54ac382c51e2b634341757ffff9eb7af2dcf017be5af587d1f  php7.1-fpm.initd
+5e5073aca1ac3c4b1163d7c943f059d00faf04f29db766a0fc1ed3aecf9b7260491c5703aff651baa7ca944d750ff0318ce66aaac5b8500f41056b5357d3fa9f  php7.1-fpm.patch
+3f5da2f3b904ceb14f8507b924b046dfbee601e274fd501150a78fe362983ee1209ce596e880ed5481a857c4eb9d3deba26c4c14d04fd58075be93e98436f0cd  php7.1-includedir.patch
 f1177cbf6b1f44402f421c3d317aab1a2a40d0b1209c11519c1158df337c8945f3a313d689c939768584f3e4edbe52e8bd6103fb6777462326a9d94e8ab1f505  install-pear.patch
 da012a82c00f9dfd3b6e446e2c3e7da597079e9b428f53ca61b5e216c304e3c02e953a5fc2759e516580cb98f08e86b0f5b33ea8df99a8003ae33fcb431463b4  getrandom.patch"
diff --git a/testing/php7.1/php-fpm.initd.in b/testing/php7.1/php7.1-fpm.initd
similarity index 90%
rename from testing/php7.1/php-fpm.initd.in
rename to testing/php7.1/php7.1-fpm.initd
index f892559e1b..37e7e02852 100644
--- a/testing/php7.1/php-fpm.initd.in
+++ b/testing/php7.1/php7.1-fpm.initd
@@ -8,7 +8,7 @@
 
 : ${name:="PHP FastCGI Process Manager"}
 
-command="/usr/sbin/php-fpm@_suffix@"
+command="/usr/sbin/php-fpm7.1"
 command_background="yes"
 start_stop_daemon_args="--quiet"
 pidfile="/run/$RC_SVCNAME/php-fpm.pid"
@@ -29,12 +29,12 @@ depend() {
 
 init_vars() {
 	# Defaults for single master process with multiple pools
-	if [ "$RC_SVCNAME" = "php-fpm@_suffix@" ]; then
-		: ${fpm_config:="/etc/php@_suffix@/php-fpm.conf"}
+	if [ "$RC_SVCNAME" = "php-fpm7.1" ]; then
+		: ${fpm_config:="/etc/php7.1/php-fpm.conf"}
 		: ${user:="root"}
 	# Defaults for master process per pool
 	else
-		: ${fpm_config="/etc/php@_suffix@/php-fpm.d/${RC_SVCNAME#php-fpm@_suffix@.}.conf"}
+		: ${fpm_config="/etc/php7.1/php-fpm.d/${RC_SVCNAME#php-fpm7.1.}.conf"}
 		: ${user:="$(conf_get user)"}
 		: ${user:="nobody"}
 		: ${group:="$(conf_get group)"}
diff --git a/testing/php7.1/php-fpm.logrotate.in b/testing/php7.1/php7.1-fpm.logrotate
similarity index 56%
rename from testing/php7.1/php-fpm.logrotate.in
rename to testing/php7.1/php7.1-fpm.logrotate
index ac1fcb2b35..aafe126a62 100644
--- a/testing/php7.1/php-fpm.logrotate.in
+++ b/testing/php7.1/php7.1-fpm.logrotate
@@ -1,4 +1,4 @@
-/var/log/php@_suffix@/*.log {
+/var/log/php7.1/*.log {
 	rotate 7
 	daily
 	missingok
@@ -8,6 +8,6 @@
 	dateext
 	sharedscripts
 	postrotate
-		/etc/init.d/php-fpm@_suffix@ --ifstarted --quiet reopen
+		/etc/init.d/php-fpm7.1 --ifstarted --quiet reopen
 	endscript
 }
diff --git a/testing/php7.1/php-fpm.patch.in b/testing/php7.1/php7.1-fpm.patch
similarity index 67%
rename from testing/php7.1/php-fpm.patch.in
rename to testing/php7.1/php7.1-fpm.patch
index b6b5917e74..480c5c4b7a 100644
--- a/testing/php7.1/php-fpm.patch.in
+++ b/testing/php7.1/php7.1-fpm.patch
@@ -3,53 +3,53 @@
 @@ -1180,3 +1180,3 @@
  	if (!fpm_global_config.error_log) {
 -		fpm_global_config.error_log = strdup("log/php-fpm.log");
-+		fpm_global_config.error_log = strdup("log/php@_suffix@/error.log");
++		fpm_global_config.error_log = strdup("log/php7.1/error.log");
  	}
 @@ -1191,3 +1191,3 @@
  	if (!fpm_global_config.syslog_ident) {
 -		fpm_global_config.syslog_ident = strdup("php-fpm");
-+		fpm_global_config.syslog_ident = strdup("php-fpm@_suffix@");
++		fpm_global_config.syslog_ident = strdup("php-fpm7.1");
  	}
 @@ -1683,3 +1683,3 @@
  		} else {
 -			spprintf(&tmp, 0, "%s/etc/php-fpm.conf", fpm_globals.prefix);
-+			spprintf(&tmp, 0, "%s/etc/php@_suffix@/php-fpm.conf", fpm_globals.prefix);
++			spprintf(&tmp, 0, "%s/etc/php7.1/php-fpm.conf", fpm_globals.prefix);
  		}
 --- a/sapi/fpm/php-fpm.conf.in
 +++ b/sapi/fpm/php-fpm.conf.in
 @@ -16,3 +16,3 @@
  ; Default Value: none
 -;pid = run/php-fpm.pid
-+;pid = run/php-fpm@_suffix@.pid
++;pid = run/php-fpm7.1.pid
  
 @@ -22,4 +22,4 @@
  ; Note: the default prefix is @EXPANDED_LOCALSTATEDIR@
 -; Default Value: log/php-fpm.log
 -;error_log = log/php-fpm.log
-+; Default Value: log/php@_suffix@/error.log
-+;error_log = log/php@_suffix@/error.log
++; Default Value: log/php7.1/error.log
++;error_log = log/php7.1/error.log
  
 @@ -35,4 +35,4 @@
  ; which must suit common needs.
 -; Default Value: php-fpm
 -;syslog.ident = php-fpm
-+; Default Value: php-fpm@_suffix@
-+;syslog.ident = php-fpm@_suffix@
++; Default Value: php-fpm7.1
++;syslog.ident = php-fpm7.1
  
 --- a/sapi/fpm/www.conf.in
 +++ b/sapi/fpm/www.conf.in
 @@ -252,3 +252,3 @@
  ; Default: not set
 -;access.log = log/$pool.access.log
-+;access.log = log/php@_suffix@/$pool.access.log
++;access.log = log/php7.1/$pool.access.log
  
 @@ -316,3 +316,3 @@
  ; Note: slowlog is mandatory if request_slowlog_timeout is set
 -;slowlog = log/$pool.log.slow
-+;slowlog = log/php@_suffix@/$pool.slow.log
++;slowlog = log/php7.1/$pool.slow.log
  
 @@ -410,3 +410,3 @@
  ;php_flag[display_errors] = off
 -;php_admin_value[error_log] = /var/log/fpm-php.www.log
-+;php_admin_value[error_log] = /var/log/php@_suffix@/$pool.error.log
++;php_admin_value[error_log] = /var/log/php7.1/$pool.error.log
  ;php_admin_flag[log_errors] = on
diff --git a/testing/php7.1/includedir.patch.in b/testing/php7.1/php7.1-includedir.patch
similarity index 83%
rename from testing/php7.1/includedir.patch.in
rename to testing/php7.1/php7.1-includedir.patch
index 8087b6200d..8075eecb75 100644
--- a/testing/php7.1/includedir.patch.in
+++ b/testing/php7.1/php7.1-includedir.patch
@@ -5,7 +5,7 @@
  #
  
 -phpincludedir = $(includedir)/php
-+phpincludedir = $(includedir)/php@_suffix@
++phpincludedir = $(includedir)/php7.1
  phpbuilddir = $(libdir)/build
  
  BUILD_FILES = \
@@ -13,7 +13,7 @@
 +++ b/ext/pdo/Makefile.frag
 @@ -1,4 +1,4 @@
 -phpincludedir=$(prefix)/include/php
-+phpincludedir=$(prefix)/include/php@_suffix@
++phpincludedir=$(prefix)/include/php7.1
  
  PDO_HEADER_FILES= \
  	php_pdo.h \
@@ -24,7 +24,7 @@
  version="@PHP_VERSION@"
  vernum="@PHP_VERSION_ID@"
 -include_dir="@includedir@/php"
-+include_dir="@includedir@/php@_suffix@"
++include_dir="@includedir@/php7.1"
  includes="-I$include_dir -I$include_dir/main -I$include_dir/TSRM -I$include_dir/Zend -I$include_dir/ext -I$include_dir/ext/date/lib"
  ldflags="@PHP_LDFLAGS@"
  libs="@EXTRA_LIBS@"
@@ -35,7 +35,7 @@
  exec_prefix="`eval echo @exec_prefix@`"
  phpdir="`eval echo @libdir@`/build"
 -includedir="`eval echo @includedir@`/php"
-+includedir="`eval echo @includedir@`/php@_suffix@"
++includedir="`eval echo @includedir@`/php7.1"
  builddir="`pwd`"
  SED="@SED@"
  
diff --git a/testing/php7.1/php-module.conf.in b/testing/php7.1/php7.1-module.conf
similarity index 67%
rename from testing/php7.1/php-module.conf.in
rename to testing/php7.1/php7.1-module.conf
index 267ad00e6e..80f2654f63 100644
--- a/testing/php7.1/php-module.conf.in
+++ b/testing/php7.1/php7.1-module.conf
@@ -1,4 +1,4 @@
-LoadModule php@_suffix@_module modules/mod_php@_suffix@.so
+LoadModule php7.1_module modules/mod_php7.1.so
 
 DirectoryIndex index.php index.html
 AddHandler application/x-httpd-php .php
-- 
2.11.1

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---