From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 42D671388BF for ; Fri, 8 Jan 2016 21:50:35 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id ADDEC21C007; Fri, 8 Jan 2016 21:50:27 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id E1DA021C00A for ; Fri, 8 Jan 2016 21:50:26 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0F13434097F for ; Fri, 8 Jan 2016 21:50:26 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 97BBFD0D for ; Fri, 8 Jan 2016 21:50:23 +0000 (UTC) From: "Michael Orlitzky" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michael Orlitzky" Message-ID: <1452277988.976d0542987023dfe6ba97e3e297c36e7317c1bd.mjo@gentoo> Subject: [gentoo-commits] proj/eselect-php:master commit in: src/ X-VCS-Repository: proj/eselect-php X-VCS-Files: src/php.eselect.in X-VCS-Directories: src/ X-VCS-Committer: mjo X-VCS-Committer-Name: Michael Orlitzky X-VCS-Revision: 976d0542987023dfe6ba97e3e297c36e7317c1bd X-VCS-Branch: master Date: Fri, 8 Jan 2016 21:50:23 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: d765ecb4-a5af-4810-9b54-908dcffe075d X-Archives-Hash: 03824f3a46cb71ed3c51e76bafdd7188 commit: 976d0542987023dfe6ba97e3e297c36e7317c1bd Author: Michael Orlitzky gentoo org> AuthorDate: Fri Jan 8 18:33:08 2016 +0000 Commit: Michael Orlitzky gentoo org> CommitDate: Fri Jan 8 18:33:08 2016 +0000 URL: https://gitweb.gentoo.org/proj/eselect-php.git/commit/?id=976d0542 Refactor set_apache2() to use set_sapi(). With a little bit of mangling and a new (trivial) function, the set_sapi() function now does the work of set_apache2(). There is probably a better "big picture" to handle the symlinking, but this works for now and is an improvement. src/php.eselect.in | 69 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 20 deletions(-) diff --git a/src/php.eselect.in b/src/php.eselect.in index 2e9ec8d..1288669 100644 --- a/src/php.eselect.in +++ b/src/php.eselect.in @@ -38,6 +38,38 @@ sapi_active_link_names() { # Each SAPI provides a few (one or more) "active" links in a +# predictable location. The target directory (where they point) is +# fixed for a given SAPI, and this function returns it. +# +# The name "target" is unfortunate, but that's the terminology that +# "ln" uses. The link_name is the name of the link on the filesystem, +# and target is where it points. +# +# INPUT: +# +# The first parameter is the name of a SAPI. The second parameter is +# the name of a target. +# +# OUTPUT: +# +# The directory to which the given SAPI's symlinks point. For example, +# the "cli" sapi has three executable symlinks and all of them point +# to executables in /usr/lib/phpX.Y/bin. +# +sapi_active_link_target_dir() { + local sapi="${1}" + local target="${2}" + + local link_target_dir="${EROOT}$(get_active_libdir)/${target}/bin" + if [[ "${sapi}" == "apache2" ]] ; then + link_target_dir+="/../apache2" + fi + + echo "${link_target_dir}" +} + + +# Each SAPI provides a few (one or more) "active" links in a # predictable location. And fortunately that location is fixed for a # given SAPI. For example, the "cgi" SAPI has its sole active symlink, # /usr/bin/php-cgi, in /usr/bin. Given a SAPI name, we return the @@ -390,34 +422,31 @@ set_sapi() { local target_name=$(resolv_target "${sapi}" "${target}") [[ -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}") + local link_tgt_dir=$(sapi_active_link_target_dir "${sapi}" "${target_name}") + local link_dir=$(sapi_active_link_dir "${sapi}") for link_name in $(sapi_active_link_names "${sapi}"); do - @LN_S@ --force "${link_src_dir}/${link_name}" \ - "${link_dst_dir}/${link_name}" || \ + # 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 + + @LN_S@ --force "${link_tgt_dir}/${link_target}" \ + "${link_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)" - major=$(parse_target_major_version "${target}") - - [[ -z $target ]] && die -q "invalid target" - - for libdir in $(get_libdirs); do - rm --force "${active_symlink}" || \ - die "failed to remove active module symlink" - - @LN_S@ --force "../../${target}/apache2/libphp${major}.so" \ - "${active_symlink}" || \ - die -q "failed to create active mod_php symlink" - done - - write_mod_php_conf "${target}" + local target="${1}" + set_sapi apache2 "${target}" + write_mod_php_conf "$(resolv_target apache2 "${target}")" echo "Please restart apache for the changes to take effect." }