summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Orlitzky <mjo@gentoo.org>2020-03-01 07:53:47 -0500
committerMichael Orlitzky <mjo@gentoo.org>2020-03-01 07:59:07 -0500
commitd5ad69d12994e69882830faae26ba565d8980a25 (patch)
treed6a14ea53478f8c746c7db305950799a9e31b06a
parentsrc/php.eselect.in.in: add support for the "phar" executable. (diff)
downloadeselect-php-d5ad69d12994e69882830faae26ba565d8980a25.tar.gz
eselect-php-d5ad69d12994e69882830faae26ba565d8980a25.tar.bz2
eselect-php-d5ad69d12994e69882830faae26ba565d8980a25.zip
src/php.eselect.in.in: only create links to targets that exist.HEADmaster
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 <mjo@gentoo.org>
-rw-r--r--src/php.eselect.in.in23
1 files 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