diff options
author | Michael Orlitzky <mjo@gentoo.org> | 2015-12-19 17:29:41 -0500 |
---|---|---|
committer | Michael Orlitzky <mjo@gentoo.org> | 2015-12-19 17:29:41 -0500 |
commit | 20bd3ef735c06af203f826e0a0b9c5603e00af8c (patch) | |
tree | 78afe7acb66b691899375a4ba0ba313d1448cf2f | |
parent | Add support for the phpdbg SAPI target (diff) | |
download | eselect-php-20bd3ef735c06af203f826e0a0b9c5603e00af8c.tar.gz eselect-php-20bd3ef735c06af203f826e0a0b9c5603e00af8c.tar.bz2 eselect-php-20bd3ef735c06af203f826e0a0b9c5603e00af8c.zip |
Replace hard-coded SAPI executable link paths with a function call.
-rw-r--r-- | src/php.eselect.in | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/src/php.eselect.in b/src/php.eselect.in index 10edcbd..4af8650 100644 --- a/src/php.eselect.in +++ b/src/php.eselect.in @@ -8,10 +8,37 @@ MAINTAINER="php-bugs@gentoo.org" MODULES="cli apache2 fpm cgi phpdbg" -cli_link="${EROOT}"/usr/bin/php -fpm_link="${EROOT}"/usr/bin/php-fpm -cgi_link="${EROOT}"/usr/bin/php-cgi -dbg_link="${EROOT}"/usr/bin/phpdbg + +# Most of the SAPIs (apache2 excluded) provide executables that we +# symlink to a predictable location. Given a SAPI name, we output +# that location. +# +# For example, the "cgi" SAPI has its active symlink at /usr/bin/php-cgi. +# +# Note that the "cli" SAPI actually provides three binaries -- 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. +# +# 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. +# +sapi_active_bin_link_path() { + local sapi="${1}" + local bin_dir="${EROOT}/usr/bin/" + case "${sapi}" in + 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" ;; + esac +} cleanup_sapis() { local m @@ -149,28 +176,28 @@ find_targets_phpdbg() { get_active_cli() { # See get_active_apache2() for an explanation of the sed call. - local target=$(canonicalise "${cli_link}") + local target=$(canonicalise "$(sapi_active_bin_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 "${cgi_link}") + local target=$(canonicalise "$(sapi_active_bin_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 "${fpm_link}") + local target=$(canonicalise "$(sapi_active_bin_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 "${dbg_link}") + local target=$(canonicalise "$(sapi_active_bin_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}" } @@ -371,7 +398,7 @@ set_cgi() { t=$(resolv_target cgi $1) [[ -z $t ]] && die -q "invalid target" @LN_S@ --force "../..$(get_active_libdir)/${t}/bin/php-cgi" \ - "${cgi_link}" || \ + "$(sapi_active_bin_link_path cgi)" || \ die -q "failed to create active php-cgi symlink" } @@ -379,7 +406,7 @@ set_phpdbg() { t=$(resolv_target phpdbg $1) [[ -z $t ]] && die -q "invalid target" @LN_S@ --force "../..$(get_active_libdir)/${t}/bin/phpdbg" \ - "${dbg_link}" || \ + "$(sapi_active_bin_link_path dbg)" || \ die -q "failed to create active phpdbg symlink" } @@ -387,7 +414,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" \ - "${fpm_link}" || \ + "$(sapi_active_bin_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." } |