1 |
commit: d5ad69d12994e69882830faae26ba565d8980a25 |
2 |
Author: Michael Orlitzky <mjo <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Mar 1 12:53:47 2020 +0000 |
4 |
Commit: Michael Orlitzky <mjo <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Mar 1 12:59:07 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/eselect-php.git/commit/?id=d5ad69d1 |
7 |
|
8 |
src/php.eselect.in.in: only create links to targets that exist. |
9 |
|
10 |
To avoid replacing a working /usr/bin/phar with a broken symlink, |
11 |
let's check to make sure that the targets of our symlinks exist before |
12 |
creating them. This can leave "phar" pointing to an unexpected version |
13 |
of that executable, but that's better than nothing if some working |
14 |
version is installed. |
15 |
|
16 |
Signed-off-by: Michael Orlitzky <mjo <AT> gentoo.org> |
17 |
|
18 |
src/php.eselect.in.in | 23 ++++++++++++++++------- |
19 |
1 file changed, 16 insertions(+), 7 deletions(-) |
20 |
|
21 |
diff --git a/src/php.eselect.in.in b/src/php.eselect.in.in |
22 |
index 2a7e5a8..d243c64 100644 |
23 |
--- a/src/php.eselect.in.in |
24 |
+++ b/src/php.eselect.in.in |
25 |
@@ -180,10 +180,9 @@ parse_target_major_version() { |
26 |
# working. |
27 |
# |
28 |
# There is one potential caveat to that approach, for SAPIs with more |
29 |
-# than one active symlink. What if "phpize" is broken but "php" is OK? |
30 |
-# (Forget for the moment how that might happen...). Do we want to |
31 |
-# update() the entire SAPI because one of the symlinks is dead? |
32 |
-# Answer: I guess. |
33 |
+# than one active symlink. What if "phar" is broken (after a rebuild) |
34 |
+# but "php" is OK? Do we want to update() the entire SAPI because one |
35 |
+# of the symlinks is dead? Answer: I guess. |
36 |
# |
37 |
# INPUT: |
38 |
# |
39 |
@@ -467,9 +466,19 @@ set_sapi() { |
40 |
local relative_target=$(relative_name \ |
41 |
"${link_tgt_dir}/${link_target}" \ |
42 |
"${link_dir}" ) |
43 |
- # Use the short "-f" option for POSIX compatibility. |
44 |
- @LN_S@ -f "${relative_target}" "${link_dir}/${link_name}" || \ |
45 |
- die -q "failed to create active ${link_name} symlink" |
46 |
+ |
47 |
+ # Since the phar extension is optional, we check here to |
48 |
+ # ensure that the target of our symlink exists before we |
49 |
+ # create it. Otherwise, we could wind up with a /usr/bin/phar |
50 |
+ # symlink that points nowhere. This might leave /usr/bin/phar |
51 |
+ # pointing to a different version than you'd expect (wherever |
52 |
+ # it pointed before you just tried to change it), but I guess |
53 |
+ # leaving some working version is not a terrible thing to do. |
54 |
+ if [[ -e "${link_tgt_dir}/${link_target}" ]]; then |
55 |
+ # Use the short "-f" option for POSIX compatibility. |
56 |
+ @LN_S@ -f "${relative_target}" "${link_dir}/${link_name}" || \ |
57 |
+ die -q "failed to create active ${link_name} symlink" |
58 |
+ fi |
59 |
done |
60 |
|
61 |
# The call to write_mod_php_conf() in particular needs to take |