summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Orlitzky <mjo@gentoo.org>2015-12-19 17:47:50 -0500
committerMichael Orlitzky <mjo@gentoo.org>2015-12-19 17:47:50 -0500
commit6b913fd7a6a7c34ca6411f5117393ab5ded0c4f9 (patch)
treeaefc0b00074bd16380e602de7a4831cb21c7d720
parentFactor out the target major version number parsing into a function. (diff)
downloadeselect-php-6b913fd7a6a7c34ca6411f5117393ab5ded0c4f9.tar.gz
eselect-php-6b913fd7a6a7c34ca6411f5117393ab5ded0c4f9.tar.bz2
eselect-php-6b913fd7a6a7c34ca6411f5117393ab5ded0c4f9.zip
Generalize sapi_active_bin_link_path() to sapi_active_link_path().
Generalize the sapi_active_bin_link_path() to work with the "apache2" SAPI, too. Basically we just return the path of the mod_php symlink for that SAPI even though it's not an executable. After doing so, it makes sense to remove "bin" from the function name. The sapi_active_link_path() function, called with "apache2" as its argument, now replaces the get_apache2_active_symlink_path() function.
-rw-r--r--src/php.eselect.in64
1 files changed, 22 insertions, 42 deletions
diff --git a/src/php.eselect.in b/src/php.eselect.in
index 0eb4ae4..6c1f803 100644
--- a/src/php.eselect.in
+++ b/src/php.eselect.in
@@ -9,34 +9,33 @@ MAINTAINER="php-bugs@gentoo.org"
MODULES="cli apache2 fpm cgi phpdbg"
-# Most of the SAPIs (apache2 excluded) provide executables that we
-# symlink to a predictable location. Given a SAPI name, we output
-# that location.
+# Each SAPI provides at least one "active" link in a predictable
+# location. For example, the "cgi" SAPI has its active symlink at
+# /usr/bin/php-cgi. Given a SAPI name we return the path to that link.
#
-# For example, the "cgi" SAPI has its active symlink at /usr/bin/php-cgi.
-#
-# Note that the "cli" SAPI actually provides three binaries -- we
+# Note that the "cli" SAPI actually provides three executables -- we
# return the path for only one. This is an API wart, not by design.
#
# INPUT:
#
-# The name of a SAPI that provides an executable.
+# The name of a SAPI.
#
# OUTPUT:
#
-# The path of the symlink for the executable provided by the active
-# version of the given SAPI. An error is raised if the given SAPI
-# does not provide an executable.
+# The path of the main symlink provided by the active version of the
+# given SAPI. An error is raised if the given SAPI is not valid.
#
-sapi_active_bin_link_path() {
+sapi_active_link_path() {
local sapi="${1}"
local bin_dir="${EROOT}/usr/bin/"
case "${sapi}" in
- cli) echo "${bin_dir}/php" ;;
+ apache2)
+ echo "${EROOT}$(get_active_libdir)/apache2/modules/mod_php.so" ;;
+ cli) echo "${bin_dir}/php" ;;
fpm) echo "${bin_dir}/php-fpm" ;;
cgi) echo "${bin_dir}/php-cgi" ;;
- dbg) echo "${bin_dir}/phpdbg" ;;
- *) die "SAPI ${sapi} does not provide an executable" ;;
+ dbg) echo "${bin_dir}/phpdbg" ;;
+ *) die "invalid SAPI name: ${sapi}" ;;
esac
}
@@ -198,51 +197,32 @@ find_targets_phpdbg() {
get_active_cli() {
# See get_active_apache2() for an explanation of the sed call.
- local target=$(canonicalise "$(sapi_active_bin_link_path cli)")
+ local target=$(canonicalise "$(sapi_active_link_path cli)")
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 "$(sapi_active_bin_link_path cgi)")
+ local target=$(canonicalise "$(sapi_active_link_path cgi)")
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 "$(sapi_active_bin_link_path fpm)")
+ local target=$(canonicalise "$(sapi_active_link_path fpm)")
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_phpdbg() {
# See get_active_apache2() for an explanation of the sed call.
- local target=$(canonicalise "$(sapi_active_bin_link_path dbg)")
+ local target=$(canonicalise "$(sapi_active_link_path dbg)")
local ver="s:.*/usr/.*/\(php[0-9]\.[0-9][0-9]*\)/bin/phpdbg:\1:p"
[[ -a "${target}" ]] && echo "${target}" | @SED@ -ne "${ver}"
}
-# The path to the active version of the apache2 module, which should
-# be a symlink. This is the path used by our apache configuration to
-# load the PHP module. The path is unversioned (that is, it has no "5"
-# or "7" in it) so that the apache configuration does not need to
-# change after the user eselects a different version.
-#
-# INPUT:
-#
-# None.
-#
-# OUTPUT:
-#
-# The path to our mod_php.so symlink, which should (but is not
-# guaranteed to) point to a real apache DSO.
-#
-get_apache2_active_symlink_path() {
- echo "${EROOT}$(get_active_libdir)/apache2/modules/mod_php.so"
-}
-
# Find the active (selected) version of the apache2 module. Used to
# decorate the output of the `eselect php list apache2` command.
#
@@ -259,7 +239,7 @@ get_active_apache2() {
local active_symlink target ver
# The symlink to our active module.
- active_symlink="$(get_apache2_active_symlink_path)"
+ active_symlink="$(sapi_active_link_path apache2)"
# This sed expression finds the "display name" of the PHP version
# corresponding to a copy of libphp. For example, it parses the
@@ -388,7 +368,7 @@ list_phpdbg() {
set_apache2() {
local active_symlink libdir major target=$(resolv_target apache2 $1)
- active_symlink="$(get_apache2_active_symlink_path)"
+ active_symlink="$(sapi_active_link_path apache2)"
major=$(parse_target_major_version "${target}")
[[ -z $target ]] && die -q "invalid target"
@@ -420,7 +400,7 @@ set_cgi() {
t=$(resolv_target cgi $1)
[[ -z $t ]] && die -q "invalid target"
@LN_S@ --force "../..$(get_active_libdir)/${t}/bin/php-cgi" \
- "$(sapi_active_bin_link_path cgi)" || \
+ "$(sapi_active_link_path cgi)" || \
die -q "failed to create active php-cgi symlink"
}
@@ -428,7 +408,7 @@ set_phpdbg() {
t=$(resolv_target phpdbg $1)
[[ -z $t ]] && die -q "invalid target"
@LN_S@ --force "../..$(get_active_libdir)/${t}/bin/phpdbg" \
- "$(sapi_active_bin_link_path dbg)" || \
+ "$(sapi_active_link_path dbg)" || \
die -q "failed to create active phpdbg symlink"
}
@@ -436,7 +416,7 @@ set_fpm() {
local t=$(resolv_target fpm $1)
[[ -z $t ]] && die -q "invalid target"
@LN_S@ --force "../..$(get_active_libdir)/${t}/bin/php-fpm" \
- "$(sapi_active_bin_link_path fpm)" || \
+ "$(sapi_active_link_path fpm)" || \
die -q "failed to create symlink for the php-fpm binary"
echo "Please restart php-fpm for the changes to take effect."
}