Gentoo Archives: gentoo-commits

From: Mart Raudsepp <leio@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-libs/glib/files/, dev-libs/glib/
Date: Wed, 01 Jan 2020 15:41:53
Message-Id: 1577893241.1ed2ea2d465969fba6a72c270d712287d2e3e116.leio@gentoo
1 commit: 1ed2ea2d465969fba6a72c270d712287d2e3e116
2 Author: Mart Raudsepp <leio <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jan 1 15:40:23 2020 +0000
4 Commit: Mart Raudsepp <leio <AT> gentoo <DOT> org>
5 CommitDate: Wed Jan 1 15:40:41 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1ed2ea2d
7
8 dev-libs/glib: backport GDBus fixes necessary for ibus security fixes
9
10 Closes: https://bugs.gentoo.org/700538
11 Package-Manager: Portage-2.3.79, Repoman-2.3.12
12 Signed-off-by: Mart Raudsepp <leio <AT> gentoo.org>
13
14 dev-libs/glib/files/2.60.7-gdbus-fixes.patch | 301 +++++++++++++++++++++++++++
15 dev-libs/glib/glib-2.60.7-r1.ebuild | 279 +++++++++++++++++++++++++
16 2 files changed, 580 insertions(+)
17
18 diff --git a/dev-libs/glib/files/2.60.7-gdbus-fixes.patch b/dev-libs/glib/files/2.60.7-gdbus-fixes.patch
19 new file mode 100644
20 index 00000000000..e2a066beec7
21 --- /dev/null
22 +++ b/dev-libs/glib/files/2.60.7-gdbus-fixes.patch
23 @@ -0,0 +1,301 @@
24 +From 1cfab12a28d97716ad581c30fbbf3e94e4d7f303 Mon Sep 17 00:00:00 2001
25 +From: Simon McVittie <smcv@×××××××××.com>
26 +Date: Mon, 14 Oct 2019 08:22:24 +0100
27 +Subject: [PATCH 1/3] gcredentialsprivate: Document the various private macros
28 +
29 +Signed-off-by: Simon McVittie <smcv@×××××××××.com>
30 +---
31 + gio/gcredentialsprivate.h | 59 +++++++++++++++++++++++++++++++++++++++
32 + 1 file changed, 59 insertions(+)
33 +
34 +diff --git a/gio/gcredentialsprivate.h b/gio/gcredentialsprivate.h
35 +index 4d1c420a8..06f0aed19 100644
36 +--- a/gio/gcredentialsprivate.h
37 ++++ b/gio/gcredentialsprivate.h
38 +@@ -22,6 +22,65 @@
39 + #include "gio/gcredentials.h"
40 + #include "gio/gnetworking.h"
41 +
42 ++/*
43 ++ * G_CREDENTIALS_SUPPORTED:
44 ++ *
45 ++ * Defined to 1 if GCredentials works.
46 ++ */
47 ++#undef G_CREDENTIALS_SUPPORTED
48 ++
49 ++/*
50 ++ * G_CREDENTIALS_USE_LINUX_UCRED, etc.:
51 ++ *
52 ++ * Defined to 1 if GCredentials uses Linux `struct ucred`, etc.
53 ++ */
54 ++#undef G_CREDENTIALS_USE_LINUX_UCRED
55 ++#undef G_CREDENTIALS_USE_FREEBSD_CMSGCRED
56 ++#undef G_CREDENTIALS_USE_NETBSD_UNPCBID
57 ++#undef G_CREDENTIALS_USE_OPENBSD_SOCKPEERCRED
58 ++#undef G_CREDENTIALS_USE_SOLARIS_UCRED
59 ++
60 ++/*
61 ++ * G_CREDENTIALS_NATIVE_TYPE:
62 ++ *
63 ++ * Defined to one of G_CREDENTIALS_TYPE_LINUX_UCRED, etc.
64 ++ */
65 ++#undef G_CREDENTIALS_NATIVE_TYPE
66 ++
67 ++/*
68 ++ * G_CREDENTIALS_NATIVE_SIZE:
69 ++ *
70 ++ * Defined to the size of the %G_CREDENTIALS_NATIVE_TYPE
71 ++ */
72 ++#undef G_CREDENTIALS_NATIVE_SIZE
73 ++
74 ++/*
75 ++ * G_CREDENTIALS_UNIX_CREDENTIALS_MESSAGE_SUPPORTED:
76 ++ *
77 ++ * Defined to 1 if we have a message-passing API in which credentials
78 ++ * are attached to a particular message, such as `SCM_CREDENTIALS` on Linux
79 ++ * or `SCM_CREDS` on FreeBSD.
80 ++ */
81 ++#undef G_CREDENTIALS_UNIX_CREDENTIALS_MESSAGE_SUPPORTED
82 ++
83 ++/*
84 ++ * G_CREDENTIALS_SOCKET_GET_CREDENTIALS_SUPPORTED:
85 ++ *
86 ++ * Defined to 1 if we have a `getsockopt()`-style API in which one end of
87 ++ * a socket connection can directly query the credentials of the process
88 ++ * that initiated the other end, such as `getsockopt SO_PEERCRED` on Linux
89 ++ * or `getpeereid()` on multiple operating systems.
90 ++ */
91 ++#undef G_CREDENTIALS_SOCKET_GET_CREDENTIALS_SUPPORTED
92 ++
93 ++/*
94 ++ * G_CREDENTIALS_SPOOFING_SUPPORTED:
95 ++ *
96 ++ * Defined to 1 if privileged processes can spoof their credentials when
97 ++ * using the message-passing API.
98 ++ */
99 ++#undef G_CREDENTIALS_SPOOFING_SUPPORTED
100 ++
101 + #ifdef __linux__
102 + #define G_CREDENTIALS_SUPPORTED 1
103 + #define G_CREDENTIALS_USE_LINUX_UCRED 1
104 +--
105 +2.20.1
106 +
107 +
108 +From 5f9318af8f19756685c1b79cf8b76f3e66614d84 Mon Sep 17 00:00:00 2001
109 +From: Simon McVittie <smcv@×××××××××.com>
110 +Date: Fri, 18 Oct 2019 10:55:09 +0100
111 +Subject: [PATCH 2/3] credentials: Invalid Linux struct ucred means "no
112 + information"
113 +
114 +On Linux, if getsockopt SO_PEERCRED is used on a TCP socket, one
115 +might expect it to fail with an appropriate error like ENOTSUP or
116 +EPROTONOSUPPORT. However, it appears that in fact it succeeds, but
117 +yields a credentials structure with pid 0, uid -1 and gid -1. These
118 +are not real process, user and group IDs that can be allocated to a
119 +real process (pid 0 needs to be reserved to give kill(0) its documented
120 +special semantics, and similarly uid and gid -1 need to be reserved for
121 +setresuid() and setresgid()) so it is not meaningful to signal them to
122 +high-level API users.
123 +
124 +An API user with Linux-specific knowledge can still inspect these fields
125 +via g_credentials_get_native() if desired.
126 +
127 +Similarly, if SO_PASSCRED is used to receive a SCM_CREDENTIALS message
128 +on a receiving Unix socket, but the sending socket had not enabled
129 +SO_PASSCRED at the time that the message was sent, it is possible
130 +for it to succeed but yield a credentials structure with pid 0, uid
131 +/proc/sys/kernel/overflowuid and gid /proc/sys/kernel/overflowgid. Even
132 +if we were to read those pseudo-files, we cannot distinguish between
133 +the overflow IDs and a real process that legitimately has the same IDs
134 +(typically they are set to 'nobody' and 'nogroup', which can be used
135 +by a real process), so we detect this situation by noticing that
136 +pid == 0, and to save syscalls we do not read the overflow IDs from
137 +/proc at all.
138 +
139 +This results in a small API change: g_credentials_is_same_user() now
140 +returns FALSE if we compare two credentials structures that are both
141 +invalid. This seems like reasonable, conservative behaviour: if we cannot
142 +prove that they are the same user, we should assume they are not.
143 +
144 +(Dropped new translatable string when backporting to `glib-2-62`.)
145 +
146 +Signed-off-by: Simon McVittie <smcv@×××××××××.com>
147 +---
148 + gio/gcredentials.c | 42 +++++++++++++++++++++++++++++++++++++++---
149 + 1 file changed, 39 insertions(+), 3 deletions(-)
150 +
151 +diff --git a/gio/gcredentials.c b/gio/gcredentials.c
152 +index 57a39f2a2..ff9b7e0b8 100644
153 +--- a/gio/gcredentials.c
154 ++++ b/gio/gcredentials.c
155 +@@ -265,6 +265,35 @@ g_credentials_to_string (GCredentials *credentials)
156 +
157 + /* ---------------------------------------------------------------------------------------------------- */
158 +
159 ++#if G_CREDENTIALS_USE_LINUX_UCRED
160 ++/*
161 ++ * Check whether @native contains invalid data. If getsockopt SO_PEERCRED
162 ++ * is used on a TCP socket, it succeeds but yields a credentials structure
163 ++ * with pid 0, uid -1 and gid -1. Similarly, if SO_PASSCRED is used on a
164 ++ * receiving Unix socket when the sending socket did not also enable
165 ++ * SO_PASSCRED, it can succeed but yield a credentials structure with
166 ++ * pid 0, uid /proc/sys/kernel/overflowuid and gid
167 ++ * /proc/sys/kernel/overflowgid.
168 ++ */
169 ++static gboolean
170 ++linux_ucred_check_valid (struct ucred *native,
171 ++ GError **error)
172 ++{
173 ++ if (native->pid == 0
174 ++ || native->uid == -1
175 ++ || native->gid == -1)
176 ++ {
177 ++ g_set_error_literal (error,
178 ++ G_IO_ERROR,
179 ++ G_IO_ERROR_INVALID_DATA,
180 ++ "GCredentials contains invalid data");
181 ++ return FALSE;
182 ++ }
183 ++
184 ++ return TRUE;
185 ++}
186 ++#endif
187 ++
188 + /**
189 + * g_credentials_is_same_user:
190 + * @credentials: A #GCredentials.
191 +@@ -294,7 +323,8 @@ g_credentials_is_same_user (GCredentials *credentials,
192 +
193 + ret = FALSE;
194 + #if G_CREDENTIALS_USE_LINUX_UCRED
195 +- if (credentials->native.uid == other_credentials->native.uid)
196 ++ if (linux_ucred_check_valid (&credentials->native, NULL)
197 ++ && credentials->native.uid == other_credentials->native.uid)
198 + ret = TRUE;
199 + #elif G_CREDENTIALS_USE_FREEBSD_CMSGCRED
200 + if (credentials->native.cmcred_euid == other_credentials->native.cmcred_euid)
201 +@@ -453,7 +483,10 @@ g_credentials_get_unix_user (GCredentials *credentials,
202 + g_return_val_if_fail (error == NULL || *error == NULL, -1);
203 +
204 + #if G_CREDENTIALS_USE_LINUX_UCRED
205 +- ret = credentials->native.uid;
206 ++ if (linux_ucred_check_valid (&credentials->native, error))
207 ++ ret = credentials->native.uid;
208 ++ else
209 ++ ret = -1;
210 + #elif G_CREDENTIALS_USE_FREEBSD_CMSGCRED
211 + ret = credentials->native.cmcred_euid;
212 + #elif G_CREDENTIALS_USE_NETBSD_UNPCBID
213 +@@ -499,7 +532,10 @@ g_credentials_get_unix_pid (GCredentials *credentials,
214 + g_return_val_if_fail (error == NULL || *error == NULL, -1);
215 +
216 + #if G_CREDENTIALS_USE_LINUX_UCRED
217 +- ret = credentials->native.pid;
218 ++ if (linux_ucred_check_valid (&credentials->native, error))
219 ++ ret = credentials->native.pid;
220 ++ else
221 ++ ret = -1;
222 + #elif G_CREDENTIALS_USE_FREEBSD_CMSGCRED
223 + ret = credentials->native.cmcred_pid;
224 + #elif G_CREDENTIALS_USE_NETBSD_UNPCBID
225 +--
226 +2.20.1
227 +
228 +
229 +From c7618cce3752e1f3681f75d0a26c7e07c15bd6a2 Mon Sep 17 00:00:00 2001
230 +From: Simon McVittie <smcv@×××××××××.com>
231 +Date: Mon, 14 Oct 2019 08:47:39 +0100
232 +Subject: [PATCH 3/3] GDBus: prefer getsockopt()-style credentials-passing APIs
233 +
234 +Closes: https://gitlab.gnome.org/GNOME/glib/issues/1831
235 +---
236 + gio/gcredentialsprivate.h | 18 ++++++++++++++++++
237 + gio/gdbusauth.c | 27 +++++++++++++++++++++++++--
238 + 2 files changed, 43 insertions(+), 2 deletions(-)
239 +
240 +diff --git a/gio/gcredentialsprivate.h b/gio/gcredentialsprivate.h
241 +index 06f0aed19..e9ec09b9f 100644
242 +--- a/gio/gcredentialsprivate.h
243 ++++ b/gio/gcredentialsprivate.h
244 +@@ -81,6 +81,18 @@
245 + */
246 + #undef G_CREDENTIALS_SPOOFING_SUPPORTED
247 +
248 ++/*
249 ++ * G_CREDENTIALS_PREFER_MESSAGE_PASSING:
250 ++ *
251 ++ * Defined to 1 if the data structure transferred by the message-passing
252 ++ * API is strictly more informative than the one transferred by the
253 ++ * `getsockopt()`-style API, and hence should be preferred, even for
254 ++ * protocols like D-Bus that are defined in terms of the credentials of
255 ++ * the (process that opened the) socket, as opposed to the credentials
256 ++ * of an individual message.
257 ++ */
258 ++#undef G_CREDENTIALS_PREFER_MESSAGE_PASSING
259 ++
260 + #ifdef __linux__
261 + #define G_CREDENTIALS_SUPPORTED 1
262 + #define G_CREDENTIALS_USE_LINUX_UCRED 1
263 +@@ -100,6 +112,12 @@
264 + #define G_CREDENTIALS_NATIVE_SIZE (sizeof (struct cmsgcred))
265 + #define G_CREDENTIALS_UNIX_CREDENTIALS_MESSAGE_SUPPORTED 1
266 + #define G_CREDENTIALS_SPOOFING_SUPPORTED 1
267 ++/* GLib doesn't implement it yet, but FreeBSD's getsockopt()-style API
268 ++ * is getpeereid(), which is not as informative as struct cmsgcred -
269 ++ * it does not tell us the PID. As a result, libdbus prefers to use
270 ++ * SCM_CREDS, and if we implement getpeereid() in future, we should
271 ++ * do the same. */
272 ++#define G_CREDENTIALS_PREFER_MESSAGE_PASSING 1
273 +
274 + #elif defined(__NetBSD__)
275 + #define G_CREDENTIALS_SUPPORTED 1
276 +diff --git a/gio/gdbusauth.c b/gio/gdbusauth.c
277 +index 752ec23fc..14cc5d70e 100644
278 +--- a/gio/gdbusauth.c
279 ++++ b/gio/gdbusauth.c
280 +@@ -31,6 +31,7 @@
281 + #include "gdbusutils.h"
282 + #include "gioenumtypes.h"
283 + #include "gcredentials.h"
284 ++#include "gcredentialsprivate.h"
285 + #include "gdbusprivate.h"
286 + #include "giostream.h"
287 + #include "gdatainputstream.h"
288 +@@ -969,9 +970,31 @@ _g_dbus_auth_run_server (GDBusAuth *auth,
289 +
290 + g_data_input_stream_set_newline_type (dis, G_DATA_STREAM_NEWLINE_TYPE_CR_LF);
291 +
292 +- /* first read the NUL-byte */
293 ++ /* read the NUL-byte, possibly with credentials attached */
294 + #ifdef G_OS_UNIX
295 +- if (G_IS_UNIX_CONNECTION (auth->priv->stream))
296 ++#ifndef G_CREDENTIALS_PREFER_MESSAGE_PASSING
297 ++ if (G_IS_SOCKET_CONNECTION (auth->priv->stream))
298 ++ {
299 ++ GSocket *sock = g_socket_connection_get_socket (G_SOCKET_CONNECTION (auth->priv->stream));
300 ++
301 ++ local_error = NULL;
302 ++ credentials = g_socket_get_credentials (sock, &local_error);
303 ++
304 ++ if (credentials == NULL && !g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED))
305 ++ {
306 ++ g_propagate_error (error, local_error);
307 ++ goto out;
308 ++ }
309 ++ else
310 ++ {
311 ++ /* Clear the error indicator, so we can retry with
312 ++ * g_unix_connection_receive_credentials() if necessary */
313 ++ g_clear_error (&local_error);
314 ++ }
315 ++ }
316 ++#endif
317 ++
318 ++ if (credentials == NULL && G_IS_UNIX_CONNECTION (auth->priv->stream))
319 + {
320 + local_error = NULL;
321 + credentials = g_unix_connection_receive_credentials (G_UNIX_CONNECTION (auth->priv->stream),
322 +--
323 +2.20.1
324 +
325
326 diff --git a/dev-libs/glib/glib-2.60.7-r1.ebuild b/dev-libs/glib/glib-2.60.7-r1.ebuild
327 new file mode 100644
328 index 00000000000..7f37b1775ab
329 --- /dev/null
330 +++ b/dev-libs/glib/glib-2.60.7-r1.ebuild
331 @@ -0,0 +1,279 @@
332 +# Copyright 1999-2020 Gentoo Authors
333 +# Distributed under the terms of the GNU General Public License v2
334 +
335 +EAPI=7
336 +PYTHON_COMPAT=( python{3_5,3_6,3_7} )
337 +
338 +inherit flag-o-matic gnome.org gnome2-utils linux-info meson multilib multilib-minimal python-any-r1 toolchain-funcs xdg
339 +
340 +DESCRIPTION="The GLib library of C routines"
341 +HOMEPAGE="https://www.gtk.org/"
342 +
343 +LICENSE="LGPL-2.1+"
344 +SLOT="2"
345 +IUSE="dbus debug elibc_glibc fam gtk-doc kernel_linux +mime selinux static-libs systemtap test utils xattr"
346 +RESTRICT="!test? ( test )"
347 +
348 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sh ~sparc ~x86 ~amd64-linux ~x86-linux"
349 +
350 +# * libelf isn't strictly necessary, but makes gresource tool more useful, and
351 +# the check is automagic in gio/meson.build. gresource is not a multilib tool
352 +# right now, thus it doesn't matter if non-native ABI libelf exists or not
353 +# (non-native binary is overwritten, it doesn't matter if libelf was linked to).
354 +# * Technically static-libs is needed on zlib, util-linux and perhaps more, but
355 +# these are used by GIO, which glib[static-libs] consumers don't really seem
356 +# to need at all, thus not imposing the deps for now and once some consumers
357 +# are actually found to static link libgio-2.0.a, we can revisit and either add
358 +# them or just put the (build) deps in that rare consumer instead of recursive
359 +# RDEPEND here (due to lack of recursive DEPEND).
360 +RDEPEND="
361 + !<dev-util/gdbus-codegen-${PV}
362 + >=virtual/libiconv-0-r1[${MULTILIB_USEDEP}]
363 + >=dev-libs/libpcre-8.31:3[${MULTILIB_USEDEP},static-libs?]
364 + >=virtual/libffi-3.0.13-r1:=[${MULTILIB_USEDEP}]
365 + >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}]
366 + >=virtual/libintl-0-r2[${MULTILIB_USEDEP}]
367 + kernel_linux? ( >=sys-apps/util-linux-2.23[${MULTILIB_USEDEP}] )
368 + selinux? ( >=sys-libs/libselinux-2.2.2-r5[${MULTILIB_USEDEP}] )
369 + xattr? ( !elibc_glibc? ( >=sys-apps/attr-2.4.47-r1[${MULTILIB_USEDEP}] ) )
370 + virtual/libelf:0=
371 + fam? ( >=virtual/fam-0-r1[${MULTILIB_USEDEP}] )
372 +"
373 +DEPEND="${RDEPEND}"
374 +# libxml2 used for optional tests that get automatically skipped
375 +BDEPEND="
376 + app-text/docbook-xsl-stylesheets
377 + dev-libs/libxslt
378 + >=sys-devel/gettext-0.19.8
379 + gtk-doc? ( >=dev-util/gtk-doc-1.20
380 + app-text/docbook-xml-dtd:4.2
381 + app-text/docbook-xml-dtd:4.5 )
382 + systemtap? ( >=dev-util/systemtap-1.3 )
383 + ${PYTHON_DEPS}
384 + test? ( >=sys-apps/dbus-1.2.14 )
385 + virtual/pkgconfig[${MULTILIB_USEDEP}]
386 +"
387 +# TODO: >=dev-util/gdbus-codegen-${PV} test dep once we modify gio/tests/meson.build to use external gdbus-codegen
388 +
389 +PDEPEND="
390 + dbus? ( gnome-base/dconf )
391 + mime? ( x11-misc/shared-mime-info )
392 +"
393 +# shared-mime-info needed for gio/xdgmime, bug #409481
394 +# dconf is needed to be able to save settings, bug #498436
395 +
396 +MULTILIB_CHOST_TOOLS=(
397 + /usr/bin/gio-querymodules$(get_exeext)
398 +)
399 +
400 +pkg_setup() {
401 + if use kernel_linux ; then
402 + CONFIG_CHECK="~INOTIFY_USER"
403 + if use test ; then
404 + CONFIG_CHECK="~IPV6"
405 + WARNING_IPV6="Your kernel needs IPV6 support for running some tests, skipping them."
406 + fi
407 + linux-info_pkg_setup
408 + fi
409 + python-any-r1_pkg_setup
410 +}
411 +
412 +src_prepare() {
413 + eapply "${FILESDIR}"/${PV}-gdbus-fixes.patch #700538, included in 2.62.3+
414 +
415 + if use test; then
416 + # TODO: Review the test exclusions, especially now with meson
417 + # Disable tests requiring dev-util/desktop-file-utils when not installed, bug #286629, upstream bug #629163
418 + if ! has_version dev-util/desktop-file-utils ; then
419 + ewarn "Some tests will be skipped due dev-util/desktop-file-utils not being present on your system,"
420 + ewarn "think on installing it to get these tests run."
421 + sed -i -e "/appinfo\/associations/d" gio/tests/appinfo.c || die
422 + sed -i -e "/g_test_add_func/d" gio/tests/desktop-app-info.c || die
423 + fi
424 +
425 + # gdesktopappinfo requires existing terminal (gnome-terminal or any
426 + # other), falling back to xterm if one doesn't exist
427 + #if ! has_version x11-terms/xterm && ! has_version x11-terms/gnome-terminal ; then
428 + # ewarn "Some tests will be skipped due to missing terminal program"
429 + # These tests seem to sometimes fail even with a terminal; skip for now and reevulate with meson
430 + # Also try https://gitlab.gnome.org/GNOME/glib/issues/1601 once ready for backport (or in a bump) and file new issue if still fails
431 + sed -i -e "/appinfo\/launch/d" gio/tests/appinfo.c || die
432 + # desktop-app-info/launch* might fail similarly
433 + sed -i -e "/desktop-app-info\/launch-as-manager/d" gio/tests/desktop-app-info.c || die
434 + #fi
435 +
436 + # https://bugzilla.gnome.org/show_bug.cgi?id=722604
437 + sed -i -e "/timer\/stop/d" glib/tests/timer.c || die
438 + sed -i -e "/timer\/basic/d" glib/tests/timer.c || die
439 +
440 + ewarn "Tests for search-utils have been skipped"
441 + sed -i -e "/search-utils/d" glib/tests/meson.build || die
442 +
443 + # Play nice with network-sandbox, but this approach would defeat the purpose of the test
444 + #sed -i -e "s/localhost/127.0.0.1/g" gio/tests/gsocketclient-slow.c || die
445 + else
446 + # Don't build tests, also prevents extra deps, bug #512022
447 + sed -i -e '/subdir.*tests/d' {.,gio,glib}/meson.build || die
448 + fi
449 +
450 + # Don't build fuzzing binaries - not used
451 + sed -i -e '/subdir.*fuzzing/d' meson.build || die
452 +
453 + # gdbus-codegen is a separate package
454 + sed -i -e 's/install.*true/install : false/g' gio/gdbus-2.0/codegen/meson.build || die
455 + # Older than meson-0.50 doesn't know about install kwarg for configure_file; for that we need to remove the install_dir kwarg.
456 + # Upstream will remove the install kwarg in a future version to require only meson-0.49.2 or newer, at which point the
457 + # install_dir removal only should be kept.
458 + sed -i -e '/install_dir/d' gio/gdbus-2.0/codegen/meson.build || die
459 +
460 + # Same kind of meson-0.50 issue with some installed-tests files; will likely be fixed upstream soon
461 + sed -i -e '/install_dir/d' gio/tests/meson.build || die
462 +
463 + cat > "${T}/glib-test-ld-wrapper" <<-EOF
464 + #!/usr/bin/env sh
465 + exec \${LD:-ld} "\$@"
466 + EOF
467 + chmod a+x "${T}/glib-test-ld-wrapper" || die
468 + sed -i -e "s|'ld'|'${T}/glib-test-ld-wrapper'|g" gio/tests/meson.build || die
469 +
470 + xdg_src_prepare
471 + gnome2_environment_reset
472 + # TODO: python_name sedding for correct python shebang? Might be relevant mainly for glib-utils only
473 +}
474 +
475 +multilib_src_configure() {
476 + if use debug; then
477 + append-cflags -DG_ENABLE_DEBUG
478 + else
479 + append-cflags -DG_DISABLE_CAST_CHECKS # https://gitlab.gnome.org/GNOME/glib/issues/1833
480 + fi
481 +
482 + # TODO: figure a way to pass appropriate values for all cross properties that glib uses (search for get_cross_property)
483 + #if tc-is-cross-compiler ; then
484 + # https://bugzilla.gnome.org/show_bug.cgi?id=756473
485 + # TODO-meson: This should be in meson cross file as 'growing_stack' property; and more, look at get_cross_property
486 + #case ${CHOST} in
487 + #hppa*|metag*) export glib_cv_stack_grows=yes ;;
488 + #*) export glib_cv_stack_grows=no ;;
489 + #esac
490 + #fi
491 +
492 + local emesonargs=(
493 + -Ddefault_library=$(usex static-libs both shared)
494 + $(meson_feature selinux)
495 + $(meson_use xattr)
496 + -Dlibmount=true # only used if host_system == 'linux'
497 + -Dinternal_pcre=false
498 + -Dman=true
499 + $(meson_use systemtap dtrace)
500 + $(meson_use systemtap)
501 + -Dgtk_doc=$(multilib_native_usex gtk-doc true false)
502 + $(meson_use fam)
503 + -Dinstalled_tests=false
504 + -Dnls=enabled
505 + )
506 + meson_src_configure
507 +}
508 +
509 +multilib_src_compile() {
510 + meson_src_compile
511 +}
512 +
513 +multilib_src_test() {
514 + export XDG_CONFIG_DIRS=/etc/xdg
515 + export XDG_DATA_DIRS=/usr/local/share:/usr/share
516 + export G_DBUS_COOKIE_SHA1_KEYRING_DIR="${T}/temp"
517 + export LC_TIME=C # bug #411967
518 + unset GSETTINGS_BACKEND # bug #596380
519 + python_setup
520 +
521 + # Related test is a bit nitpicking
522 + mkdir "$G_DBUS_COOKIE_SHA1_KEYRING_DIR"
523 + chmod 0700 "$G_DBUS_COOKIE_SHA1_KEYRING_DIR"
524 +
525 + meson_src_test --timeout-multiplier 2 --no-suite flaky
526 +}
527 +
528 +multilib_src_install() {
529 + meson_src_install
530 + keepdir /usr/$(get_libdir)/gio/modules
531 +}
532 +
533 +multilib_src_install_all() {
534 + einstalldocs
535 +
536 + # These are installed by dev-util/glib-utils
537 + # TODO: With patching we might be able to get rid of the python-any deps and removals, and test depend on glib-utils instead; revisit now with meson
538 + rm "${ED}/usr/bin/glib-genmarshal" || die
539 + rm "${ED}/usr/share/man/man1/glib-genmarshal.1" || die
540 + rm "${ED}/usr/bin/glib-mkenums" || die
541 + rm "${ED}/usr/share/man/man1/glib-mkenums.1" || die
542 + rm "${ED}/usr/bin/gtester-report" || die
543 + rm "${ED}/usr/share/man/man1/gtester-report.1" || die
544 + # gdbus-codegen manpage installed by dev-util/gdbus-codegen
545 + rm "${ED}/usr/share/man/man1/gdbus-codegen.1" || die
546 +}
547 +
548 +pkg_preinst() {
549 + xdg_pkg_preinst
550 +
551 + # Make gschemas.compiled belong to glib alone
552 + local cache="/usr/share/glib-2.0/schemas/gschemas.compiled"
553 +
554 + if [[ -e ${EROOT}${cache} ]]; then
555 + cp "${EROOT}"${cache} "${ED}"/${cache} || die
556 + else
557 + touch "${ED}"${cache} || die
558 + fi
559 +
560 + multilib_pkg_preinst() {
561 + # Make giomodule.cache belong to glib alone
562 + local cache="/usr/$(get_libdir)/gio/modules/giomodule.cache"
563 +
564 + if [[ -e ${EROOT}${cache} ]]; then
565 + cp "${EROOT}"${cache} "${ED}"${cache} || die
566 + else
567 + touch "${ED}"${cache} || die
568 + fi
569 + }
570 +
571 + # Don't run the cache ownership when cross-compiling, as it would end up with an empty cache
572 + # file due to inability to create it and GIO might not look at any of the modules there
573 + if ! tc-is-cross-compiler ; then
574 + multilib_foreach_abi multilib_pkg_preinst
575 + fi
576 +}
577 +
578 +pkg_postinst() {
579 + xdg_pkg_postinst
580 + # glib installs no schemas itself, but we force update for fresh install in case
581 + # something has dropped in a schemas file without direct glib dep; and for upgrades
582 + # in case the compiled schema format could have changed
583 + gnome2_schemas_update
584 +
585 + multilib_pkg_postinst() {
586 + gnome2_giomodule_cache_update \
587 + || die "Update GIO modules cache failed (for ${ABI})"
588 + }
589 + if ! tc-is-cross-compiler ; then
590 + multilib_foreach_abi multilib_pkg_postinst
591 + else
592 + ewarn "Updating of GIO modules cache skipped due to cross-compilation."
593 + ewarn "You might want to run gio-querymodules manually on the target for"
594 + ewarn "your final image for performance reasons and re-run it when packages"
595 + ewarn "installing GIO modules get upgraded or added to the image."
596 + fi
597 +}
598 +
599 +pkg_postrm() {
600 + xdg_pkg_postrm
601 + gnome2_schemas_update
602 +
603 + if [[ -z ${REPLACED_BY_VERSION} ]]; then
604 + multilib_pkg_postrm() {
605 + rm -f "${EROOT}"/usr/$(get_libdir)/gio/modules/giomodule.cache
606 + }
607 + multilib_foreach_abi multilib_pkg_postrm
608 + rm -f "${EROOT}"/usr/share/glib-2.0/schemas/gschemas.compiled
609 + fi
610 +}