Gentoo Archives: gentoo-commits

From: "Anthony G. Basile" <blueness@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/musl/, sys-libs/musl/files/
Date: Tue, 02 Oct 2018 23:44:07
Message-Id: 1538523766.cf5756d9f7c89635bf73b4f781f464b24019a77c.blueness@gentoo
1 commit: cf5756d9f7c89635bf73b4f781f464b24019a77c
2 Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
3 AuthorDate: Tue Oct 2 23:42:46 2018 +0000
4 Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
5 CommitDate: Tue Oct 2 23:42:46 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cf5756d9
7
8 sys-libs/musl: fix bug #667234
9
10 Signed-off-by: Anthony G. Basile <blueness <AT> gentoo.org>
11 Package-Manager: Portage-2.3.49, Repoman-2.3.10
12
13 .../musl/files/musl-1.1.20-fix-getaddrinfo.patch | 51 +++++++++
14 sys-libs/musl/musl-1.1.20-r1.ebuild | 123 +++++++++++++++++++++
15 2 files changed, 174 insertions(+)
16
17 diff --git a/sys-libs/musl/files/musl-1.1.20-fix-getaddrinfo.patch b/sys-libs/musl/files/musl-1.1.20-fix-getaddrinfo.patch
18 new file mode 100644
19 index 00000000000..28d4558b8b6
20 --- /dev/null
21 +++ b/sys-libs/musl/files/musl-1.1.20-fix-getaddrinfo.patch
22 @@ -0,0 +1,51 @@
23 +From f381c118b2d4f7d914481d3cdc830ce41369b002 Mon Sep 17 00:00:00 2001
24 +From: Rich Felker <dalias@×××××××.cx>
25 +Date: Wed, 19 Sep 2018 18:03:22 -0400
26 +Subject: fix getaddrinfo regression with AI_ADDRCONFIG on some configurations
27 +
28 +despite not being documented to do so in the standard or Linux
29 +documentation, attempts to udp connect to 127.0.0.1 or ::1 generate
30 +EADDRNOTAVAIL when the loopback device is not configured and there is
31 +no default route for IPv6. this caused getaddrinfo with AI_ADDRCONFIG
32 +to fail with EAI_SYSTEM and EADDRNOTAVAIL on some no-IPv6
33 +configurations, rather than the intended behavior of detecting IPv6 as
34 +unsuppported and producing IPv4-only results.
35 +
36 +previously, only EAFNOSUPPORT was treated as unavailability of the
37 +address family being probed. instead, treat all errors related to
38 +inability to get an address or route as conclusive that the family
39 +being probed is unsupported, and only fail with EAI_SYSTEM on other
40 +errors.
41 +
42 +further improvements may be desirable, such as reporting EAI_AGAIN
43 +instead of EAI_SYSTEM for errors which are expected to be transient,
44 +but this patch should suffice to fix the serious regression.
45 +---
46 + src/network/getaddrinfo.c | 11 ++++++++++-
47 + 1 file changed, 10 insertions(+), 1 deletion(-)
48 +
49 +diff --git a/src/network/getaddrinfo.c b/src/network/getaddrinfo.c
50 +index ba26847a..e33bfa28 100644
51 +--- a/src/network/getaddrinfo.c
52 ++++ b/src/network/getaddrinfo.c
53 +@@ -76,7 +76,16 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru
54 + close(s);
55 + if (!r) continue;
56 + }
57 +- if (errno != EAFNOSUPPORT) return EAI_SYSTEM;
58 ++ switch (errno) {
59 ++ case EADDRNOTAVAIL:
60 ++ case EAFNOSUPPORT:
61 ++ case EHOSTUNREACH:
62 ++ case ENETDOWN:
63 ++ case ENETUNREACH:
64 ++ break;
65 ++ default:
66 ++ return EAI_SYSTEM;
67 ++ }
68 + if (family == tf[i]) return EAI_NONAME;
69 + family = tf[1-i];
70 + }
71 +--
72 +cgit v1.2.1
73 +
74
75 diff --git a/sys-libs/musl/musl-1.1.20-r1.ebuild b/sys-libs/musl/musl-1.1.20-r1.ebuild
76 new file mode 100644
77 index 00000000000..cba85ae6bb6
78 --- /dev/null
79 +++ b/sys-libs/musl/musl-1.1.20-r1.ebuild
80 @@ -0,0 +1,123 @@
81 +# Copyright 1999-2018 Gentoo Foundation
82 +# Distributed under the terms of the GNU General Public License v2
83 +
84 +EAPI=6
85 +
86 +inherit eutils flag-o-matic multilib toolchain-funcs
87 +if [[ ${PV} == "9999" ]] ; then
88 + EGIT_REPO_URI="git://git.musl-libc.org/musl"
89 + inherit git-r3
90 + SRC_URI="
91 + https://dev.gentoo.org/~blueness/musl-misc/getconf.c
92 + https://dev.gentoo.org/~blueness/musl-misc/getent.c
93 + https://dev.gentoo.org/~blueness/musl-misc/iconv.c"
94 + KEYWORDS=""
95 +else
96 + SRC_URI="http://www.musl-libc.org/releases/${P}.tar.gz
97 + https://dev.gentoo.org/~blueness/musl-misc/getconf.c
98 + https://dev.gentoo.org/~blueness/musl-misc/getent.c
99 + https://dev.gentoo.org/~blueness/musl-misc/iconv.c"
100 + KEYWORDS="-* ~amd64 ~arm ~arm64 ~mips ~ppc ~x86"
101 +fi
102 +
103 +export CBUILD=${CBUILD:-${CHOST}}
104 +export CTARGET=${CTARGET:-${CHOST}}
105 +if [[ ${CTARGET} == ${CHOST} ]] ; then
106 + if [[ ${CATEGORY} == cross-* ]] ; then
107 + export CTARGET=${CATEGORY#cross-}
108 + fi
109 +fi
110 +
111 +DESCRIPTION="Light, fast and simple C library focused on standards-conformance and safety"
112 +HOMEPAGE="http://www.musl-libc.org/"
113 +LICENSE="MIT LGPL-2 GPL-2"
114 +SLOT="0"
115 +IUSE="headers-only"
116 +
117 +QA_SONAME="/usr/lib/libc.so"
118 +QA_DT_NEEDED="/usr/lib/libc.so"
119 +
120 +is_crosscompile() {
121 + [[ ${CHOST} != ${CTARGET} ]]
122 +}
123 +
124 +just_headers() {
125 + use headers-only && is_crosscompile
126 +}
127 +
128 +pkg_setup() {
129 + if [ ${CTARGET} == ${CHOST} ] ; then
130 + case ${CHOST} in
131 + *-musl*) ;;
132 + *) die "Use sys-devel/crossdev to build a musl toolchain" ;;
133 + esac
134 + fi
135 +}
136 +
137 +src_prepare() {
138 + eapply "${FILESDIR}/${P}-fix-getaddrinfo.patch"
139 + eapply_user
140 +}
141 +
142 +src_configure() {
143 + tc-getCC ${CTARGET}
144 + just_headers && export CC=true
145 +
146 + local sysroot
147 + is_crosscompile && sysroot=/usr/${CTARGET}
148 + ./configure \
149 + --target=${CTARGET} \
150 + --prefix=${sysroot}/usr \
151 + --syslibdir=${sysroot}/lib \
152 + --disable-gcc-wrapper || die
153 +}
154 +
155 +src_compile() {
156 + emake obj/include/bits/alltypes.h
157 + just_headers && return 0
158 +
159 + emake
160 + if [[ ${CATEGORY} != cross-* ]] ; then
161 + $(tc-getCC) ${CFLAGS} "${DISTDIR}"/getconf.c -o "${T}"/getconf || die
162 + $(tc-getCC) ${CFLAGS} "${DISTDIR}"/getent.c -o "${T}"/getent || die
163 + $(tc-getCC) ${CFLAGS} "${DISTDIR}"/iconv.c -o "${T}"/iconv || die
164 + fi
165 +}
166 +
167 +src_install() {
168 + local target="install"
169 + just_headers && target="install-headers"
170 + emake DESTDIR="${D}" ${target}
171 + just_headers && return 0
172 +
173 + # musl provides ldd via a sym link to its ld.so
174 + local sysroot
175 + is_crosscompile && sysroot=/usr/${CTARGET}
176 + local ldso=$(basename "${D}"${sysroot}/lib/ld-musl-*)
177 + dosym ${sysroot}/lib/${ldso} ${sysroot}/usr/bin/ldd
178 +
179 + if [[ ${CATEGORY} != cross-* ]] ; then
180 + local arch=$("${D}"usr/lib/libc.so 2>&1 | sed -n '1s/^musl libc (\(.*\))$/\1/p')
181 + [[ -e "${D}"/lib/ld-musl-${arch}.so.1 ]] || die
182 + cp "${FILESDIR}"/ldconfig.in "${T}" || die
183 + sed -e "s|@@ARCH@@|${arch}|" "${T}"/ldconfig.in > "${T}"/ldconfig || die
184 + into /
185 + dosbin "${T}"/ldconfig
186 + into /usr
187 + dobin "${T}"/getconf
188 + dobin "${T}"/getent
189 + dobin "${T}"/iconv
190 + echo 'LDPATH="include ld.so.conf.d/*.conf"' > "${T}"/00musl || die
191 + doenvd "${T}"/00musl || die
192 + fi
193 +}
194 +
195 +pkg_postinst() {
196 + is_crosscompile && return 0
197 +
198 + [ "${ROOT}" != "/" ] && return 0
199 +
200 + ldconfig || die
201 + # reload init ...
202 + /sbin/telinit U 2>/dev/null
203 +}