diff options
-rw-r--r-- | src/php.eselect.in.in | 23 |
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 |