From a84247840eb392d2e248a116828d8941d507b033 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 8 Jan 2016 12:31:44 -0500 Subject: Refactor most set_foo() functions to use set_sapi(). The set_sapi() function was accidentally introduced in commit 91160d1 but was not used until now. This commit finishes its implementation, and refactors the "easy" SAPI set_* functions to use set_sapi(). The set_apache2() function still requires more work. --- src/php.eselect.in | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/php.eselect.in b/src/php.eselect.in index aa681f0..97e7940 100644 --- a/src/php.eselect.in +++ b/src/php.eselect.in @@ -373,17 +373,34 @@ list_phpdbg() { } +# Perform the "set" action for the given SAPI. +# +# INPUT: +# +# The first parameter is the SAPI name, and the second parameter is +# the desired target. +# +# OUTPUT: +# +# None. +# set_sapi() { local sapi="${1}" local target="${2}" local target_name=$(resolv_target "${sapi}" "${target}") - [[ -z $t ]] && die -q "invalid target ${target} for SAPI ${sapi}" + [[ -z $target_name ]] && die -q "invalid target ${target} for SAPI ${sapi}" + + local link_src_dir="../..$(get_active_libdir)/${target_name}/bin" + local link_dst_dir=$(sapi_active_link_dir "${sapi}") - @LN_S@ --force "../..$(get_active_libdir)/${t}/bin/php-cgi" \ - "$(sapi_active_link_path cgi)" || \ - die -q "failed to create active php-cgi symlink" + for link_name in $(sapi_active_link_names "${sapi}"); do + @LN_S@ --force "${link_src_dir}/${link_name}" \ + "${link_dst_dir}/${link_name}" || \ + die -q "failed to create active ${link_name} symlink" + done } + set_apache2() { local active_symlink libdir major target=$(resolv_target apache2 $1) active_symlink="$(sapi_active_link_path apache2)" @@ -405,39 +422,22 @@ set_apache2() { } set_cli() { - local file libdir t=$(resolv_target cli $1) - [[ -z $t ]] && die -q "invalid target" - for file in php phpize php-config; do - @LN_S@ --force "../..$(get_active_libdir)/${t}/bin/${file}" \ - "${EROOT}/usr/bin/${file}" || \ - die -q "failed to create active ${file} symlink" - done + set_sapi "cli" "${1}" } 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_link_path cgi)" || \ - die -q "failed to create active php-cgi symlink" + set_sapi "cgi" "${1}" } set_phpdbg() { - t=$(resolv_target dbg $1) - [[ -z $t ]] && die -q "invalid target" - @LN_S@ --force "../..$(get_active_libdir)/${t}/bin/phpdbg" \ - "$(sapi_active_link_path dbg)" || \ - die -q "failed to create active phpdbg symlink" + set_sapi "dbg" "${1}" } 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_link_path fpm)" || \ - die -q "failed to create symlink for the php-fpm binary" + set_sapi "fpm" "${1}" echo "Please restart php-fpm for the changes to take effect." } + ## set action describe_set() { -- cgit v1.2.3-65-gdbad