summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Orlitzky <mjo@gentoo.org>2015-12-06 19:29:56 -0500
committerMichael Orlitzky <mjo@gentoo.org>2015-12-06 19:29:56 -0500
commita6faf22fb94279c1cd677c39ec872b282d0ad7a4 (patch)
tree8b7946c95b2131b95f26783c3bda83182fc10d7d
parentLine length, whitespace, and typo cleanup. (diff)
downloadeselect-php-a6faf22fb94279c1cd677c39ec872b282d0ad7a4.tar.gz
eselect-php-a6faf22fb94279c1cd677c39ec872b282d0ad7a4.tar.bz2
eselect-php-a6faf22fb94279c1cd677c39ec872b282d0ad7a4.zip
Combine the libphp5/libphp7 branches.
-rw-r--r--src/php.eselect.in58
1 files changed, 32 insertions, 26 deletions
diff --git a/src/php.eselect.in b/src/php.eselect.in
index 271c73b..b729ca2 100644
--- a/src/php.eselect.in
+++ b/src/php.eselect.in
@@ -99,11 +99,13 @@ find_targets() {
}
find_targets_apache2() {
- local target libdir
+ local libs target libdir
for target in $(find_targets); do
for libdir in $(get_libdirs); do
- [[ -f ${EROOT}${libdir}/$target/apache2/libphp5$(get_libname) ]] && echo $target
- [[ -f ${EROOT}${libdir}/$target/apache2/libphp7$(get_libname) ]] && echo $target
+ libs="${EROOT}${libdir}/$target/apache2/libphp[57]$(get_libname)"
+ for lib in $libs; do
+ [[ -f "${lib}" ]] && echo $target
+ done
done
done | sort -u
}
@@ -136,42 +138,46 @@ find_targets_cgi() {
}
get_active_cli() {
+ # See get_active_apache2() for an explanation of the sed call.
local target=$(canonicalise "${EROOT}"/usr/bin/php)
- if [[ -a "${target}" ]] ; then
- echo "${target}" | \
- @SED@ -ne "s:.*/usr/.*/\(php[0-9]\.[0-9][0-9]*\)/bin/php:\1:p"
- fi
+ local ver="s:.*/usr/.*/\(php[0-9]\.[0-9][0-9]*\)/bin/php:\1:p"
+ [[ -a "${target}" ]] && echo "${target}" | @SED@ -ne "${ver}"
}
get_active_cgi() {
+ # See get_active_apache2() for an explanation of the sed call.
local target=$(canonicalise "${EROOT}"/usr/bin/php-cgi)
- if [[ -a "${target}" ]] ; then
- echo "${target}" | \
- @SED@ -ne "s:.*/usr/.*/\(php[0-9]\.[0-9][0-9]*\)/bin/php-cgi:\1:p"
- fi
+ local ver="s:.*/usr/.*/\(php[0-9]\.[0-9][0-9]*\)/bin/php-cgi:\1:p"
+ [[ -a "${target}" ]] && echo "${target}" | @SED@ -ne "${ver}"
}
get_active_fpm() {
+ # See get_active_apache2() for an explanation of the sed call.
local target=$(canonicalise "${EROOT}"/usr/bin/php-fpm)
- if [[ -a "${target}" ]] ; then
- echo "${target}" | \
- @SED@ -ne "s:.*/usr/.*/\(php[0-9]\.[0-9][0-9]*\)/bin/php-fpm:\1:p"
- fi
+ local ver="s:.*/usr/.*/\(php[0-9]\.[0-9][0-9]*\)/bin/php-fpm:\1:p"
+ [[ -a "${target}" ]] && echo "${target}" | @SED@ -ne "${ver}"
}
+
get_active_apache2() {
- local target
- if [[ -L "${EROOT}"$(get_active_libdir)/apache2/modules/libphp5$(get_libname) ]] ; then
- target=$(canonicalise "${EROOT}"$(get_active_libdir)/apache2/modules/libphp5$(get_libname))
- if [[ -a "${target}" ]] ; then
- echo "${target}" | @SED@ -ne "s:.*/usr/.*/\(php[0-9]\.[0-9]\)/apache2/libphp5$(get_libname):\1:p"
- fi
- elif [[ -L "${EROOT}"$(get_active_libdir)/apache2/modules/libphp7$(get_libname) ]] ; then
- target=$(canonicalise "${EROOT}"$(get_active_libdir)/apache2/modules/libphp7$(get_libname))
- if [[ -a "${target}" ]] ; then
- echo "${target}" | @SED@ -ne "s:.*/usr/.*/\(php[0-9]\.[0-9]\)/apache2/libphp7$(get_libname):\1:p"
+ local libs target ver
+ libs="${EROOT}$(get_active_libdir)/apache2/modules/libphp[57]$(get_libname)"
+
+ # This sed expression finds the "display name" of the PHP version
+ # corresponding to a copy of libphp. For example, it parses the
+ # string "php5.6" out of "/usr/lib64/php5.6/apache2/libphp5.so".
+ ver="s:.*/usr/.*/\(php[0-9]\.[0-9]\)/apache2/libphp[57]$(get_libname):\1:p"
+ for lib in $libs; do
+ if [[ -L "${lib}" ]] ; then
+ target=$(canonicalise "${lib}")
+ if [[ -a "${target}" ]] ; then
+ echo "${target}" | @SED@ -ne "${ver}"
+ # Short-circuit here because we should never have more
+ # than one active version.
+ return
+ fi
fi
- fi
+ done
}
resolv_target() {