Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/musl/, sys-libs/musl/files/
Date: Sun, 20 Feb 2022 00:31:40
Message-Id: 1645316986.b02003640228503cb93d5c371bef1f55c555429f.sam@gentoo
1 commit: b02003640228503cb93d5c371bef1f55c555429f
2 Author: Esteve Varela Colominas <esteve.varela <AT> gmail <DOT> com>
3 AuthorDate: Sat Feb 12 15:34:33 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Sun Feb 20 00:29:46 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b0200364
7
8 sys-libs/musl: Support Gentoo prefix
9
10 Added necessary framework to get this libc to run properly under a prefix.
11
12 Closes: https://bugs.gentoo.org/833192
13 Signed-off-by: Esteve Varela Colominas <esteve.varela <AT> gmail.com>
14 Closes: https://github.com/gentoo/gentoo/pull/24169
15 Signed-off-by: Sam James <sam <AT> gentoo.org>
16
17 sys-libs/musl/files/ldconfig.in-r3 | 160 +++++++++++++++++++++
18 .../{musl-9999.ebuild => musl-1.2.2-r8.ebuild} | 44 +++---
19 sys-libs/musl/musl-9999.ebuild | 44 +++---
20 3 files changed, 200 insertions(+), 48 deletions(-)
21
22 diff --git a/sys-libs/musl/files/ldconfig.in-r3 b/sys-libs/musl/files/ldconfig.in-r3
23 new file mode 100644
24 index 000000000000..60f6cc9e1130
25 --- /dev/null
26 +++ b/sys-libs/musl/files/ldconfig.in-r3
27 @@ -0,0 +1,160 @@
28 +#!/bin/bash -e
29 +# Copyright 1999-2022 Gentoo Authors
30 +# Distributed under the terms of the GNU General Public License v2
31 +
32 +ROOT="/"
33 +EPREFIX="@GENTOO_PORTAGE_EPREFIX@"
34 +LDSO_CONF_FILE="/etc/ld.so.conf"
35 +
36 +VERBOSE=0
37 +
38 +UPDATE_LINKS=1
39 +
40 +get_options() {
41 + LDSO_CONF=""
42 + while getopts "vnNXf:C:r:p" opt "$@"; do
43 + case $opt in
44 + v)
45 + echo "ldconfig for musl in Gentoo"
46 + VERBOSE=1
47 + ;;
48 + r)
49 + ROOT=${OPTARG}
50 + ;;
51 + f)
52 + LDSO_CONF=${OPTARG}
53 + ;;
54 + X)
55 + UPDATE_LINKS=0
56 + ;;
57 + \?)
58 + echo "Invalid option: -${opt}" >&2
59 + exit 1
60 + ;;
61 + n|N|C|p)
62 + echo "Unimplemented option: -${opt}" >&2
63 + exit 1
64 + ;;
65 + esac
66 + done
67 + if [[ -z ${LDSO_CONF} ]]; then
68 + LDSO_CONF=${ROOT}${EPREFIX}${LDSO_CONF_FILE}
69 + fi
70 +
71 + if [[ ${UPDATE_LINKS} == 1 ]]; then
72 + echo "Updating links is not implemented."
73 + fi
74 +}
75 +
76 +
77 +repeated() {
78 + local l=${1}
79 + local drs="${@:2}"
80 + for m in ${drs}; do
81 + [[ ${m} == ${l} ]] && return 0
82 + done
83 + return 1
84 +}
85 +
86 +expand() {
87 + # We are assuming the ld.so.conf's 'include' is not recursive
88 + local f line l
89 + local glob="${LDSO_CONF_DIR}/${1}"
90 + local drs="${@:2} "
91 +
92 + for f in ${glob}; do
93 + [[ ! -f ${f} ]] && continue
94 + while read line; do
95 + line=${line%%#*}
96 + line=${line//:/ }
97 + line=${line//,/ }
98 + for l in ${line}; do
99 + # We must add this whether or not the directory exists
100 + repeated ${l} ${drs} && continue
101 + drs+=" ${l} "
102 + done
103 + done < ${f}
104 + done
105 +
106 + echo ${drs}
107 +}
108 +
109 +read_ldso_conf() {
110 + local drs=" "
111 +
112 + while read line; do
113 + # Sanitize the line - see ldconfig(8) for delimiters
114 + # Note: bash read turns tabs into spaces and read already
115 + # delimits on newlines with the default $IFS
116 + line=${line%%#*} # Remove comments
117 + line=${line//:/ } # Change colon delimiter to space
118 + line=${line//,/ } # Change comma delimiter to space
119 +
120 + next=0
121 + for l in ${line}; do
122 + if [[ ${next} == 1 ]]; then
123 + next=0
124 + drs=$(expand ${l} ${drs})
125 + elif [[ ${l} == "include" ]]; then
126 + next=1
127 + else
128 + # glibc's ldconfig silently skips non directories
129 + if [[ -d ${l} ]]; then
130 + repeated ${l} ${drs} && continue
131 + drs+=" ${l} "
132 + fi
133 + fi
134 + done
135 + done < ${1}
136 +
137 + echo ${drs}
138 +}
139 +
140 +sanitize() {
141 + local drs=$@
142 +
143 + repeated "${EPREFIX}/lib" ${drs} || drs="${EPREFIX}/lib ${drs}"
144 + repeated "${EPREFIX}/usr/lib" ${drs} || drs="${EPREFIX}/usr/lib ${drs}"
145 +
146 + echo ${drs}
147 +}
148 +
149 +changed() {
150 + [[ -f ${ETC_LDSO_PATH} ]] || return 0
151 + local current=$(<${ETC_LDSO_PATH})
152 + current=${current//$'\n'/ }
153 + [[ ${current} != ${drs} ]] || return 1
154 +}
155 +
156 +get_options "$@"
157 +
158 +if [[ ! -e ${LDSO_CONF} ]]; then
159 + echo "${LDSO_CONF} not found" >&2
160 + exit 1
161 +fi
162 +
163 +LDSO_CONF_DIR=$(dirname ${LDSO_CONF})
164 +
165 +drs=$(read_ldso_conf "${LDSO_CONF}")
166 +drs=$(sanitize ${drs})
167 +
168 +ARCH=@@ARCH@@
169 +LDSO_PATH="${ROOT}${EPREFIX}/lib/ld-musl-${ARCH}.so.1"
170 +if [[ ! -e ${LDSO_PATH} ]]; then
171 + echo "${LDSO_PATH} not found" >&2
172 + exit 1
173 +fi
174 +
175 +LDSO_ARCH=$(basename ${LDSO_PATH})
176 +LDSO_NAME=${LDSO_ARCH%.so.1}
177 +ETC_LDSO_PATH="${ROOT}${EPREFIX}/etc/${LDSO_NAME}.path"
178 +
179 +changed || exit 0
180 +X=$(mktemp -p /tmp ${LDSO_NAME}.XXXXXX)
181 +for d in ${drs}; do
182 + echo ${d} >> ${X}
183 +done
184 +chmod 644 ${X}
185 +# busybox doesn't support mz -Z
186 +cp ${X} ${ETC_LDSO_PATH}
187 +rm ${X}
188
189 diff --git a/sys-libs/musl/musl-9999.ebuild b/sys-libs/musl/musl-1.2.2-r8.ebuild
190 similarity index 76%
191 copy from sys-libs/musl/musl-9999.ebuild
192 copy to sys-libs/musl/musl-1.2.2-r8.ebuild
193 index 6a5e2688dd5a..52960e95a004 100644
194 --- a/sys-libs/musl/musl-9999.ebuild
195 +++ b/sys-libs/musl/musl-1.2.2-r8.ebuild
196 @@ -1,9 +1,9 @@
197 -# Copyright 1999-2021 Gentoo Authors
198 +# Copyright 1999-2022 Gentoo Authors
199 # Distributed under the terms of the GNU General Public License v2
200
201 EAPI=7
202
203 -inherit eapi8-dosym flag-o-matic toolchain-funcs
204 +inherit eapi8-dosym flag-o-matic toolchain-funcs prefix
205 if [[ ${PV} == "9999" ]] ; then
206 EGIT_REPO_URI="git://git.musl-libc.org/musl"
207 inherit git-r3
208 @@ -76,11 +76,11 @@ src_configure() {
209 just_headers && export CC=true
210
211 local sysroot
212 - is_crosscompile && sysroot="${EPREFIX}"/usr/${CTARGET}
213 + is_crosscompile && sysroot=/usr/${CTARGET}
214 ./configure \
215 --target=${CTARGET} \
216 - --prefix=${sysroot}/usr \
217 - --syslibdir=${sysroot}/lib \
218 + --prefix=${EPREFIX}${sysroot}/usr \
219 + --syslibdir=${EPREFIX}${sysroot}/lib \
220 --disable-gcc-wrapper || die
221 }
222
223 @@ -111,8 +111,8 @@ src_install() {
224 # musl provides ldd via a sym link to its ld.so
225 local sysroot
226 is_crosscompile && sysroot=/usr/${CTARGET}
227 - local ldso=$(basename "${D}"${sysroot}/lib/ld-musl-*)
228 - dosym ${sysroot}/lib/${ldso} ${sysroot}/usr/bin/ldd
229 + local ldso=$(basename "${ED}"${sysroot}/lib/ld-musl-*)
230 + dosym ${EPREFIX}${sysroot}/lib/${ldso} ${sysroot}/usr/bin/ldd
231
232 if [[ ${CATEGORY} != cross-* ]] ; then
233 # Fish out of config:
234 @@ -121,24 +121,20 @@ src_install() {
235 # and print $(ARCH)$(SUBARCH).
236 local arch=$(awk '{ k[$1] = $3 } END { printf("%s%s", k["ARCH"], k["SUBARCH"]); }' config.mak)
237
238 - if [[ ! -e "${ED}"/lib/ld-musl-${arch}.so.1 ]] ; then
239 - # During cross (using crossdev), when emerging sys-libs/musl,
240 - # if /usr/lib/libc.so.1 doesn't exist on the system, installation
241 - # would fail.
242 - #
243 - # The musl build system seems to create a symlink:
244 - # ${D}/lib/ld-musl-${arch}.so.1 -> /usr/lib/libc.so.1 (absolute)
245 - # During cross, there's no guarantee that the host is using musl
246 - # so that file may not exist. Use a relative symlink within ${D}
247 - # instead.
248 - dosym8 -r /usr/lib/libc.so /lib/ld-musl-${arch}.so.1
249 -
250 - # If it's still a dead symlnk, OK, we really do need to abort.
251 - [[ -e "${ED}"/lib/ld-musl-${arch}.so.1 ]] || die
252 - fi
253 -
254 - cp "${FILESDIR}"/ldconfig.in-r1 "${T}"/ldconfig.in || die
255 + # The musl build system seems to create a symlink:
256 + # ${D}/lib/ld-musl-${arch}.so.1 -> /usr/lib/libc.so.1 (absolute)
257 + # During cross or within prefix, there's no guarantee that the host is
258 + # using musl so that file may not exist. Use a relative symlink within
259 + # ${D} instead.
260 + rm -f "${ED}"/lib/ld-musl-${arch}.so.1 || die
261 + dosym8 -r /usr/lib/libc.so /lib/ld-musl-${arch}.so.1
262 +
263 + # If it's still a dead symlnk, OK, we really do need to abort.
264 + [[ -e "${ED}"/lib/ld-musl-${arch}.so.1 ]] || die
265 +
266 + cp "${FILESDIR}"/ldconfig.in-r3 "${T}"/ldconfig.in || die
267 sed -e "s|@@ARCH@@|${arch}|" "${T}"/ldconfig.in > "${T}"/ldconfig || die
268 + eprefixify "${T}"/ldconfig
269 into /
270 dosbin "${T}"/ldconfig
271 into /usr
272
273 diff --git a/sys-libs/musl/musl-9999.ebuild b/sys-libs/musl/musl-9999.ebuild
274 index 6a5e2688dd5a..52960e95a004 100644
275 --- a/sys-libs/musl/musl-9999.ebuild
276 +++ b/sys-libs/musl/musl-9999.ebuild
277 @@ -1,9 +1,9 @@
278 -# Copyright 1999-2021 Gentoo Authors
279 +# Copyright 1999-2022 Gentoo Authors
280 # Distributed under the terms of the GNU General Public License v2
281
282 EAPI=7
283
284 -inherit eapi8-dosym flag-o-matic toolchain-funcs
285 +inherit eapi8-dosym flag-o-matic toolchain-funcs prefix
286 if [[ ${PV} == "9999" ]] ; then
287 EGIT_REPO_URI="git://git.musl-libc.org/musl"
288 inherit git-r3
289 @@ -76,11 +76,11 @@ src_configure() {
290 just_headers && export CC=true
291
292 local sysroot
293 - is_crosscompile && sysroot="${EPREFIX}"/usr/${CTARGET}
294 + is_crosscompile && sysroot=/usr/${CTARGET}
295 ./configure \
296 --target=${CTARGET} \
297 - --prefix=${sysroot}/usr \
298 - --syslibdir=${sysroot}/lib \
299 + --prefix=${EPREFIX}${sysroot}/usr \
300 + --syslibdir=${EPREFIX}${sysroot}/lib \
301 --disable-gcc-wrapper || die
302 }
303
304 @@ -111,8 +111,8 @@ src_install() {
305 # musl provides ldd via a sym link to its ld.so
306 local sysroot
307 is_crosscompile && sysroot=/usr/${CTARGET}
308 - local ldso=$(basename "${D}"${sysroot}/lib/ld-musl-*)
309 - dosym ${sysroot}/lib/${ldso} ${sysroot}/usr/bin/ldd
310 + local ldso=$(basename "${ED}"${sysroot}/lib/ld-musl-*)
311 + dosym ${EPREFIX}${sysroot}/lib/${ldso} ${sysroot}/usr/bin/ldd
312
313 if [[ ${CATEGORY} != cross-* ]] ; then
314 # Fish out of config:
315 @@ -121,24 +121,20 @@ src_install() {
316 # and print $(ARCH)$(SUBARCH).
317 local arch=$(awk '{ k[$1] = $3 } END { printf("%s%s", k["ARCH"], k["SUBARCH"]); }' config.mak)
318
319 - if [[ ! -e "${ED}"/lib/ld-musl-${arch}.so.1 ]] ; then
320 - # During cross (using crossdev), when emerging sys-libs/musl,
321 - # if /usr/lib/libc.so.1 doesn't exist on the system, installation
322 - # would fail.
323 - #
324 - # The musl build system seems to create a symlink:
325 - # ${D}/lib/ld-musl-${arch}.so.1 -> /usr/lib/libc.so.1 (absolute)
326 - # During cross, there's no guarantee that the host is using musl
327 - # so that file may not exist. Use a relative symlink within ${D}
328 - # instead.
329 - dosym8 -r /usr/lib/libc.so /lib/ld-musl-${arch}.so.1
330 -
331 - # If it's still a dead symlnk, OK, we really do need to abort.
332 - [[ -e "${ED}"/lib/ld-musl-${arch}.so.1 ]] || die
333 - fi
334 -
335 - cp "${FILESDIR}"/ldconfig.in-r1 "${T}"/ldconfig.in || die
336 + # The musl build system seems to create a symlink:
337 + # ${D}/lib/ld-musl-${arch}.so.1 -> /usr/lib/libc.so.1 (absolute)
338 + # During cross or within prefix, there's no guarantee that the host is
339 + # using musl so that file may not exist. Use a relative symlink within
340 + # ${D} instead.
341 + rm -f "${ED}"/lib/ld-musl-${arch}.so.1 || die
342 + dosym8 -r /usr/lib/libc.so /lib/ld-musl-${arch}.so.1
343 +
344 + # If it's still a dead symlnk, OK, we really do need to abort.
345 + [[ -e "${ED}"/lib/ld-musl-${arch}.so.1 ]] || die
346 +
347 + cp "${FILESDIR}"/ldconfig.in-r3 "${T}"/ldconfig.in || die
348 sed -e "s|@@ARCH@@|${arch}|" "${T}"/ldconfig.in > "${T}"/ldconfig || die
349 + eprefixify "${T}"/ldconfig
350 into /
351 dosbin "${T}"/ldconfig
352 into /usr