From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id AE58F138239 for ; Sun, 1 Mar 2020 12:59:31 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C2AA4E0A0B; Sun, 1 Mar 2020 12:59:30 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A81B6E0A0B for ; Sun, 1 Mar 2020 12:59:30 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id AC0BB34F132 for ; Sun, 1 Mar 2020 12:59:29 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id EF08E17 for ; Sun, 1 Mar 2020 12:59:26 +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: <1583067547.d5ad69d12994e69882830faae26ba565d8980a25.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: d5ad69d12994e69882830faae26ba565d8980a25 X-VCS-Branch: master Date: Sun, 1 Mar 2020 12:59:26 +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-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 63cfde1a-49ca-4bd6-b630-d990d8470b53 X-Archives-Hash: c3859a6b0521c5f66d2ce278f2638ce0 commit: d5ad69d12994e69882830faae26ba565d8980a25 Author: Michael Orlitzky gentoo org> AuthorDate: Sun Mar 1 12:53:47 2020 +0000 Commit: Michael Orlitzky gentoo org> CommitDate: Sun Mar 1 12:59:07 2020 +0000 URL: https://gitweb.gentoo.org/proj/eselect-php.git/commit/?id=d5ad69d1 src/php.eselect.in.in: only create links to targets that exist. To avoid replacing a working /usr/bin/phar with a broken symlink, let's check to make sure that the targets of our symlinks exist before creating them. This can leave "phar" pointing to an unexpected version of that executable, but that's better than nothing if some working version is installed. Signed-off-by: Michael Orlitzky gentoo.org> src/php.eselect.in.in | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/php.eselect.in.in b/src/php.eselect.in.in index 2a7e5a8..d243c64 100644 --- a/src/php.eselect.in.in +++ b/src/php.eselect.in.in @@ -180,10 +180,9 @@ parse_target_major_version() { # 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. +# than one active symlink. What if "phar" is broken (after a rebuild) +# but "php" is OK? Do we want to update() the entire SAPI because one +# of the symlinks is dead? Answer: I guess. # # INPUT: # @@ -467,9 +466,19 @@ set_sapi() { local relative_target=$(relative_name \ "${link_tgt_dir}/${link_target}" \ "${link_dir}" ) - # Use the short "-f" option for POSIX compatibility. - @LN_S@ -f "${relative_target}" "${link_dir}/${link_name}" || \ - die -q "failed to create active ${link_name} symlink" + + # Since the phar extension is optional, we check here to + # ensure that the target of our symlink exists before we + # create it. Otherwise, we could wind up with a /usr/bin/phar + # symlink that points nowhere. This might leave /usr/bin/phar + # pointing to a different version than you'd expect (wherever + # it pointed before you just tried to change it), but I guess + # leaving some working version is not a terrible thing to do. + if [[ -e "${link_tgt_dir}/${link_target}" ]]; then + # Use the short "-f" option for POSIX compatibility. + @LN_S@ -f "${relative_target}" "${link_dir}/${link_name}" || \ + die -q "failed to create active ${link_name} symlink" + fi done # The call to write_mod_php_conf() in particular needs to take