Gentoo Archives: gentoo-commits

From: Michael Orlitzky <mjo@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/eselect-php:master commit in: src/
Date: Sun, 20 Dec 2015 00:17:44
Message-Id: 1450565270.6b913fd7a6a7c34ca6411f5117393ab5ded0c4f9.mjo@gentoo
1 commit: 6b913fd7a6a7c34ca6411f5117393ab5ded0c4f9
2 Author: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
3 AuthorDate: Sat Dec 19 22:47:50 2015 +0000
4 Commit: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
5 CommitDate: Sat Dec 19 22:47:50 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/eselect-php.git/commit/?id=6b913fd7
7
8 Generalize sapi_active_bin_link_path() to sapi_active_link_path().
9
10 Generalize the sapi_active_bin_link_path() to work with the "apache2"
11 SAPI, too. Basically we just return the path of the mod_php symlink
12 for that SAPI even though it's not an executable. After doing so, it
13 makes sense to remove "bin" from the function name.
14
15 The sapi_active_link_path() function, called with "apache2" as its
16 argument, now replaces the get_apache2_active_symlink_path() function.
17
18 src/php.eselect.in | 64 +++++++++++++++++++-----------------------------------
19 1 file changed, 22 insertions(+), 42 deletions(-)
20
21 diff --git a/src/php.eselect.in b/src/php.eselect.in
22 index 0eb4ae4..6c1f803 100644
23 --- a/src/php.eselect.in
24 +++ b/src/php.eselect.in
25 @@ -9,34 +9,33 @@ MAINTAINER="php-bugs@g.o"
26 MODULES="cli apache2 fpm cgi phpdbg"
27
28
29 -# Most of the SAPIs (apache2 excluded) provide executables that we
30 -# symlink to a predictable location. Given a SAPI name, we output
31 -# that location.
32 +# Each SAPI provides at least one "active" link in a predictable
33 +# location. For example, the "cgi" SAPI has its active symlink at
34 +# /usr/bin/php-cgi. Given a SAPI name we return the path to that link.
35 #
36 -# For example, the "cgi" SAPI has its active symlink at /usr/bin/php-cgi.
37 -#
38 -# Note that the "cli" SAPI actually provides three binaries -- we
39 +# Note that the "cli" SAPI actually provides three executables -- we
40 # return the path for only one. This is an API wart, not by design.
41 #
42 # INPUT:
43 #
44 -# The name of a SAPI that provides an executable.
45 +# The name of a SAPI.
46 #
47 # OUTPUT:
48 #
49 -# The path of the symlink for the executable provided by the active
50 -# version of the given SAPI. An error is raised if the given SAPI
51 -# does not provide an executable.
52 +# The path of the main symlink provided by the active version of the
53 +# given SAPI. An error is raised if the given SAPI is not valid.
54 #
55 -sapi_active_bin_link_path() {
56 +sapi_active_link_path() {
57 local sapi="${1}"
58 local bin_dir="${EROOT}/usr/bin/"
59 case "${sapi}" in
60 - cli) echo "${bin_dir}/php" ;;
61 + apache2)
62 + echo "${EROOT}$(get_active_libdir)/apache2/modules/mod_php.so" ;;
63 + cli) echo "${bin_dir}/php" ;;
64 fpm) echo "${bin_dir}/php-fpm" ;;
65 cgi) echo "${bin_dir}/php-cgi" ;;
66 - dbg) echo "${bin_dir}/phpdbg" ;;
67 - *) die "SAPI ${sapi} does not provide an executable" ;;
68 + dbg) echo "${bin_dir}/phpdbg" ;;
69 + *) die "invalid SAPI name: ${sapi}" ;;
70 esac
71 }
72
73 @@ -198,51 +197,32 @@ find_targets_phpdbg() {
74
75 get_active_cli() {
76 # See get_active_apache2() for an explanation of the sed call.
77 - local target=$(canonicalise "$(sapi_active_bin_link_path cli)")
78 + local target=$(canonicalise "$(sapi_active_link_path cli)")
79 local ver="s:.*/usr/.*/\(php[0-9]\.[0-9][0-9]*\)/bin/php:\1:p"
80 [[ -a "${target}" ]] && echo "${target}" | @SED@ -ne "${ver}"
81 }
82
83 get_active_cgi() {
84 # See get_active_apache2() for an explanation of the sed call.
85 - local target=$(canonicalise "$(sapi_active_bin_link_path cgi)")
86 + local target=$(canonicalise "$(sapi_active_link_path cgi)")
87 local ver="s:.*/usr/.*/\(php[0-9]\.[0-9][0-9]*\)/bin/php-cgi:\1:p"
88 [[ -a "${target}" ]] && echo "${target}" | @SED@ -ne "${ver}"
89 }
90
91 get_active_fpm() {
92 # See get_active_apache2() for an explanation of the sed call.
93 - local target=$(canonicalise "$(sapi_active_bin_link_path fpm)")
94 + local target=$(canonicalise "$(sapi_active_link_path fpm)")
95 local ver="s:.*/usr/.*/\(php[0-9]\.[0-9][0-9]*\)/bin/php-fpm:\1:p"
96 [[ -a "${target}" ]] && echo "${target}" | @SED@ -ne "${ver}"
97 }
98
99 get_active_phpdbg() {
100 # See get_active_apache2() for an explanation of the sed call.
101 - local target=$(canonicalise "$(sapi_active_bin_link_path dbg)")
102 + local target=$(canonicalise "$(sapi_active_link_path dbg)")
103 local ver="s:.*/usr/.*/\(php[0-9]\.[0-9][0-9]*\)/bin/phpdbg:\1:p"
104 [[ -a "${target}" ]] && echo "${target}" | @SED@ -ne "${ver}"
105 }
106
107 -# The path to the active version of the apache2 module, which should
108 -# be a symlink. This is the path used by our apache configuration to
109 -# load the PHP module. The path is unversioned (that is, it has no "5"
110 -# or "7" in it) so that the apache configuration does not need to
111 -# change after the user eselects a different version.
112 -#
113 -# INPUT:
114 -#
115 -# None.
116 -#
117 -# OUTPUT:
118 -#
119 -# The path to our mod_php.so symlink, which should (but is not
120 -# guaranteed to) point to a real apache DSO.
121 -#
122 -get_apache2_active_symlink_path() {
123 - echo "${EROOT}$(get_active_libdir)/apache2/modules/mod_php.so"
124 -}
125 -
126 # Find the active (selected) version of the apache2 module. Used to
127 # decorate the output of the `eselect php list apache2` command.
128 #
129 @@ -259,7 +239,7 @@ get_active_apache2() {
130 local active_symlink target ver
131
132 # The symlink to our active module.
133 - active_symlink="$(get_apache2_active_symlink_path)"
134 + active_symlink="$(sapi_active_link_path apache2)"
135
136 # This sed expression finds the "display name" of the PHP version
137 # corresponding to a copy of libphp. For example, it parses the
138 @@ -388,7 +368,7 @@ list_phpdbg() {
139
140 set_apache2() {
141 local active_symlink libdir major target=$(resolv_target apache2 $1)
142 - active_symlink="$(get_apache2_active_symlink_path)"
143 + active_symlink="$(sapi_active_link_path apache2)"
144 major=$(parse_target_major_version "${target}")
145
146 [[ -z $target ]] && die -q "invalid target"
147 @@ -420,7 +400,7 @@ set_cgi() {
148 t=$(resolv_target cgi $1)
149 [[ -z $t ]] && die -q "invalid target"
150 @LN_S@ --force "../..$(get_active_libdir)/${t}/bin/php-cgi" \
151 - "$(sapi_active_bin_link_path cgi)" || \
152 + "$(sapi_active_link_path cgi)" || \
153 die -q "failed to create active php-cgi symlink"
154 }
155
156 @@ -428,7 +408,7 @@ set_phpdbg() {
157 t=$(resolv_target phpdbg $1)
158 [[ -z $t ]] && die -q "invalid target"
159 @LN_S@ --force "../..$(get_active_libdir)/${t}/bin/phpdbg" \
160 - "$(sapi_active_bin_link_path dbg)" || \
161 + "$(sapi_active_link_path dbg)" || \
162 die -q "failed to create active phpdbg symlink"
163 }
164
165 @@ -436,7 +416,7 @@ set_fpm() {
166 local t=$(resolv_target fpm $1)
167 [[ -z $t ]] && die -q "invalid target"
168 @LN_S@ --force "../..$(get_active_libdir)/${t}/bin/php-fpm" \
169 - "$(sapi_active_bin_link_path fpm)" || \
170 + "$(sapi_active_link_path fpm)" || \
171 die -q "failed to create symlink for the php-fpm binary"
172 echo "Please restart php-fpm for the changes to take effect."
173 }