Mail archive
alpine-aports

[alpine-aports] [PATCH] main/php: APKBUILD and php-fpm.initd cleanups

From: Valery Kartel <valery.kartel_at_gmail.com>
Date: Fri, 8 Jan 2016 14:24:07 +0200

- fix arch=noarch for php, php-common, php-pear
- php-fpm and php-apache2 package code moved from main to related subpackages
- clean init script for php-fpm
---
 main/php/APKBUILD      | 55 +++++++++++++++++++++-----------------------------
 main/php/php-fpm.initd | 37 +++++++++++----------------------
 2 files changed, 35 insertions(+), 57 deletions(-)
diff --git a/main/php/APKBUILD b/main/php/APKBUILD
index 4ec398e..4c8f049 100644
--- a/main/php/APKBUILD
+++ b/main/php/APKBUILD
_at_@ -10,7 +10,6 @@ url="http://www.php.net/"
 arch="all"
 license="PHP-3"
 depends="$pkgname-cli"
-# -dev package needs phpize
 depends_dev="$pkgname-cli pcre-dev"
 install="$pkgname.post-upgrade"
 makedepends="
_at_@ -288,32 +287,13 @@ build() {
 
 package() {
 	cd "$srcdir"/build-cgi
-
+	arch="noarch"
 	# install php-cgi, cli, pear and modules
 	make -j1 install install-pear INSTALL_ROOT="$pkgdir" || return 1
 
 	# cleanup after pear
 	find "$pkgdir" -name '.*' | xargs rm -rf || return 1
 
-	# install fpm
-	install -D -m755 "$srcdir"/build-fpm/sapi/fpm/php-fpm \
-		"$pkgdir"/usr/bin/php-fpm || return 1
-	install -D -m644 "$srcdir"/build-fpm/sapi/fpm/php-fpm.conf \
-		"$pkgdir"/etc/php/php-fpm.conf || return 1
-	install -D -m755 "$srcdir"/php-fpm.initd "$pkgdir"/etc/init.d/php-fpm
-	# enable some default options
-	sed -ri -e "s~^;(error_log)(.*)~\1 = /var/log/php-fpm.log~" \
-		-e "s/^;(pm.start_servers)/\1/" \
-		-e "s/^;(pm.min_spare_servers)/\1/" \
-		-e "s/^;(pm.max_spare_servers)/\1/" \
-		"$pkgdir"/etc/php/php-fpm.conf || return 1
-
-	# install apache2
-	install -D -m755 "$srcdir"/build-apache2/libs/libphp5.so \
-		"$pkgdir"/usr/lib/apache2/libphp5.so || return 1
-	install -D -m644 "$srcdir"/php5-module.conf \
-		"$pkgdir"/etc/apache2/conf.d/php5-module.conf || return 1
-
 	# install embed
 	install -D -m755 "$srcdir"/build-embed/libs/libphp5.so \
 		"$pkgdir"/usr/lib/libphp5.so || return 1
_at_@ -346,7 +326,7 @@ common() {
 	pkgdesc="PHP Common Files"
 	replaces="$pkgname"
 	depends=""
-
+	arch="noarch"
 	cd "$srcdir"/$pkgname-$pkgver
 	install -D -m644 php.ini-production "$subpkgdir"/etc/php/php.ini
 	sed -i -e "s:^; extension_dir = \"./\":extension_dir = \"$_extdir\":" "$subpkgdir"/etc/php/php.ini
_at_@ -375,18 +355,28 @@ cli() {
 fpm() {
 	pkgdesc="PHP FastCGI Process Manager (FPM)"
 	depends="php-common"
-	mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/etc/php
-	mv "$pkgdir"/usr/bin/php-fpm "$subpkgdir"/usr/bin/ || return 1
-	mv "$pkgdir"/etc/init.d "$subpkgdir"/etc/ || return 1
-	mv "$pkgdir"/etc/php/php-fpm.conf "$subpkgdir"/etc/php/
+	mkdir -p "$subpkgdir"/etc/php/fpm.d
+	install -D -m755 "$srcdir"/build-fpm/sapi/fpm/php-fpm \
+		"$subpkgdir"/usr/bin/php-fpm || return 1
+	install -D -m644 "$srcdir"/build-fpm/sapi/fpm/php-fpm.conf \
+		"$subpkgdir"/etc/php/php-fpm.conf || return 1
+	install -D -m755 "$srcdir"/php-fpm.initd "$subpkgdir"/etc/init.d/php-fpm
+	# enable some default options
+	sed -ri	-e "s~^;(error_log)(.*)~\1 = /var/log/php-fpm.log~" \
+		-e "s~^;(include)(.*)~\1 = /etc/php/fpm.d/*.conf~" \
+		-e "s/^;(pm.start_servers)/\1/" \
+		-e "s/^;(pm.min_spare_servers)/\1/" \
+		-e "s/^;(pm.max_spare_servers)/\1/" \
+		"$subpkgdir"/etc/php/php-fpm.conf || return 1
 }
 
 apache2() {
 	pkgdesc="PHP Module for Apache2"
 	depends="php-common apache2"
-	mkdir -p "$subpkgdir"/usr/lib "$subpkgdir"/etc
-	mv "$pkgdir"/usr/lib/apache2 "$subpkgdir"/usr/lib/ &&\
-		mv "$pkgdir"/etc/apache2 "$subpkgdir"/etc
+	install -D -m755 "$srcdir"/build-apache2/libs/libphp5.so \
+		"$subpkgdir"/usr/lib/apache2/libphp5.so || return 1
+	install -D -m644 "$srcdir"/php5-module.conf \
+		"$subpkgdir"/etc/apache2/conf.d/php5-module.conf || return 1
 }
 
 embed() {
_at_@ -399,6 +389,7 @@ embed() {
 pear() {
 	pkgdesc="PHP Extension and Application Repository (PEAR)"
 	depends="php-cli php-xml"
+	arch="noarch"
 	mkdir -p "$subpkgdir"/usr/share "$subpkgdir"/etc/php \
 		"$subpkgdir"/usr/bin
 	mv "$pkgdir"/usr/bin/pecl \
_at_@ -504,21 +495,21 @@ wddx()		{ _mv_ext wddx; }
 opcache()	{ _mv_ext opcache; }
 
 md5sums="23e2183852b172a8e2b2c739b7dde4ca  php-5.6.17.tar.bz2
-08932656a9fe2d0b329805097efb033a  php-fpm.initd
+02417a82d080c858933e945ced0c6818  php-fpm.initd
 67719f428f44ec004da18705cbabe2ee  php5-module.conf
 483bc0a85c50a9a9aedbe14a19ed4526  php-install-pear-xml.patch
 162d8d079944387eab2bc80edab347ae  gd-iconv.patch
 b63ef63893c1c115d6dd63e8df1f17e3  php-fix-crypt.patch
 cb10034c525c6544890f1a1839837e38  fix-crypt-sha.patch"
 sha256sums="77b45f56a1e63e75bb22b42cfb8b438ec4083c59ce774b4d7c1685544b7add3b  php-5.6.17.tar.bz2
-c60b956b909c347de57265654c76b6fb903248adc709c07966a39584a3ef65fe  php-fpm.initd
+3ad0252894d628e9832dbefb24d7043ac0f75475cd26d6ca12332e71cc3fc0f5  php-fpm.initd
 ceec4d5b2a128c6a97e49830af604f0bb555bca1a86a9cd0366b828ba392257f  php5-module.conf
 f739ca427a1dd53a388bad0823565299c5d4a5796b1171b892884e4d7d099bab  php-install-pear-xml.patch
 6122bf279cdb7c387dd000761b2426969a73cf63a10a132aa98a79eb1dd259b2  gd-iconv.patch
 817f6300cd0c4d97f24c3e883132d2cde0ef52d84f5c97073f9c9668d6275d6e  php-fix-crypt.patch
 a5db307ad2638e7e609b450abce19c98c23de54be96619b46adb69f2c5e11fa2  fix-crypt-sha.patch"
 sha512sums="706fd31324c98717d44b4db4440a5eaffe24ad34b346ba95418b33ee072b3ddde5d7429d318f69554b4bfcd7dcc0e9e4b07142b539196e9f0ab7707485ad9dbb  php-5.6.17.tar.bz2
-f88eb6b44d1418d2373a7a0de56e17bc392b5afd87a9a3953183f2dcb62cfd8e5ac9ba8a5c481efce4058a68624c0be88b42c804fc386175cda158b71c82bea7  php-fpm.initd
+38c24e84c9be2dcf4f291e5f04187f40e5a8b325da73e79580d82b8a9e0e496c4fb17df92dcf8157bb9df4f1beadce102df9265c83849ca4e55560abf4937c43  php-fpm.initd
 895e94c791bd82060ad820fef049d366a09c932097faa6b7b9a2c2e9e00a18cb7c0f9b128679c7659b404379266fd0f95dba5c0333f626194cf60f7bf6044102  php5-module.conf
 f1177cbf6b1f44402f421c3d317aab1a2a40d0b1209c11519c1158df337c8945f3a313d689c939768584f3e4edbe52e8bd6103fb6777462326a9d94e8ab1f505  php-install-pear-xml.patch
 59443fb464f49ff7d9b64739df982e7240f9d4792226d96ad1538286945125fc7eb6f0cab88b64d5c81ee3679fd89bffdca59ebd20eca2778ab801ee54529028  gd-iconv.patch
diff --git a/main/php/php-fpm.initd b/main/php/php-fpm.initd
index a7e6798..814c2bb 100644
--- a/main/php/php-fpm.initd
+++ b/main/php/php-fpm.initd
_at_@ -1,10 +1,12 @@
 #!/sbin/openrc-run
 
-PHP_FPM_CONF="/etc/php/php-fpm.conf"
+name="PHP FastCGI Process Manager"
+cfgfile="/etc/php/php-fpm.conf"
 pidfile="/var/run/php-fpm.pid"
-command=/usr/bin/php-fpm
+command="/usr/bin/php-fpm"
+command_args="--fpm-config $cfgfile --pid $pidfile"
+required_files="$cfgfile"
 
-extra_commands="depend"
 extra_started_commands="reload"
 
 depend() {
_at_@ -12,29 +14,14 @@ depend() {
 	use apache2 lighttpd nginx
 }
 
-start() {
-        ebegin "Starting PHP FastCGI Process Manager"
-        start-stop-daemon --start --pidfile ${pidfile} --exec ${command} \
-            -- --fpm-config "${PHP_FPM_CONF}" --pid "${pidfile}"
-        local i=0
-        local timeout=50
-        while [ ! -f ${pidfile} ] && [ $i -le $timeout ]; do
-            sleep 0.1
-            i=$(($i + 1))
-        done
-
-        [ $timeout -gt $i ]
-        eend $?
-}
-
-stop() {
-        ebegin "Stopping PHP FastCGI Process Manager"
-        start-stop-daemon --signal QUIT --stop --pidfile ${pidfile}
-        eend $?
+start_pre() {
+	ebegin
+	$command $command_args -t 2>/dev/null
+	eend $?
 }
 
 reload() {
-    ebegin "Reloading PHP FastCGI Process Manager"
-    [ -f ${pidfile} ] && kill -USR2 $(cat ${pidfile})
-    eend $?
+	ebegin "Reloading $name"
+	start-stop-daemon --signal USR2 --pidfile ${pidfile} --name ${SVCNAME}
+	eend $?
 }
-- 
2.6.4
---
Unsubscribe:  alpine-aports+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-aports+help_at_lists.alpinelinux.org
---
Received on Fri Jan 08 2016 - 14:24:07 GMT