public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michael Orlitzky" <mjo@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/eselect-php:master commit in: src/
Date: Fri,  8 Jan 2016 21:50:23 +0000 (UTC)	[thread overview]
Message-ID: <1452277988.976d0542987023dfe6ba97e3e297c36e7317c1bd.mjo@gentoo> (raw)

commit:     976d0542987023dfe6ba97e3e297c36e7317c1bd
Author:     Michael Orlitzky <mjo <AT> gentoo <DOT> org>
AuthorDate: Fri Jan  8 18:33:08 2016 +0000
Commit:     Michael Orlitzky <mjo <AT> gentoo <DOT> 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."
 }
 


             reply	other threads:[~2016-01-08 21:50 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-08 21:50 Michael Orlitzky [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-12-08  2:24 [gentoo-commits] proj/eselect-php:master commit in: src/ Brian Evans
2020-03-01 12:59 Michael Orlitzky
2020-02-29 22:16 Michael Orlitzky
2020-02-29 22:16 Michael Orlitzky
2020-02-29 22:16 Michael Orlitzky
2020-02-29 22:16 Michael Orlitzky
2020-02-12 22:30 Michael Orlitzky
2018-04-12  2:24 Michael Orlitzky
2016-01-22 20:53 Michael Orlitzky
2016-01-22 19:42 Michael Orlitzky
2016-01-22 19:14 Michael Orlitzky
2016-01-22 19:14 Michael Orlitzky
2016-01-22 19:14 Michael Orlitzky
2016-01-22 19:14 Michael Orlitzky
2016-01-22 19:14 Michael Orlitzky
2016-01-22 19:14 Michael Orlitzky
2016-01-22 19:14 Michael Orlitzky
2016-01-22 19:14 Michael Orlitzky
2016-01-22  3:15 Michael Orlitzky
2016-01-22  3:15 Michael Orlitzky
2016-01-22  3:15 Michael Orlitzky
2016-01-22  3:15 Michael Orlitzky
2016-01-20 14:42 Michael Orlitzky
2016-01-09 17:20 Michael Orlitzky
2016-01-09 17:20 Michael Orlitzky
2016-01-09  2:24 Michael Orlitzky
2016-01-09  2:24 Michael Orlitzky
2016-01-09  2:24 Michael Orlitzky
2016-01-09  2:24 Michael Orlitzky
2016-01-09  2:24 Michael Orlitzky
2016-01-08 21:50 Michael Orlitzky
2016-01-08 21:50 Michael Orlitzky
2016-01-08 21:50 Michael Orlitzky
2016-01-08 21:50 Michael Orlitzky
2016-01-08 21:50 Michael Orlitzky
2016-01-08 21:50 Michael Orlitzky
2016-01-08 21:50 Michael Orlitzky
2016-01-08 21:50 Michael Orlitzky
2016-01-08 21:50 Michael Orlitzky
2015-12-20  0:17 Michael Orlitzky
2015-12-20  0:17 Michael Orlitzky
2015-12-20  0:17 Michael Orlitzky
2015-12-20  0:17 Michael Orlitzky
2015-12-20  0:17 Michael Orlitzky
2015-12-20  0:17 Michael Orlitzky
2015-12-20  0:17 Michael Orlitzky
2015-12-20  0:17 Michael Orlitzky
2015-12-20  0:17 Michael Orlitzky
2015-12-18  2:27 Brian Evans
2015-12-11  0:40 Michael Orlitzky
2015-12-11  0:40 Michael Orlitzky
2015-12-11  0:40 Michael Orlitzky
2015-12-11  0:40 Michael Orlitzky
2015-12-11  0:40 Michael Orlitzky
2015-12-11  0:40 Michael Orlitzky
2015-12-11  0:40 Michael Orlitzky
2015-12-11  0:40 Michael Orlitzky
2015-12-11  0:40 Michael Orlitzky
2015-12-11  0:40 Michael Orlitzky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1452277988.976d0542987023dfe6ba97e3e297c36e7317c1bd.mjo@gentoo \
    --to=mjo@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox