1 |
commit: 20bd3ef735c06af203f826e0a0b9c5603e00af8c |
2 |
Author: Michael Orlitzky <mjo <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Dec 19 22:29:41 2015 +0000 |
4 |
Commit: Michael Orlitzky <mjo <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Dec 19 22:29:41 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/eselect-php.git/commit/?id=20bd3ef7 |
7 |
|
8 |
Replace hard-coded SAPI executable link paths with a function call. |
9 |
|
10 |
src/php.eselect.in | 49 ++++++++++++++++++++++++++++++++++++++----------- |
11 |
1 file changed, 38 insertions(+), 11 deletions(-) |
12 |
|
13 |
diff --git a/src/php.eselect.in b/src/php.eselect.in |
14 |
index 10edcbd..4af8650 100644 |
15 |
--- a/src/php.eselect.in |
16 |
+++ b/src/php.eselect.in |
17 |
@@ -8,10 +8,37 @@ MAINTAINER="php-bugs@g.o" |
18 |
|
19 |
MODULES="cli apache2 fpm cgi phpdbg" |
20 |
|
21 |
-cli_link="${EROOT}"/usr/bin/php |
22 |
-fpm_link="${EROOT}"/usr/bin/php-fpm |
23 |
-cgi_link="${EROOT}"/usr/bin/php-cgi |
24 |
-dbg_link="${EROOT}"/usr/bin/phpdbg |
25 |
+ |
26 |
+# Most of the SAPIs (apache2 excluded) provide executables that we |
27 |
+# symlink to a predictable location. Given a SAPI name, we output |
28 |
+# that location. |
29 |
+# |
30 |
+# For example, the "cgi" SAPI has its active symlink at /usr/bin/php-cgi. |
31 |
+# |
32 |
+# Note that the "cli" SAPI actually provides three binaries -- we |
33 |
+# return the path for only one. This is an API wart, not by design. |
34 |
+# |
35 |
+# INPUT: |
36 |
+# |
37 |
+# The name of a SAPI that provides an executable. |
38 |
+# |
39 |
+# OUTPUT: |
40 |
+# |
41 |
+# The path of the symlink for the executable provided by the active |
42 |
+# version of the given SAPI. An error is raised if the given SAPI |
43 |
+# does not provide an executable. |
44 |
+# |
45 |
+sapi_active_bin_link_path() { |
46 |
+ local sapi="${1}" |
47 |
+ local bin_dir="${EROOT}/usr/bin/" |
48 |
+ case "${sapi}" in |
49 |
+ cli) echo "${bin_dir}/php" ;; |
50 |
+ fpm) echo "${bin_dir}/php-fpm" ;; |
51 |
+ cgi) echo "${bin_dir}/php-cgi" ;; |
52 |
+ dbg) echo "${bin_dir}/phpdbg" ;; |
53 |
+ *) die "SAPI ${sapi} does not provide an executable" ;; |
54 |
+ esac |
55 |
+} |
56 |
|
57 |
cleanup_sapis() { |
58 |
local m |
59 |
@@ -149,28 +176,28 @@ find_targets_phpdbg() { |
60 |
|
61 |
get_active_cli() { |
62 |
# See get_active_apache2() for an explanation of the sed call. |
63 |
- local target=$(canonicalise "${cli_link}") |
64 |
+ local target=$(canonicalise "$(sapi_active_bin_link_path cli)") |
65 |
local ver="s:.*/usr/.*/\(php[0-9]\.[0-9][0-9]*\)/bin/php:\1:p" |
66 |
[[ -a "${target}" ]] && echo "${target}" | @SED@ -ne "${ver}" |
67 |
} |
68 |
|
69 |
get_active_cgi() { |
70 |
# See get_active_apache2() for an explanation of the sed call. |
71 |
- local target=$(canonicalise "${cgi_link}") |
72 |
+ local target=$(canonicalise "$(sapi_active_bin_link_path cgi)") |
73 |
local ver="s:.*/usr/.*/\(php[0-9]\.[0-9][0-9]*\)/bin/php-cgi:\1:p" |
74 |
[[ -a "${target}" ]] && echo "${target}" | @SED@ -ne "${ver}" |
75 |
} |
76 |
|
77 |
get_active_fpm() { |
78 |
# See get_active_apache2() for an explanation of the sed call. |
79 |
- local target=$(canonicalise "${fpm_link}") |
80 |
+ local target=$(canonicalise "$(sapi_active_bin_link_path fpm)") |
81 |
local ver="s:.*/usr/.*/\(php[0-9]\.[0-9][0-9]*\)/bin/php-fpm:\1:p" |
82 |
[[ -a "${target}" ]] && echo "${target}" | @SED@ -ne "${ver}" |
83 |
} |
84 |
|
85 |
get_active_phpdbg() { |
86 |
# See get_active_apache2() for an explanation of the sed call. |
87 |
- local target=$(canonicalise "${dbg_link}") |
88 |
+ local target=$(canonicalise "$(sapi_active_bin_link_path dbg)") |
89 |
local ver="s:.*/usr/.*/\(php[0-9]\.[0-9][0-9]*\)/bin/phpdbg:\1:p" |
90 |
[[ -a "${target}" ]] && echo "${target}" | @SED@ -ne "${ver}" |
91 |
} |
92 |
@@ -371,7 +398,7 @@ set_cgi() { |
93 |
t=$(resolv_target cgi $1) |
94 |
[[ -z $t ]] && die -q "invalid target" |
95 |
@LN_S@ --force "../..$(get_active_libdir)/${t}/bin/php-cgi" \ |
96 |
- "${cgi_link}" || \ |
97 |
+ "$(sapi_active_bin_link_path cgi)" || \ |
98 |
die -q "failed to create active php-cgi symlink" |
99 |
} |
100 |
|
101 |
@@ -379,7 +406,7 @@ set_phpdbg() { |
102 |
t=$(resolv_target phpdbg $1) |
103 |
[[ -z $t ]] && die -q "invalid target" |
104 |
@LN_S@ --force "../..$(get_active_libdir)/${t}/bin/phpdbg" \ |
105 |
- "${dbg_link}" || \ |
106 |
+ "$(sapi_active_bin_link_path dbg)" || \ |
107 |
die -q "failed to create active phpdbg symlink" |
108 |
} |
109 |
|
110 |
@@ -387,7 +414,7 @@ set_fpm() { |
111 |
local t=$(resolv_target fpm $1) |
112 |
[[ -z $t ]] && die -q "invalid target" |
113 |
@LN_S@ --force "../..$(get_active_libdir)/${t}/bin/php-fpm" \ |
114 |
- "${fpm_link}" || \ |
115 |
+ "$(sapi_active_bin_link_path fpm)" || \ |
116 |
die -q "failed to create symlink for the php-fpm binary" |
117 |
echo "Please restart php-fpm for the changes to take effect." |
118 |
} |