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: Sat, 29 Feb 2020 22:16:24
Message-Id: 1583013628.eccdef0c3d501060838c803ffa81ed79ca614dc0.mjo@gentoo
1 commit: eccdef0c3d501060838c803ffa81ed79ca614dc0
2 Author: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
3 AuthorDate: Sat Feb 29 21:53:38 2020 +0000
4 Commit: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
5 CommitDate: Sat Feb 29 22:00:28 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/eselect-php.git/commit/?id=eccdef0c
7
8 src/php.eselect.in.in: create symlinks relatively.
9
10 As part of our $ROOT support, we need symlinks within $ROOT to point
11 to stuff within $ROOT. The problem with that is that, if we create
12 those symlinks with absolute paths, then you can't later chroot() into
13 $ROOT and use them, because they'll point to the wrong place -- an
14 absolute path that was only correct before you chrooted.
15
16 Using relative symlinks seems to fix the problem, and shouldn't hurt
17 anything in the common case where ROOT is unset or contains only a
18 trailing slash.
19
20 Thanks are due to Stefan Langenmaier for reporting the problem and
21 helping us test the solution.
22
23 Bug: https://bugs.gentoo.org/709422
24 Signed-off-by: Michael Orlitzky <mjo <AT> gentoo.org>
25
26 src/php.eselect.in.in | 23 ++++++++++-------------
27 1 file changed, 10 insertions(+), 13 deletions(-)
28
29 diff --git a/src/php.eselect.in.in b/src/php.eselect.in.in
30 index 12ef1e1..f78bf3d 100644
31 --- a/src/php.eselect.in.in
32 +++ b/src/php.eselect.in.in
33 @@ -85,7 +85,7 @@ sapi_active_link_target_dir() {
34 local sapi="${1}"
35 local target="${2}"
36
37 - local link_target_dir="@LIBDIR@/${target}/bin"
38 + local link_target_dir="${ROOT%/}@LIBDIR@/${target}/bin"
39 if [[ "${sapi}" == "apache2" ]] ; then
40 link_target_dir+="/../apache2"
41 fi
42 @@ -459,9 +459,16 @@ set_sapi() {
43 for link_name in $(sapi_active_link_names "${sapi}"); do
44 local link_target=$(sapi_link_name_target "${sapi}" "${target_name}" "${link_name}")
45
46 + # We need these links to be relative: when setting a target
47 + # with ROOT nonempty, the symlink needs to point within
48 + # ROOT. But if you later chroot() into ROOT, that link will
49 + # point... nowhere, most likely. We need it to still point
50 + # at the right target in that case!
51 + local relative_target=$(relative_name \
52 + "${link_tgt_dir}/${link_target}" \
53 + "${link_dir}" )
54 # Use the short "-f" option for POSIX compatibility.
55 - @LN_S@ -f "${link_tgt_dir}/${link_target}" \
56 - "${link_dir}/${link_name}" || \
57 + @LN_S@ -f "${relative_target}" "${link_dir}/${link_name}" || \
58 die -q "failed to create active ${link_name} symlink"
59 done
60
61 @@ -518,11 +525,6 @@ describe_list_options() {
62 }
63
64 do_list() {
65 - if [ "${ROOT%/}" != "" ] ; then
66 - local msg
67 - write_warning_msg "ROOT only supported in setting the configuration"
68 - echo
69 - fi
70 local sapi="${1}"
71 check_module "${sapi}"
72 list_sapi "${sapi}"
73 @@ -543,11 +545,6 @@ describe_show_options() {
74 }
75
76 do_show() {
77 - if [ "${ROOT%/}" != "" ] ; then
78 - local msg
79 - write_warning_msg "ROOT only supported in setting the configuration"
80 - echo
81 - fi
82 local sapi="${1}"
83 check_module "${sapi}"
84 get_sapi_active_target "${sapi}"