Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-libs/glib/files/, dev-libs/glib/
Date: Tue, 01 Nov 2022 22:10:30
Message-Id: 1667340600.92e1c534401aa14856d4f4e0887934bd24882d8c.sam@gentoo
1 commit: 92e1c534401aa14856d4f4e0887934bd24882d8c
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Tue Nov 1 22:10:00 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Tue Nov 1 22:10:00 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=92e1c534
7
8 dev-libs/glib: backport gnome-keyring CPU peg fix
9
10 Bug: https://bugs.gentoo.org/878995
11 Bug: https://bugs.gentoo.org/878351
12 Signed-off-by: Sam James <sam <AT> gentoo.org>
13
14 .../glib/files/glib-2.74.1-gnome-keyring-cpu.patch | 131 ++++++++++
15 dev-libs/glib/glib-2.74.1-r1.ebuild | 288 +++++++++++++++++++++
16 2 files changed, 419 insertions(+)
17
18 diff --git a/dev-libs/glib/files/glib-2.74.1-gnome-keyring-cpu.patch b/dev-libs/glib/files/glib-2.74.1-gnome-keyring-cpu.patch
19 new file mode 100644
20 index 000000000000..8cb07a2803f3
21 --- /dev/null
22 +++ b/dev-libs/glib/files/glib-2.74.1-gnome-keyring-cpu.patch
23 @@ -0,0 +1,131 @@
24 +https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3029
25 +https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3039 (backport PR we've used)
26 +https://bugs.gentoo.org/878995
27 +https://bugs.gentoo.org/878351
28 +
29 +From e2f283d7c8c5ab3aeb2f281a27ec7c0f24b86868 Mon Sep 17 00:00:00 2001
30 +From: Ray Strode <rstrode@××××××.com>
31 +Date: Fri, 28 Oct 2022 11:21:04 -0400
32 +Subject: [PATCH 1/2] Revert "Handling collision between standard i/o file
33 + descriptors and newly created ones"
34 +
35 +g_unix_open_pipe tries to avoid the standard io fd range
36 +when getting pipe fds. This turns out to be a bad idea because
37 +certain buggy programs rely on it using that range.
38 +
39 +This reverts commit d9ba6150909818beb05573f54f26232063492c5b
40 +--- a/glib/glib-unix.c
41 ++++ b/glib/glib-unix.c
42 +@@ -108,17 +108,6 @@ g_unix_open_pipe (int *fds,
43 + ecode = pipe2 (fds, pipe2_flags);
44 + if (ecode == -1 && errno != ENOSYS)
45 + return g_unix_set_error_from_errno (error, errno);
46 +- /* Don't reassign pipes to stdin, stdout, stderr if closed meanwhile */
47 +- else if (fds[0] < 3 || fds[1] < 3)
48 +- {
49 +- int old_fds[2] = { fds[0], fds[1] };
50 +- gboolean result = g_unix_open_pipe (fds, flags, error);
51 +- close (old_fds[0]);
52 +- close (old_fds[1]);
53 +-
54 +- if (!result)
55 +- g_unix_set_error_from_errno (error, errno);
56 +- }
57 + else if (ecode == 0)
58 + return TRUE;
59 + /* Fall through on -ENOSYS, we must be running on an old kernel */
60 +@@ -127,19 +116,6 @@ g_unix_open_pipe (int *fds,
61 + ecode = pipe (fds);
62 + if (ecode == -1)
63 + return g_unix_set_error_from_errno (error, errno);
64 +- /* Don't reassign pipes to stdin, stdout, stderr if closed meanwhile */
65 +- else if (fds[0] < 3 || fds[1] < 3)
66 +- {
67 +- int old_fds[2] = { fds[0], fds[1] };
68 +- gboolean result = g_unix_open_pipe (fds, flags, error);
69 +- close (old_fds[0]);
70 +- close (old_fds[1]);
71 +-
72 +- if (!result)
73 +- g_unix_set_error_from_errno (error, errno);
74 +-
75 +- return result;
76 +- }
77 +
78 + if (flags == 0)
79 + return TRUE;
80 +GitLab
81 +From 4526620d8c485f5dfba6ddca33f91670982f82eb Mon Sep 17 00:00:00 2001
82 +From: Ray Strode <rstrode@××××××.com>
83 +Date: Mon, 31 Oct 2022 09:17:55 -0400
84 +Subject: [PATCH 2/2] glib-unix: Add test to make sure g_unix_open_pipe will
85 + intrude standard range
86 +
87 +Now that we know it's a bad idea to avoid the standard io fd range
88 +when getting pipe fds for g_unix_open_pipe, we should test to make sure
89 +we don't inadvertently try to do it again.
90 +
91 +This commit adds that test.
92 +--- a/glib/tests/unix.c
93 ++++ b/glib/tests/unix.c
94 +@@ -24,8 +24,11 @@
95 + #include "config.h"
96 +
97 + #include "glib-unix.h"
98 ++#include "gstdio.h"
99 ++
100 + #include <string.h>
101 + #include <pwd.h>
102 ++#include <unistd.h>
103 +
104 + static void
105 + test_pipe (void)
106 +@@ -52,6 +55,39 @@ test_pipe (void)
107 + g_assert (g_str_has_prefix (buf, "hello"));
108 + }
109 +
110 ++static void
111 ++test_pipe_stdio_overwrite (void)
112 ++{
113 ++ GError *error = NULL;
114 ++ int pipefd[2], ret;
115 ++ gboolean res;
116 ++ int stdin_fd;
117 ++
118 ++ stdin_fd = dup (STDIN_FILENO);
119 ++ g_assert_cmpint (stdin_fd, >, 0);
120 ++
121 ++ g_close (STDIN_FILENO, &error);
122 ++ g_assert_no_error (error);
123 ++
124 ++ res = g_unix_open_pipe (pipefd, FD_CLOEXEC, &error);
125 ++ g_assert_no_error (error);
126 ++ g_assert_true (res);
127 ++
128 ++ g_assert_cmpint (pipefd[0], ==, STDIN_FILENO);
129 ++
130 ++ g_close (pipefd[0], &error);
131 ++ g_assert_no_error (error);
132 ++
133 ++ g_close (pipefd[1], &error);
134 ++ g_assert_no_error (error);
135 ++
136 ++ ret = dup2 (stdin_fd, STDIN_FILENO);
137 ++ g_assert_cmpint (ret, >=, 0);
138 ++
139 ++ g_close (stdin_fd, &error);
140 ++ g_assert_no_error (error);
141 ++}
142 ++
143 + static void
144 + test_error (void)
145 + {
146 +@@ -337,6 +373,7 @@ main (int argc,
147 + g_test_init (&argc, &argv, NULL);
148 +
149 + g_test_add_func ("/glib-unix/pipe", test_pipe);
150 ++ g_test_add_func ("/glib-unix/pipe-stdio-overwrite", test_pipe_stdio_overwrite);
151 + g_test_add_func ("/glib-unix/error", test_error);
152 + g_test_add_func ("/glib-unix/nonblocking", test_nonblocking);
153 + g_test_add_func ("/glib-unix/sighup", test_sighup);
154 +GitLab
155
156 diff --git a/dev-libs/glib/glib-2.74.1-r1.ebuild b/dev-libs/glib/glib-2.74.1-r1.ebuild
157 new file mode 100644
158 index 000000000000..11e0a8149c3b
159 --- /dev/null
160 +++ b/dev-libs/glib/glib-2.74.1-r1.ebuild
161 @@ -0,0 +1,288 @@
162 +# Copyright 1999-2022 Gentoo Authors
163 +# Distributed under the terms of the GNU General Public License v2
164 +
165 +EAPI=8
166 +PYTHON_REQ_USE="xml(+)"
167 +PYTHON_COMPAT=( python3_{8..11} )
168 +
169 +inherit flag-o-matic gnome.org gnome2-utils linux-info meson-multilib multilib python-any-r1 toolchain-funcs xdg
170 +
171 +DESCRIPTION="The GLib library of C routines"
172 +HOMEPAGE="https://www.gtk.org/"
173 +
174 +LICENSE="LGPL-2.1+"
175 +SLOT="2"
176 +IUSE="dbus debug +elf gtk-doc +mime selinux static-libs sysprof systemtap test utils xattr"
177 +RESTRICT="!test? ( test )"
178 +#REQUIRED_USE="gtk-doc? ( test )" # Bug #777636
179 +
180 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux"
181 +
182 +# * elfutils (via libelf) does not build on Windows. gresources are not embedded
183 +# within ELF binaries on that platform anyway and inspecting ELF binaries from
184 +# other platforms is not that useful so exclude the dependency in this case.
185 +# * Technically static-libs is needed on zlib, util-linux and perhaps more, but
186 +# these are used by GIO, which glib[static-libs] consumers don't really seem
187 +# to need at all, thus not imposing the deps for now and once some consumers
188 +# are actually found to static link libgio-2.0.a, we can revisit and either add
189 +# them or just put the (build) deps in that rare consumer instead of recursive
190 +# RDEPEND here (due to lack of recursive DEPEND).
191 +RDEPEND="
192 + !<dev-util/gdbus-codegen-${PV}
193 + >=virtual/libiconv-0-r1[${MULTILIB_USEDEP}]
194 + >=dev-libs/libpcre2-10.32:0=[${MULTILIB_USEDEP},static-libs?]
195 + >=dev-libs/libffi-3.0.13-r1:=[${MULTILIB_USEDEP}]
196 + >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}]
197 + >=virtual/libintl-0-r2[${MULTILIB_USEDEP}]
198 + kernel_linux? ( >=sys-apps/util-linux-2.23[${MULTILIB_USEDEP}] )
199 + selinux? ( >=sys-libs/libselinux-2.2.2-r5[${MULTILIB_USEDEP}] )
200 + xattr? ( !elibc_glibc? ( >=sys-apps/attr-2.4.47-r1[${MULTILIB_USEDEP}] ) )
201 + elf? ( virtual/libelf:0= )
202 + sysprof? ( >=dev-util/sysprof-capture-3.40.1:4[${MULTILIB_USEDEP}] )
203 +"
204 +DEPEND="${RDEPEND}"
205 +# libxml2 used for optional tests that get automatically skipped
206 +BDEPEND="
207 + app-text/docbook-xsl-stylesheets
208 + dev-libs/libxslt
209 + >=sys-devel/gettext-0.19.8
210 + gtk-doc? ( >=dev-util/gtk-doc-1.33
211 + app-text/docbook-xml-dtd:4.2
212 + app-text/docbook-xml-dtd:4.5 )
213 + systemtap? ( >=dev-util/systemtap-1.3 )
214 + ${PYTHON_DEPS}
215 + test? ( >=sys-apps/dbus-1.2.14 )
216 + virtual/pkgconfig
217 +"
218 +# TODO: >=dev-util/gdbus-codegen-${PV} test dep once we modify gio/tests/meson.build to use external gdbus-codegen
219 +
220 +PDEPEND="
221 + dbus? ( gnome-base/dconf )
222 + mime? ( x11-misc/shared-mime-info )
223 +"
224 +# shared-mime-info needed for gio/xdgmime, bug #409481
225 +# dconf is needed to be able to save settings, bug #498436
226 +
227 +MULTILIB_CHOST_TOOLS=(
228 + /usr/bin/gio-querymodules$(get_exeext)
229 +)
230 +
231 +PATCHES=(
232 + "${FILESDIR}"/${PN}-2.74.0-crash-gparamspec.patch
233 + "${FILESDIR}"/${P}-gnome-keyring-cpu.patch
234 +)
235 +
236 +pkg_setup() {
237 + if use kernel_linux ; then
238 + CONFIG_CHECK="~INOTIFY_USER"
239 + if use test ; then
240 + CONFIG_CHECK="~IPV6"
241 + WARNING_IPV6="Your kernel needs IPV6 support for running some tests, skipping them."
242 + fi
243 + linux-info_pkg_setup
244 + fi
245 + python-any-r1_pkg_setup
246 +}
247 +
248 +src_prepare() {
249 + if use test; then
250 + # TODO: Review the test exclusions, especially now with meson
251 + # Disable tests requiring dev-util/desktop-file-utils when not installed, bug #286629, upstream bug #629163
252 + if ! has_version dev-util/desktop-file-utils ; then
253 + ewarn "Some tests will be skipped due dev-util/desktop-file-utils not being present on your system,"
254 + ewarn "think on installing it to get these tests run."
255 + sed -i -e "/appinfo\/associations/d" gio/tests/appinfo.c || die
256 + sed -i -e "/g_test_add_func/d" gio/tests/desktop-app-info.c || die
257 + fi
258 +
259 + # gdesktopappinfo requires existing terminal (gnome-terminal or any
260 + # other), falling back to xterm if one doesn't exist
261 + #if ! has_version x11-terms/xterm && ! has_version x11-terms/gnome-terminal ; then
262 + # ewarn "Some tests will be skipped due to missing terminal program"
263 + # These tests seem to sometimes fail even with a terminal; skip for now and reevulate with meson
264 + # 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
265 + sed -i -e "/appinfo\/launch/d" gio/tests/appinfo.c || die
266 + # desktop-app-info/launch* might fail similarly
267 + sed -i -e "/desktop-app-info\/launch-as-manager/d" gio/tests/desktop-app-info.c || die
268 + #fi
269 +
270 + # https://bugzilla.gnome.org/show_bug.cgi?id=722604
271 + sed -i -e "/timer\/stop/d" glib/tests/timer.c || die
272 + sed -i -e "/timer\/basic/d" glib/tests/timer.c || die
273 +
274 + ewarn "Tests for search-utils have been skipped"
275 + sed -i -e "/search-utils/d" glib/tests/meson.build || die
276 +
277 + # Play nice with network-sandbox, but this approach would defeat the purpose of the test
278 + #sed -i -e "s/localhost/127.0.0.1/g" gio/tests/gsocketclient-slow.c || die
279 + else
280 + # Don't build tests, also prevents extra deps, bug #512022
281 + sed -i -e '/subdir.*tests/d' {.,gio,glib}/meson.build || die
282 + fi
283 +
284 + # Don't build fuzzing binaries - not used
285 + sed -i -e '/subdir.*fuzzing/d' meson.build || die
286 +
287 + # gdbus-codegen is a separate package
288 + sed -i -e '/install_dir/d' gio/gdbus-2.0/codegen/meson.build || die
289 +
290 + # Same kind of meson-0.50 issue with some installed-tests files; will likely be fixed upstream soon
291 + sed -i -e '/install_dir/d' gio/tests/meson.build || die
292 +
293 + cat > "${T}/glib-test-ld-wrapper" <<-EOF
294 + #!/usr/bin/env sh
295 + exec \${LD:-ld} "\$@"
296 + EOF
297 + chmod a+x "${T}/glib-test-ld-wrapper" || die
298 + sed -i -e "s|'ld'|'${T}/glib-test-ld-wrapper'|g" gio/tests/meson.build || die
299 +
300 + default
301 + gnome2_environment_reset
302 + # TODO: python_name sedding for correct python shebang? Might be relevant mainly for glib-utils only
303 +}
304 +
305 +multilib_src_configure() {
306 + if use debug; then
307 + append-cflags -DG_ENABLE_DEBUG
308 + else
309 + append-cflags -DG_DISABLE_CAST_CHECKS # https://gitlab.gnome.org/GNOME/glib/issues/1833
310 + fi
311 +
312 + # TODO: figure a way to pass appropriate values for all cross properties that glib uses (search for get_cross_property)
313 + #if tc-is-cross-compiler ; then
314 + # https://bugzilla.gnome.org/show_bug.cgi?id=756473
315 + # TODO-meson: This should be in meson cross file as 'growing_stack' property; and more, look at get_cross_property
316 + #case ${CHOST} in
317 + #hppa*|metag*) export glib_cv_stack_grows=yes ;;
318 + #*) export glib_cv_stack_grows=no ;;
319 + #esac
320 + #fi
321 +
322 + local emesonargs=(
323 + -Ddefault_library=$(usex static-libs both shared)
324 + $(meson_feature selinux)
325 + $(meson_use xattr)
326 + -Dlibmount=enabled # only used if host_system == 'linux'
327 + -Dman=true
328 + $(meson_use systemtap dtrace)
329 + $(meson_use systemtap)
330 + $(meson_feature sysprof)
331 + $(meson_native_use_bool gtk-doc gtk_doc)
332 + $(meson_use test tests)
333 + -Dinstalled_tests=false
334 + -Dnls=enabled
335 + -Doss_fuzz=disabled
336 + $(meson_native_use_feature elf libelf)
337 + -Dmultiarch=false
338 + )
339 + meson_src_configure
340 +}
341 +
342 +multilib_src_test() {
343 + export XDG_CONFIG_DIRS=/etc/xdg
344 + export XDG_DATA_DIRS=/usr/local/share:/usr/share
345 + export G_DBUS_COOKIE_SHA1_KEYRING_DIR="${T}/temp"
346 + export LC_TIME=C # bug #411967
347 + export TZ=UTC
348 + unset GSETTINGS_BACKEND # bug #596380
349 + python_setup
350 +
351 + # https://bugs.gentoo.org/839807
352 + local -x SANDBOX_PREDICT=${SANDBOX_PREDICT}
353 + addpredict /usr/b
354 +
355 + # Related test is a bit nitpicking
356 + mkdir "$G_DBUS_COOKIE_SHA1_KEYRING_DIR"
357 + chmod 0700 "$G_DBUS_COOKIE_SHA1_KEYRING_DIR"
358 +
359 + meson_src_test --timeout-multiplier 2 --no-suite flaky
360 +}
361 +
362 +multilib_src_install() {
363 + meson_src_install
364 + keepdir /usr/$(get_libdir)/gio/modules
365 +}
366 +
367 +multilib_src_install_all() {
368 + # These are installed by dev-util/glib-utils
369 + # 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
370 + rm "${ED}/usr/bin/glib-genmarshal" || die
371 + rm "${ED}/usr/share/man/man1/glib-genmarshal.1" || die
372 + rm "${ED}/usr/bin/glib-mkenums" || die
373 + rm "${ED}/usr/share/man/man1/glib-mkenums.1" || die
374 + rm "${ED}/usr/bin/gtester-report" || die
375 + rm "${ED}/usr/share/man/man1/gtester-report.1" || die
376 + # gdbus-codegen manpage installed by dev-util/gdbus-codegen
377 + rm "${ED}/usr/share/man/man1/gdbus-codegen.1" || die
378 +}
379 +
380 +pkg_preinst() {
381 + xdg_pkg_preinst
382 +
383 + # Make gschemas.compiled belong to glib alone
384 + local cache="/usr/share/glib-2.0/schemas/gschemas.compiled"
385 +
386 + if [[ -e ${EROOT}${cache} ]]; then
387 + cp "${EROOT}"${cache} "${ED}"/${cache} || die
388 + else
389 + touch "${ED}"${cache} || die
390 + fi
391 +
392 + multilib_pkg_preinst() {
393 + # Make giomodule.cache belong to glib alone
394 + local cache="/usr/$(get_libdir)/gio/modules/giomodule.cache"
395 +
396 + if [[ -e ${EROOT}${cache} ]]; then
397 + cp "${EROOT}"${cache} "${ED}"${cache} || die
398 + else
399 + touch "${ED}"${cache} || die
400 + fi
401 + }
402 +
403 + # Don't run the cache ownership when cross-compiling, as it would end up with an empty cache
404 + # file due to inability to create it and GIO might not look at any of the modules there
405 + if ! tc-is-cross-compiler ; then
406 + multilib_foreach_abi multilib_pkg_preinst
407 + fi
408 +}
409 +
410 +pkg_postinst() {
411 + xdg_pkg_postinst
412 + # glib installs no schemas itself, but we force update for fresh install in case
413 + # something has dropped in a schemas file without direct glib dep; and for upgrades
414 + # in case the compiled schema format could have changed
415 + gnome2_schemas_update
416 +
417 + multilib_pkg_postinst() {
418 + gnome2_giomodule_cache_update \
419 + || die "Update GIO modules cache failed (for ${ABI})"
420 + }
421 + if ! tc-is-cross-compiler ; then
422 + multilib_foreach_abi multilib_pkg_postinst
423 + else
424 + ewarn "Updating of GIO modules cache skipped due to cross-compilation."
425 + ewarn "You might want to run gio-querymodules manually on the target for"
426 + ewarn "your final image for performance reasons and re-run it when packages"
427 + ewarn "installing GIO modules get upgraded or added to the image."
428 + fi
429 +
430 + for v in ${REPLACING_VERSIONS}; do
431 + if ver_test "$v" "-lt" "2.63.6"; then
432 + ewarn "glib no longer installs the gio-launch-desktop binary. You may need"
433 + ewarn "to restart your session for \"Open With\" dialogs to work."
434 + fi
435 + done
436 +}
437 +
438 +pkg_postrm() {
439 + xdg_pkg_postrm
440 + gnome2_schemas_update
441 +
442 + if [[ -z ${REPLACED_BY_VERSION} ]]; then
443 + multilib_pkg_postrm() {
444 + rm -f "${EROOT}"/usr/$(get_libdir)/gio/modules/giomodule.cache
445 + }
446 + multilib_foreach_abi multilib_pkg_postrm
447 + rm -f "${EROOT}"/usr/share/glib-2.0/schemas/gschemas.compiled
448 + fi
449 +}