summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Orlitzky <mjo@gentoo.org>2016-01-08 13:51:21 -0500
committerMichael Orlitzky <mjo@gentoo.org>2016-01-08 13:51:21 -0500
commitcc0b2730e408da529275b6688e9a381ae4b905dc (patch)
treebb2e9a8d31c43cfd956b5f2d19f08b4dc9671e58
parentRefactor set_apache2() to use set_sapi(). (diff)
downloadeselect-php-cc0b2730.tar.gz
eselect-php-cc0b2730.tar.bz2
eselect-php-cc0b2730.zip
Add sapi_link_name_target() to clean up set_sapi().
There was a special case in set_sapi() for apache2's mod_php.so. Now that has been factored out into a new function sapi_link_name_target() which acts more or less like a hash table (dictionary lookup).
-rw-r--r--src/php.eselect.in38
1 files changed, 29 insertions, 9 deletions
diff --git a/src/php.eselect.in b/src/php.eselect.in
index 1288669..7acda64 100644
--- a/src/php.eselect.in
+++ b/src/php.eselect.in
@@ -36,6 +36,34 @@ sapi_active_link_names() {
esac
}
+# The link names obtained from sapi_active_link_names() all need to
+# point somewhere. Usually the target is the same as the link name
+# itself, but not always. This function returns the link-target for a
+# given sapi, sapi-target, and link name.
+#
+# INPUT:
+#
+# The first parameter is a SAPI name. The second parameter is the
+# SAPI-target name (for example, "php7.0"). The third parameter is a
+# link name.
+#
+# OUTPUT:
+#
+# The name of the target (that is, file) for the given link name.
+#
+sapi_link_name_target() {
+ local sapi="${1}"
+ local target_name="${2}"
+ local link_name="${3}"
+
+ # For now, only apache2's mod_php.so gets special treatment.
+ if [[ "${sapi}" == "apache2" && "${link_name}" == "mod_php.so" ]] ; then
+ local major=$(parse_target_major_version "${target_name}")
+ echo "libphp${major}.so"
+ else
+ echo "${link_name}"
+ fi
+}
# Each SAPI provides a few (one or more) "active" links in a
# predictable location. The target directory (where they point) is
@@ -426,15 +454,7 @@ set_sapi() {
local link_dir=$(sapi_active_link_dir "${sapi}")
for link_name in $(sapi_active_link_names "${sapi}"); do
- # Usually the link targets have the same name as the link itself...
- local link_target="${link_name}"
-
- if [[ "${link_name}" == "mod_php.so" ]] ; then
- # ...but apache2 needs special handling since we're not
- # linking from something named mod_php.so.
- local major=$(parse_target_major_version "${target_name}")
- link_target="libphp${major}.so"
- fi
+ local link_target=$(sapi_link_name_target "${sapi}" "${target_name}" "${link_name}")
@LN_S@ --force "${link_tgt_dir}/${link_target}" \
"${link_dir}/${link_name}" || \