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 8B4FD58973 for ; Fri, 22 Jan 2016 19:15:06 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2051121C007; Fri, 22 Jan 2016 19:14:59 +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 A31DE21C01B for ; Fri, 22 Jan 2016 19:14:58 +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 DEC4A340A84 for ; Fri, 22 Jan 2016 19:14:47 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id F0DFD1017 for ; Fri, 22 Jan 2016 19:14:44 +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: <1453486774.d50f77c79f3a7e2ce129ef69ff4cc662d1b95ad6.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: d50f77c79f3a7e2ce129ef69ff4cc662d1b95ad6 X-VCS-Branch: master Date: Fri, 22 Jan 2016 19:14:44 +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: 774339dd-ad32-4f14-b186-753bed2fe0cd X-Archives-Hash: 52f3d4eef9b512134b5e478c7d651d43 commit: d50f77c79f3a7e2ce129ef69ff4cc662d1b95ad6 Author: Michael Orlitzky gentoo org> AuthorDate: Fri Jan 22 18:19:34 2016 +0000 Commit: Michael Orlitzky gentoo org> CommitDate: Fri Jan 22 18:19:34 2016 +0000 URL: https://gitweb.gentoo.org/proj/eselect-php.git/commit/?id=d50f77c7 Clean up and document the cleanup_sapi() function. src/php.eselect.in.in | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/src/php.eselect.in.in b/src/php.eselect.in.in index 7e52f53..63b9d42 100644 --- a/src/php.eselect.in.in +++ b/src/php.eselect.in.in @@ -173,23 +173,42 @@ parse_target_major_version() { esac } +# Remove dead active symlinks for the given SAPI. +# +# If a symlink for an SAPI is dead, then that SAPI is at least +# partially broken. For example, if the symlink to php-cgi is dead, +# then CGI just isn't going to work -- the SAPI is broken. It +# therefore makes sense to run update() after we find and remove any +# broken links. The update at least has the potential to leave things +# working. +# +# There is one potential caveat to that approach, for SAPIs with more +# than one active symlink. What if "phpize" is broken but "php" is OK? +# (Forget for the moment how that might happen...). Do we want to +# update() the entire SAPI because one of the symlinks is dead? +# Answer: I guess. +# +# INPUT: +# +# The name of the SAPI to clean up. +# +# OUTPUT: +# +# If any symlinks are removed, that fact will be announced. If an +# update occurs, that will be noted as well +# cleanup_sapi() { local sapi="${1}" - local l="${sapi}_link" - local link=${!l} - if [[ -L $link && ! -e $link ]] ; then - echo -n "Broken link for ${sapi}" - if update_sapi $1 ; then - echo ", updated version to $(get_sapi_active_target "${sapi}")" - return - else - rm $link || die "failed to remove ${link}" - - return - fi - fi + local link_dir=$(sapi_active_link_dir "${sapi}") - return 1 + for link_name in $(sapi_active_link_names "${sapi}"); do + local link_path="${link_dir}/${link_name}" + if [[ -L "${link_path}" && ! -e "${link_path}" ]] ; then + rm -f "${link_path}" || die "failed to remove ${link_path}" + echo "Removed broken symlink ${link_path}." + update_sapi "${sapi}" # Try to fix it. + fi + done } update_sapi() {