Skip to content

Instantly share code, notes, and snippets.

@Keruspe
Created September 15, 2015 14:40
Show Gist options
  • Save Keruspe/e44d5d29dda48415beff to your computer and use it in GitHub Desktop.
Save Keruspe/e44d5d29dda48415beff to your computer and use it in GitHub Desktop.
stdin
From 7068c405801c13b140be2c874d51d1fc233281c5 Mon Sep 17 00:00:00 2001
From: Marc-Antoine Perennou <keruspe@exherbo.org>
Date: Fri, 11 Sep 2015 19:25:02 +0200
Subject: [PATCH 1/4] introduce PHP_ABIS
Change-Id: Ib4495edc31f99366d0ffb3e5b8370a33f11338d7
Signed-off-by: Marc-Antoine Perennou <keruspe@exherbo.org>
---
metadata/options/descriptions/php_abis.conf | 3 +++
profiles/make.defaults | 2 +-
profiles/options.conf | 6 +++++-
3 files changed, 9 insertions(+), 2 deletions(-)
create mode 100644 metadata/options/descriptions/php_abis.conf
diff --git a/metadata/options/descriptions/php_abis.conf b/metadata/options/descriptions/php_abis.conf
new file mode 100644
index 0000000..2e992e1
--- /dev/null
+++ b/metadata/options/descriptions/php_abis.conf
@@ -0,0 +1,3 @@
+5.4 - Use PHP 5.4
+5.5 - Use PHP 5.5
+5.6 - Use PHP 5.6
diff --git a/profiles/make.defaults b/profiles/make.defaults
index 90652c1..030e4e9 100644
--- a/profiles/make.defaults
+++ b/profiles/make.defaults
@@ -8,7 +8,7 @@ CONFIG_PROTECT_MASK="/etc/env.d /etc/xdg"
# module that doesn't already have suitable bytecode written
PYTHONDONTWRITEBYTECODE=1
-MULTIBUILD_CLASSES="LUA_ABIS PYTHON_ABIS"
+MULTIBUILD_CLASSES="LUA_ABIS PHP_ABIS PYTHON_ABIS"
CROSS_COMPILE_TOOLS="AR:ar AS:as CC:cc CPP:cpp CXX:c++ FORTRAN:gfortran LD:ld NM:nm OBJCOPY:objcopy OBJDUMP:objdump PKG_CONFIG:pkg-config RANLIB:ranlib"
CROSS_COMPILE_FLAGS="CFLAGS CPPFLAGS:CFLAGS CXXFLAGS CXXCPPFLAGS:CXXFLAGS LDFLAGS FCFLAGS"
diff --git a/profiles/options.conf b/profiles/options.conf
index bda207d..40c050b 100644
--- a/profiles/options.conf
+++ b/profiles/options.conf
@@ -8,7 +8,7 @@
INPUT_DRIVERS KDE_PARTS KIPI_PLUGINS KOPETE_PLUGINS LINGUAS LUA_ABIS \
MODULES NGINX_MODULES NUT_DRIVERS PLATFORM PLUGINS AMD64_CPU_FEATURES \
ARM_CPU_FEATURES VIDEO_DRIVERS X86_CPU_FEATURES P2P_NETWORKS PCSC_DRIVERS \
- PHP_EXTENSIONS POSTGRESQL_EXTENSIONS PYTHON_ABIS PROVIDERS RUBY_ABIS
+ PHP_ABIS PHP_EXTENSIONS POSTGRESQL_EXTENSIONS PYTHON_ABIS PROVIDERS RUBY_ABIS
# Things in HIDDEN_SUBOPTIONS need to go in SUBOPTIONS too
*/* HIDDEN_SUBOPTIONS: PLATFORM AMD64_CPU_FEATURES ARM_CPU_FEATURES \
@@ -221,6 +221,10 @@ x11-libs/qtbase gui
# Default ruby version
*/* RUBY_ABIS: 2.0
+# Marc-Antoine Perennou <keruspe@exherbo.org>
+# Default php version
+*/* PHP_ABIS: 5.6
+
# Bo Ørsted Andresen <zlin@exherbo.org>
# gcc threads should always be enabled unless a new toolchain is being bootstrapped
sys-devel/gcc threads
--
2.5.2
From fbe754d27bf17dbf379480cf7b8d931bfd8830ff Mon Sep 17 00:00:00 2001
From: Marc-Antoine Perennou <keruspe@exherbo.org>
Date: Fri, 11 Sep 2015 16:14:39 +0200
Subject: [PATCH 2/4] php: allow slotting
Change-Id: I32bbe35ed7ab5374af438d4f369a5b4c0eb0d824
Signed-off-by: Marc-Antoine Perennou <keruspe@exherbo.org>
---
...5.4.45-r1.exheres-0 => php-5.4.45-r2.exheres-0} | 0
...5.6.13-r1.exheres-0 => php-5.5.29-r2.exheres-0} | 0
...5.5.29-r1.exheres-0 => php-5.6.13-r2.exheres-0} | 0
packages/dev-lang/php/php.exlib | 102 +++++++++++++++++----
4 files changed, 84 insertions(+), 18 deletions(-)
rename packages/dev-lang/php/{php-5.4.45-r1.exheres-0 => php-5.4.45-r2.exheres-0} (100%)
rename packages/dev-lang/php/{php-5.6.13-r1.exheres-0 => php-5.5.29-r2.exheres-0} (100%)
rename packages/dev-lang/php/{php-5.5.29-r1.exheres-0 => php-5.6.13-r2.exheres-0} (100%)
diff --git a/packages/dev-lang/php/php-5.4.45-r1.exheres-0 b/packages/dev-lang/php/php-5.4.45-r2.exheres-0
similarity index 100%
rename from packages/dev-lang/php/php-5.4.45-r1.exheres-0
rename to packages/dev-lang/php/php-5.4.45-r2.exheres-0
diff --git a/packages/dev-lang/php/php-5.6.13-r1.exheres-0 b/packages/dev-lang/php/php-5.5.29-r2.exheres-0
similarity index 100%
rename from packages/dev-lang/php/php-5.6.13-r1.exheres-0
rename to packages/dev-lang/php/php-5.5.29-r2.exheres-0
diff --git a/packages/dev-lang/php/php-5.5.29-r1.exheres-0 b/packages/dev-lang/php/php-5.6.13-r2.exheres-0
similarity index 100%
rename from packages/dev-lang/php/php-5.5.29-r1.exheres-0
rename to packages/dev-lang/php/php-5.6.13-r2.exheres-0
diff --git a/packages/dev-lang/php/php.exlib b/packages/dev-lang/php/php.exlib
index 5404d2e..ecd773d 100644
--- a/packages/dev-lang/php/php.exlib
+++ b/packages/dev-lang/php/php.exlib
@@ -1,9 +1,9 @@
# Copyright 2009-2015 Wulf C. Krueger <philantrop@exherbo.org>
# Distributed under the terms of the GNU General Public License v2
-export_exlib_phases src_test_expensive src_install
+export_exlib_phases pkg_pretend src_prepare src_test_expensive src_install
-require systemd-service
+require systemd-service alternatives
SUMMARY="PHP is a general-purpose scripting language especially suited for web development"
DESCRIPTION="
@@ -18,7 +18,7 @@ HOMEPAGE="http://www.${PN}.net"
DOWNLOADS="${HOMEPAGE}/distributions/${PNV}.tar.bz2"
LICENCES="PHP-3"
-SLOT="0"
+SLOT="$(ever range 1-2)"
MYOPTIONS="
debug
apache [[ description = [ Build PHP for the Apache webserver. ] ]]
@@ -136,6 +136,10 @@ DEPENDENCIES="
php_extensions:unixodbc? ( dev-db/unixODBC[>=2.2.14] )
php_extensions:xml? ( dev-libs/libxml2:2.0[>=2.7.2_p20081127] )
php_extensions:xsl? ( dev-libs/libxslt[>=1.1.0] )
+ !dev-lang/php:0 [[
+ description = [ php is now slotted ]
+ resolution = uninstall-blocked-before
+ ]]
"
if ever at_least 5.6.4; then
@@ -158,7 +162,7 @@ RESTRICT="test"
DEFAULT_SRC_CONFIGURE_PARAMS=(
--hates=docdir
- --libdir=/usr/share/${PN}
+ --libdir=/usr/share/${PN}-${SLOT}
--localstatedir=/var
--enable-bcmath
--enable-calendar
@@ -188,8 +192,8 @@ DEFAULT_SRC_CONFIGURE_PARAMS=(
--disable-embed
--disable-embedded-mysqli
--with-bz2
- --with-config-file-path=/etc/${PN}
- --with-config-file-scan-dir=/etc/${PN}
+ --with-config-file-path=/etc/${PN}-${SLOT}
+ --with-config-file-scan-dir=/etc/${PN}-${SLOT}
--with-gettext
--with-gmp
--with-iconv
@@ -271,7 +275,7 @@ DEFAULT_SRC_CONFIGURE_OPTION_ENABLES=(
DEFAULT_SRC_CONFIGURE_OPTION_WITHS=(
"apache apxs2"
- pear
+ "pear pear /usr/share/pear-${SLOT}"
"php_extensions:curl curl"
"php_extensions:berkdb db4"
"php_extensions:gd gd"
@@ -337,6 +341,33 @@ DEFAULT_SRC_INSTALL_EXCLUDE=(
README.Zeus
)
+check_legacy_conf_dir() {
+ [[ -d "${1}" && ! -L "${1}" ]] && elog "${1} is not a symlink, please rename it to ${1}-${SLOT}"
+}
+
+check_legacy_conf_file() {
+ [[ -f "${1}" && ! -L "${1}" ]] && elog "${1} is not a symlink, please rename it to ${1/.conf}-${SLOT}.conf"
+}
+
+check_legacy_config() {
+ check_legacy_conf_dir "/etc/php" || \
+ check_legacy_conf_dir "/usr/share/php" || \
+ check_legacy_conf_dir "/usr/share/pear" || \
+ check_legacy_conf_file "/etc/pear.conf" || \
+ check_legacy_conf_file "/etc/php-fpm.conf" || \
+ check_legacy_conf_file "/etc/php-fpm.conf.default"
+}
+
+php_pkg_pretend() {
+ check_legacy_config && die "User interaction required"
+}
+
+php_src_prepare() {
+ default
+ edo sed -e "/includedir=/s/php/&-${SLOT}/" -i scripts/phpize.in
+ edo sed -e "s/php-config/&-${SLOT}/" -i scripts/phpize.m4
+}
+
php_src_test_expensive() {
return
@@ -349,9 +380,11 @@ php_src_test_expensive() {
php_src_install() {
export PHP_PEAR_TEMP_DIR="/tmp"
- export PHP_PEAR_CACHE_DIR="/var/cache/pear"
+ export PHP_PEAR_CACHE_DIR="/var/cache/pear-${SLOT}"
export PHP_PEAR_DOWNLOAD_DIR="/tmp"
+ local alternatives=()
+
# Needed but useless because we'll remove it later.
if option apache; then
edo mkdir -p "${IMAGE}"/etc/apache2
@@ -360,7 +393,7 @@ php_src_install() {
# Allow installation of various PEAR extensions if PEAR is enabled.
if option pear; then
- esandbox allow /usr/share/pear/.lock
+ esandbox allow /usr/share/pear-${SLOT}/.lock
fi
default
@@ -377,21 +410,42 @@ php_src_install() {
fi
if option pear; then
- keepdir /usr/share/pear/.registry/.channel.__uri
- keepdir /usr/share/pear/.registry/.channel.{doc,pecl}.php.net
+ keepdir /usr/share/pear-${SLOT}/.registry/.channel.__uri
+ keepdir /usr/share/pear-${SLOT}/.registry/.channel.{doc,pecl}.php.net
fi
- dodir /etc/${PN}
- insinto /etc/${PN}
+ alternatives+=(
+ /usr/$(exhost --target)/include/php php-${SLOT}
+ /usr/share/php php-${SLOT}
+ )
+
+ for bin in phar.phar phar php php-cgi php-config phpize; do
+ alternatives+=(
+ /usr/$(exhost --target)/bin/${bin} ${bin}-${SLOT}
+ /usr/share/man/man1/${bin}.1 ${bin}-${SLOT}.1
+ )
+ done
+
+ dodir /etc/${PN}-${SLOT}
+ insinto /etc/${PN}-${SLOT}
newins php.ini-production php.ini
+ alternatives+=( /etc/php php-${SLOT} )
if option pear; then
- edo sed -i -e 's|^;\(include_path =\).*|\1 ".:/usr/share/pear:/usr/share/php:"|' "${IMAGE}"/etc/php/php.ini
+ edo sed -i -e 's|^;\(include_path =\).*|\1 ".:/usr/share/pear-'${SLOT}':/usr/share/php-'${SLOT}':"|' "${IMAGE}"/etc/php-${SLOT}/php.ini
keepdir "${PHP_PEAR_CACHE_DIR}"
+ alternatives+=(
+ /etc/pear.conf pear-${SLOT}.conf
+ /var/cache/pear pear-${SLOT}
+ /usr/share/pear pear-${SLOT}
+ )
+ for bin in pear peardev pecl; do
+ alternatives+=( /usr/$(exhost --target)/bin/${bin} ${bin}-${SLOT} )
+ done
fi
if option php_extensions:mysql ; then
- edo sed -i -e 's:.*\(mysql.default_socket =\).*:\1 "/run/mysqld/mysqld.sock":' "${IMAGE}"/etc/php/php.ini
+ edo sed -i -e 's:.*\(mysql.default_socket =\).*:\1 "/run/mysqld/mysqld.sock":' "${IMAGE}"/etc/php-${SLOT}/php.ini
fi
if option apache; then
@@ -407,11 +461,23 @@ php_src_install() {
fi
fi
- install_systemd_files
+ if option fpm; then
+ install_systemd_files
+ alternatives+=(
+ /usr/$(exhost --target)/bin/php-fpm php-fpm-${SLOT}
+ /usr/share/man/man8/php-fpm.8 php-fpm-${SLOT}.8
+ /usr/share/fpm php-fpm-${SLOT}
+ /etc/php-fpm.conf php-fpm-${SLOT}.conf
+ /etc/php-fpm.conf.default php-fpm-${SLOT}.conf.default
+ ${SYSTEMDSYSTEMUNITDIR}/php-fpm.service php-fpm-${SLOT}.service
+ )
+ fi
# Set extension_dir path. Only replace the first occurence.
- linenum=$(edo grep -n "extension_dir" "${IMAGE}"/etc/php/php.ini | head -1 | awk -F: '{ print $1}')
+ linenum=$(edo grep -n "extension_dir" "${IMAGE}"/etc/php-${SLOT}/php.ini | head -1 | awk -F: '{ print $1}')
extension_dir=$(edo "${IMAGE}"/usr/$(exhost --target)/bin/php-config --extension-dir | sed -e 's/\//\\\//g')
- edo sed -i -e "${linenum},${linenum} s/; extension_dir = \".\/\"/extension_dir = \"${extension_dir}\"/" "${IMAGE}"/etc/php/php.ini
+ edo sed -i -e "${linenum},${linenum} s/; extension_dir = \".\/\"/extension_dir = \"${extension_dir}\"/" "${IMAGE}"/etc/php-${SLOT}/php.ini
+
+ alternatives_for ${PN} ${SLOT} ${SLOT} "${alternatives[@]}"
}
--
2.5.2
From 7f38261e8221cca0229dbffc00c4900ba3e630db Mon Sep 17 00:00:00 2001
From: Marc-Antoine Perennou <keruspe@exherbo.org>
Date: Fri, 11 Sep 2015 19:55:47 +0200
Subject: [PATCH 3/4] php-pecl: multiphp
Change-Id: Id0f9e4a5cc9eef17acea7d18f8c88aba4d40f7a9
Signed-off-by: Marc-Antoine Perennou <keruspe@exherbo.org>
---
exlibs/php-pecl.exlib | 73 +++++++++++++++++++++++++++++++++++++--------------
1 file changed, 53 insertions(+), 20 deletions(-)
diff --git a/exlibs/php-pecl.exlib b/exlibs/php-pecl.exlib
index 11dcaf8..01117cf 100644
--- a/exlibs/php-pecl.exlib
+++ b/exlibs/php-pecl.exlib
@@ -1,16 +1,18 @@
# Copyright 2010 Anders Ladegaard Marchsteiner <alm.anma@gmail.com>
+# Copyright 2015 Marc-Antoine Perennou <keruspe@exherbo.org>
# Distributed under the terms of the GNU General Public License v2
# Based in part upon 'php-pear.exlib', which is:
# Copyright 2009 Wulf C. Krueger <philantrop@exherbo.org>
-export_exlib_phases src_configure src_install
-
+# Specify whether the module is a "zend" module or a standard "module"
myexparam module=extension
-DEPENDENCIES="
- build+run:
- dev-lang/php[pear]
-"
+# If the package doesn't support all php slots, you have to list
+# all supported slots yourself
+myexparam php_abis=[ 5.4 5.5 5.6 ]
+
+exparam -v PHP_MODULE_TYPE module
+exparam -v PHP_ABIS php_abis[@]
fix_PECL_PV() {
tmp="${PV}"
@@ -30,33 +32,64 @@ fix_PECL_PV() {
UPSTREAM_CHANGELOG="http://pecl.php.net/package-changelog.php?package=${PN}&release=${PECL_PV}"
-WORK=${WORKBASE}/${PN}-${PECL_PV}
+MY_PNV="${PN}-${PECL_PV}"
+
+MULTIBUILD_PHP_ABIS_TARGETS="${PHP_ABIS[@]}"
-install_module_config() {
- edo echo "extension = ${PN}.so" > "${IMAGE}"/etc/php/${PN}.ini
+require easy-multibuild [ classes=[ PHP_ABIS ] multiunpack=true work=${MY_PNV} ]
+
+php_myoptions() {
+ local abi
+ echo -n "( php_abis: "
+ for abi in "${PHP_ABIS[@]}"; do
+ echo -n "${abi} "
+ done
+ echo -n ") [[ number-selected = at-least-one ]]"
}
-install_zend_config() {
- extensionDir=$(php-config --extension-dir)
- extensionFileName="${extensionDir}/${PN}.so"
- edo echo "zend_extension = ${extensionFileName}" > "${IMAGE}"/etc/php/${PN}.ini
+php_dependencies() {
+ local abi
+ echo "("
+ for abi in "${PHP_ABIS[@]}"; do
+ echo "php_abis:${abi}? ( dev-lang/php:${abi}[pear] )"
+ done
+ echo ")"
}
-php-pecl_src_configure() {
- phpize
+MYOPTIONS="$(php_myoptions)"
+
+DEPENDENCIES="
+ build+run:
+ $(php_dependencies)
+"
+
+php-pecl_get_abi() {
+ illegal_in_global_scope
+ echo -n "${MULTIBUILD_PHP_ABIS_CURRENT_TARGET}"
+}
+
+prepare_one_multibuild() {
default
+ edo phpize-$(php-pecl_get_abi)
+}
+
+configure_one_multibuild() {
+ PHP_PHP_CONFIG=php-config-$(php-pecl_get_abi) default
}
-php-pecl_src_install() {
- exparam -v PHP_MODULE_TYPE module
+install_one_multibuild() {
+ local abi=$(php-pecl_get_abi)
+ local extensionDir extensionFileName
- edo mkdir -p "${IMAGE}"/etc/php
+ edo mkdir -p "${IMAGE}"/etc/php-${abi}
if [[ "$PHP_MODULE_TYPE" == "zend" ]] ; then
- install_zend_config
+ extensionDir=$(php-config-${abi} --extension-dir)
+ extensionFileName="${extensionDir}/${PN}.so"
+ edo echo "zend_extension = ${extensionFileName}" > "${IMAGE}"/etc/php-${abi}/${PN}.ini
elif [[ "$PHP_MODULE_TYPE" == "module" ]] ; then
- install_module_config
+ edo echo "extension = ${PN}.so" > "${IMAGE}"/etc/php-${abi}/${PN}.ini
else
die "Invalid module type"
fi
--
2.5.2
From 3564dd4b1d42b13d00981ac821779d0347f507a6 Mon Sep 17 00:00:00 2001
From: Marc-Antoine Perennou <keruspe@exherbo.org>
Date: Fri, 11 Sep 2015 23:17:17 +0200
Subject: [PATCH 4/4] multiphp: add news entry
Change-Id: Ifd047d10038bcb29b07919ce80796eaeb4d25421
Signed-off-by: Marc-Antoine Perennou <keruspe@exherbo.org>
---
.../2015-09-11-multiphp/2015-09-11-multiphp.en.txt | 23 ++++++++++++++++++++++
1 file changed, 23 insertions(+)
create mode 100644 metadata/news/2015-09-11-multiphp/2015-09-11-multiphp.en.txt
diff --git a/metadata/news/2015-09-11-multiphp/2015-09-11-multiphp.en.txt b/metadata/news/2015-09-11-multiphp/2015-09-11-multiphp.en.txt
new file mode 100644
index 0000000..7c5b1d2
--- /dev/null
+++ b/metadata/news/2015-09-11-multiphp/2015-09-11-multiphp.en.txt
@@ -0,0 +1,23 @@
+Title: MultiPHP
+Author: Marc-Antoine Perennou <keruspe@exherbo.org>
+Content-Type: text/plain
+Posted: 2015-09-11
+Revision: 1
+News-Item-Format: 1.0
+Display-If-Installed: dev-lang/php
+
+Here comes multiphp.
+You will now be able to install multiple versions of php in parallel
+slots and install your dev-pecl/* stuff for several versions.
+
+The only manual action required is that if you currently are using
+php 5.6 for example, you have to do:
+
+mv /etc/php /etc/php-5.6
+mv /etc/pear.conf /etc/pear-5.6.conf
+
+The used suboption is "php_abis", currently supporting slots
+5.4, 5.5 and 5.6
+
+php-pecl.exlib gain one exparam:
+- php_slots: the list of supported slots (defaults to all)
--
2.5.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment