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, 22 Jan 2016 19:14:45 +0000 (UTC)	[thread overview]
Message-ID: <1453488899.56261aef608438c77df89aa5782cd9285d5f9d2f.mjo@gentoo> (raw)

commit:     56261aef608438c77df89aa5782cd9285d5f9d2f
Author:     Michael Orlitzky <mjo <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 22 18:54:59 2016 +0000
Commit:     Michael Orlitzky <mjo <AT> gentoo <DOT> org>
CommitDate: Fri Jan 22 18:54:59 2016 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-php.git/commit/?id=56261aef

Document and fix the update functionality.

The update_sapi() function was not working due to a call to set_$sapi
that was never caught. Some of the logic in both do_update() and
update_sapi() was clarified, and the update_sapi() function was
documented. The "update" action and "cleanup" (which uses it) now work
as expected.

 src/php.eselect.in.in | 46 +++++++++++++++++++++++++++++++++++-----------
 1 file changed, 35 insertions(+), 11 deletions(-)

diff --git a/src/php.eselect.in.in b/src/php.eselect.in.in
index a9c6efd..4e5e4b7 100644
--- a/src/php.eselect.in.in
+++ b/src/php.eselect.in.in
@@ -211,13 +211,32 @@ cleanup_sapi() {
 	done
 }
 
+
+# Update the given SAPI to the latest valid target.
+#
+# The "latest" target is really just the last available one in the
+# list for this SAPI.
+#
+# INPUT:
+#
+# The name of a SAPI.
+#
+# OUTPUT:
+#
+# An error code "1" is returned if there are no valid targets for the
+# given SAPI. Otherwise, we return whatever comes back from set_sapi()
+#
 update_sapi() {
 	local sapi="${1}"
-	local target=$(find_sapi_targets "${sapi}" | tail -n 1)
-	local current=$(get_sapi_active_target "${sapi}")
-	[[ -z $target ]] && return 1
-	[[ $current = $target ]] && return 1
-	set_$sapi $target
+	local latest_target=$(find_sapi_targets "${sapi}" | tail -n 1)
+
+	# No valid targets?
+	[[ -z "${latest_target}" ]] && return 1
+
+	# Proceed even if the current target is the latest one. This can
+	# fix issues where, for example, the "phpize" symlink is broken
+	# but "php" is fine and points to the latest target.
+	set_sapi "${sapi}" "${latest_target}"
 }
 
 
@@ -551,7 +570,7 @@ describe_update() {
 }
 
 describe_update_parameters() {
-	echo "<module> [ifunset]"
+	echo "<module> [--if-unset]"
 }
 
 describe_update_options() {
@@ -561,13 +580,18 @@ describe_update_options() {
 
 do_update() {
 	local sapi="${1}"
+	local ifunset="${2}"
+
+	# Input sanity check.
 	check_module "${sapi}"
-	[[ -z ${2} || ( -z ${3} && ( ${2} == ifunset || ${2} == '--if-unset' ) ) ]] || \
-		die -q "Usage error"
 
-	if [[ (${2} == ifunset || ${2} == '--if-unset') && -n $(get_sapi_active_target "${sapi}") ]];
-	then
-		return
+	# Older versions listed the flag as "ifunset" insted of "--if-unset".
+	if [[ "${ifunset}" == "ifunset" || "${ifunset}" == "--if-unset" ]] ; then
+		if [[ -n $(get_sapi_active_target "${sapi}") ]] ; then
+			# There's already an active target for this SAPI, and the
+			# user asked us to leave it alone. So we leave it alone.
+			return
+		fi
 	fi
 
 	update_sapi "${sapi}" || echo "Nothing to update"


             reply	other threads:[~2016-01-22 19:14 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-22 19:14 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  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
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=1453488899.56261aef608438c77df89aa5782cd9285d5f9d2f.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