libgudev: fix build on musl (#286244)

This commit is contained in:
Yureka 2024-02-04 17:40:19 +01:00 committed by GitHub
parent b79d9beb4b
commit 630c078fd5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 53 additions and 1 deletions

View File

@ -9,7 +9,6 @@
, gnome
, vala
, gobject-introspection
, fetchpatch
, glibcLocales
, umockdev
}:
@ -25,6 +24,18 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-YSZqsa/J1z28YKiyr3PpnS/f9H2ZVE0IV2Dk+mZ7XdE=";
};
patches = [
# Conditionally disable one test that requires a locale implementation
# https://gitlab.gnome.org/GNOME/libgudev/-/merge_requests/31
./tests-skip-double-test-on-stub-locale-impls.patch
];
postPatch = ''
# The relative location of LD_PRELOAD works for Glibc but not for other loaders (e.g. pkgsMusl)
substituteInPlace tests/meson.build \
--replace "LD_PRELOAD=libumockdev-preload.so.0" "LD_PRELOAD=${lib.getLib umockdev}/lib/libumockdev-preload.so.0"
'';
strictDeps = true;
nativeBuildInputs = [

View File

@ -0,0 +1,41 @@
From ad8b10870ee2092268f87144d8e5ab7db2011139 Mon Sep 17 00:00:00 2001
From: Alyssa Ross <hi@alyssa.is>
Date: Tue, 30 Jan 2024 20:47:21 +0100
Subject: [PATCH] tests: Skip double test on stub locale impls
On musl, setlocale() with an unknown locale name will succeed, but
treat the requested locale as if it were C.UTF-8. Therefore, to
properly check whether the locale is supported, we need to actually
verify whether it works the way we expect when deciding whether to
skip the test.
---
tests/test-double.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tests/test-double.c b/tests/test-double.c
index 91e77c9..e9d9232 100644
--- a/tests/test-double.c
+++ b/tests/test-double.c
@@ -39,8 +39,6 @@ fixture_teardown (Fixture *f, G_GNUC_UNUSED const void *data)
static void
test_double (Fixture *f, G_GNUC_UNUSED const void *data)
{
- g_assert_cmpstr (nl_langinfo(RADIXCHAR), ==, ",");
-
umockdev_testbed_add_device (f->testbed, "platform", "dev1", NULL,
"in_accel_scale", "0.0000098", NULL,
"ID_MODEL", "KoolGadget", "SCALE", "0.0000098", NULL);
@@ -73,6 +71,10 @@ int main(int argc, char **argv)
if (setlocale (LC_NUMERIC, "fr_FR.UTF-8") == NULL)
return GNU_SKIP_RETURNCODE;
+ /* Skip if locale doesn't work how we expect. */
+ if (strcmp (nl_langinfo(RADIXCHAR), ","))
+ return GNU_SKIP_RETURNCODE;
+
g_test_init (&argc, &argv, NULL);
g_test_add ("/gudev/double", Fixture, NULL,
--
GitLab