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 2F4E358973 for ; Fri, 22 Jan 2016 19:14:52 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C4FF021C01A; Fri, 22 Jan 2016 19:14:50 +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 1949421C00C for ; Fri, 22 Jan 2016 19:14:49 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 1691C340A8E for ; Fri, 22 Jan 2016 19:14:49 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 1FB2E106A for ; Fri, 22 Jan 2016 19:14:45 +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: <1453488899.56261aef608438c77df89aa5782cd9285d5f9d2f.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.in X-VCS-Directories: src/ X-VCS-Committer: mjo X-VCS-Committer-Name: Michael Orlitzky X-VCS-Revision: 56261aef608438c77df89aa5782cd9285d5f9d2f X-VCS-Branch: master Date: Fri, 22 Jan 2016 19:14:45 +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: 5eb5fced-c92b-4a0a-a7aa-49ee1763c903 X-Archives-Hash: 141baa60f4db34ef5e493eaa54ccfdb9 commit: 56261aef608438c77df89aa5782cd9285d5f9d2f Author: Michael Orlitzky gentoo org> AuthorDate: Fri Jan 22 18:54:59 2016 +0000 Commit: Michael Orlitzky gentoo 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 " [ifunset]" + echo " [--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"