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: Fri, 11 Dec 2015 00:40:44
Message-Id: 1449793472.c5c96ff3aa9777818de6185045c41426214e3493.mjo@gentoo
1 commit: c5c96ff3aa9777818de6185045c41426214e3493
2 Author: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
3 AuthorDate: Fri Dec 11 00:24:32 2015 +0000
4 Commit: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
5 CommitDate: Fri Dec 11 00:24:32 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/eselect-php.git/commit/?id=c5c96ff3
7
8 Write an apache configuration file to /var/lib/eselect-php/mod_php.conf.
9
10 With the mod_php.so symlinking done, we realize a new problem: each
11 apache module has its "module name" hardcoded into the binary. For
12 example, in mod_php7.c, we find,
13
14 AP_MODULE_DECLARE_DATA module php7_module
15
16 and likewise with php5_module in the 5.x series of PHP. This means
17 that we can't load both of these modules with one LoadModule statement
18 regardless of its filename -- we need to know the module name too.
19
20 This commit adds a function to write out an apache config file for the
21 current active module. The main apache config file should Include this
22 file, which will be updated whenever an apache2 target is set.
23
24 src/php.eselect.in | 39 ++++++++++++++++++++++++++++++++++++---
25 1 file changed, 36 insertions(+), 3 deletions(-)
26
27 diff --git a/src/php.eselect.in b/src/php.eselect.in
28 index ea8676f..aa8ad68 100644
29 --- a/src/php.eselect.in
30 +++ b/src/php.eselect.in
31 @@ -208,6 +208,37 @@ get_active_apache2() {
32 fi
33 }
34
35 +# Write an apache configuration file to load the active version of
36 +# mod_php. The 5.x and 7.x series (at least...) have different module
37 +# names, and so require a different apache configuration when
38 +# switching between the two.
39 +#
40 +# INPUT:
41 +#
42 +# The name of the target (php5.6, php7.0) for which to write the
43 +# configuration file.
44 +#
45 +# OUTPUT:
46 +#
47 +# None.
48 +#
49 +write_mod_php_conf() {
50 + local target="${1}"
51 + local conf_dir="${EROOT}"/var/lib/eselect-php
52 + local conf_path="${conf_dir}/mod_php.conf"
53 +
54 + mkdir -p "${conf_dir}" || die "failed to create ${conf_dir}"
55 +
56 + # Parse the major version (for example "5" or "7") out of the
57 + # target name.
58 + local major="${target:3:1}"
59 + cat <<-EOF > "${conf_path}" || die "failed to write mod_php.conf"
60 + <IfModule !php${major}_module>
61 + LoadModule php${major}_module modules/mod_php.so
62 + </IfModule>
63 + EOF
64 +}
65 +
66 resolv_target() {
67 local targets=( $(find_targets_$1) )
68 if is_number $2; then
69 @@ -279,18 +310,20 @@ list_fpm() {
70 }
71
72 set_apache2() {
73 - local active_symlink libdir t=$(resolv_target apache2 $1)
74 + local active_symlink libdir target=$(resolv_target apache2 $1)
75 active_symlink="$(get_apache2_active_symlink_path)"
76
77 - [[ -z $t ]] && die -q "invalid target"
78 + [[ -z $target ]] && die -q "invalid target"
79 for libdir in $(get_libdirs); do
80 rm --force "${active_symlink}" || \
81 die "failed to remove active module symlink"
82
83 - @LN_S@ --force "../../${t}/apache2/libphp${t:3:1}.so" \
84 + @LN_S@ --force "../../${target}/apache2/libphp${target:3:1}.so" \
85 "${active_symlink}" || \
86 die -q "failed to create active mod_php symlink"
87 done
88 +
89 + write_mod_php_conf "${target}"
90 echo "Please restart apache for the changes to take effect."
91 }