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: 1450564841.7d9d9e7ef2a642c2f568de59b1af5f20a0c828ab.mjo@gentoo
1 commit: 7d9d9e7ef2a642c2f568de59b1af5f20a0c828ab
2 Author: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
3 AuthorDate: Sat Dec 19 22:40:41 2015 +0000
4 Commit: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
5 CommitDate: Sat Dec 19 22:40:41 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/eselect-php.git/commit/?id=7d9d9e7e
7
8 Factor out the target major version number parsing into a function.
9
10 src/php.eselect.in | 32 +++++++++++++++++++++++++++-----
11 1 file changed, 27 insertions(+), 5 deletions(-)
12
13 diff --git a/src/php.eselect.in b/src/php.eselect.in
14 index 4af8650..0eb4ae4 100644
15 --- a/src/php.eselect.in
16 +++ b/src/php.eselect.in
17 @@ -40,6 +40,28 @@ sapi_active_bin_link_path() {
18 esac
19 }
20
21 +
22 +# Parse and return the major version from a target name. For example,
23 +# the "php5.6" target has a major version of "5".
24 +#
25 +# INPUT:
26 +#
27 +# The name of a valid PHP target, like php5.6 or php7.0.
28 +#
29 +# OUTPUT:
30 +#
31 +# A major version number. An error is raised if the given target is
32 +# not valid.
33 +#
34 +parse_target_major_version() {
35 + local target="${1}"
36 + local major="${target:3:1}"
37 + case "${major}" in
38 + 5|7) echo "${major}" ;;
39 + *) die "invalid PHP target name: ${target}"
40 + esac
41 +}
42 +
43 cleanup_sapis() {
44 local m
45 local link
46 @@ -273,9 +295,7 @@ write_mod_php_conf() {
47
48 @MKDIR_P@ "${conf_dir}" || die "failed to create ${conf_dir}"
49
50 - # Parse the major version (for example "5" or "7") out of the
51 - # target name.
52 - local major="${target:3:1}"
53 + local major=$(parse_target_major_version "${target}")
54 cat <<-EOF > "${conf_path}" || die "failed to write mod_php.conf"
55 <IfModule !php${major}_module>
56 LoadModule php${major}_module modules/mod_php.so
57 @@ -367,15 +387,17 @@ list_phpdbg() {
58 }
59
60 set_apache2() {
61 - local active_symlink libdir target=$(resolv_target apache2 $1)
62 + local active_symlink libdir major target=$(resolv_target apache2 $1)
63 active_symlink="$(get_apache2_active_symlink_path)"
64 + major=$(parse_target_major_version "${target}")
65
66 [[ -z $target ]] && die -q "invalid target"
67 +
68 for libdir in $(get_libdirs); do
69 rm --force "${active_symlink}" || \
70 die "failed to remove active module symlink"
71
72 - @LN_S@ --force "../../${target}/apache2/libphp${target:3:1}.so" \
73 + @LN_S@ --force "../../${target}/apache2/libphp${major}.so" \
74 "${active_symlink}" || \
75 die -q "failed to create active mod_php symlink"
76 done