From patchwork Thu Jan 23 06:28:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "King, Spencer via Guix-patches\" via" X-Patchwork-Id: 37613 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 5D97B27BBE9; Thu, 23 Jan 2025 06:26:53 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 856C027BBE2 for ; Thu, 23 Jan 2025 06:26:50 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1taqfG-00079l-Hu; Thu, 23 Jan 2025 01:26:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1taqfD-00079O-VL for guix-patches@gnu.org; Thu, 23 Jan 2025 01:26:04 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1taqfD-0002d9-Md for guix-patches@gnu.org; Thu, 23 Jan 2025 01:26:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:In-Reply-To:References:Subject; bh=QFNSsGI4Gyi8bL0h5r+aVnoD9AEJ9qZBOp2tTDFpHk4=; b=rQdU2Stpp2Hlj9Ovc18hRSP2uW1s7lOtWczktMfKxLKBMhLzH8FhsJH7rW5+1pSGT+dt14dRzcgg2g+4qyaYItAoLwlnc4F/a0W11bFkX4vJtKcPhefdPUC387ua8+zGturZVqe5B5MhX+njzS8G5pXrQEzX1PjLR4bAXMKZ6t9Jh/BHO3MWqh93RjgaZHQOyHEgoa0C0fRiFQNcDjYblbTrgp9zIwJk7X6ECVXy2sA+8BdLHggtZ5xNG6AFkP/3fPIZUGFS9HdsjAyxfX18eCOdLMnoMruFZyoWUTbJja9bLyMcuN/sJgOuFcIVZruvXRHymlzTYBLdZgThpsd/JQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1taqfB-0007TH-M0; Thu, 23 Jan 2025 01:26:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#75688] [PATCH v2 1/4] gnu: glib: Support load search paths from etc/search-paths.d files. References: In-Reply-To: Resent-From: iyzsong@envs.net Original-Sender: "Debbugs-submit" Resent-CC: liliana.prikler@gmail.com, maxim.cournoyer@gmail.com, vivien@planete-kraus.eu, guix-patches@gnu.org Resent-Date: Thu, 23 Jan 2025 06:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75688 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 75688@debbugs.gnu.org Cc: =?utf-8?b?5a6L5paH5q2m?= , Liliana Marie Prikler , Maxim Cournoyer , Vivien Kraus X-Debbugs-Original-Xcc: Liliana Marie Prikler , Maxim Cournoyer , Vivien Kraus Received: via spool by 75688-submit@debbugs.gnu.org id=B75688.173761355828708 (code B ref 75688); Thu, 23 Jan 2025 06:26:01 +0000 Received: (at 75688) by debbugs.gnu.org; 23 Jan 2025 06:25:58 +0000 Received: from localhost ([127.0.0.1]:38730 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1taqf7-0007Sx-QA for submit@debbugs.gnu.org; Thu, 23 Jan 2025 01:25:58 -0500 Received: from mail.envs.net ([5.199.136.28]:58298) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1taqf4-0007Sa-5C for 75688@debbugs.gnu.org; Thu, 23 Jan 2025 01:25:55 -0500 Received: from localhost (mail.envs.net [127.0.0.1]) by mail.envs.net (Postfix) with ESMTP id D3AD038A3E4C; Thu, 23 Jan 2025 06:25:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=envs.net; s=modoboa; t=1737613551; bh=QFNSsGI4Gyi8bL0h5r+aVnoD9AEJ9qZBOp2tTDFpHk4=; h=From:To:Cc:Subject:Date:From; b=TKnGVNB3tuVHUhhHR3sXl1oQVW/g1aR8A3krFaqQv5S89Nczhx33YWRujupBghumm oj45xkX2IUKh+AI2YoZpDppHQV+DXDrKHzrCNHD/zN62Q17JitIV6Q+LjyiUF+ohnN 3P22cFlbD5uHcIfjHjYyjIsBnPKAU/4XYXNyOzeqei/JIchpCW+jezFTvaxy4qClVu E3hXvEf1AZBUMoY6R34a4wi7DTT19ZR+BzV/JBOWVxzYJIFLxy+9iNIGg+448fcmHb Lo02AVekcdqzB5zRVyElPR5K1Q2WmsE+X97u6dl4KtFZ/AdiqT32qc2944RKFpA2wr r7sYvRyQy4r3rjtbZab20LNBBTqD7755PJJZEIRno8BdzJhKMD1cPpXht3U2SCVRPV 4unkGJQW1cJGqjabjd/PiWVI7uQ8NQLccsUZDMljxAHiROLBjAYOPcT3JHxzmnWQC9 hlcXiXk+R7SDNrlxMi5cHa0UT6GHZpVvWgPH4eKPoWJnmIDK6lEVnQVxqCQnhO/tr4 w1jTN6B8mtPgmTfdPVrCm/fumKqXrD3JaKu172+O/eJ6rFQdHzafnCDSjEjUhS23aM cdCgOw15OxynEbNgD00/YbzcYUfDrlWSta98Mx4yzN8JBFF8olGVRByYXZrHL9Hd9e ay38bDw2pelbvyDWm66FfLvA= X-Virus-Scanned: Debian amavisd-new at mail.envs.net Received: from mail.envs.net ([127.0.0.1]) by localhost (mail.envs.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 6QagBnzDIC0r; Thu, 23 Jan 2025 06:25:48 +0000 (UTC) Received: from localhost (unknown [112.44.100.254]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.envs.net (Postfix) with ESMTPSA; Thu, 23 Jan 2025 06:25:48 +0000 (UTC) Received: from localhost.localdomain (localhost.lan [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id e7e2719b; Thu, 23 Jan 2025 06:29:10 +0000 (UTC) Date: Thu, 23 Jan 2025 14:28:55 +0800 Message-ID: <916f2d3087c47d6212682656f47a2899ba795df1.1737613671.git.iyzsong@member.fsf.org> X-Mailer: git-send-email 2.47.1 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: iyzsong@envs.net X-ACL-Warn: , iyzsong--- via Guix-patches X-Patchwork-Original-From: iyzsong--- via Guix-patches via From: "King, Spencer via Guix-patches\" via" Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches From: 宋文武 Add a new function "g_build_guix_search_path_dirs" to GLIB, which in addition to environment variable, read search path values from etc/search-paths.d directory of the current executable. This can be used to replace wrapper scripts. Use it for GUIX_GSETTINGS_SCHEMA_DIR, GUIX_GIO_EXTRA_MODULES, GUIX_XDG_DATA_DIRS and GUIX_XDG_CONFIG_DIRS. * gnu/packages/patches/glib-guix-search-paths.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it. * gnu/packages/glib.scm (glib)[source]: Add patch. [native-search-paths]: Add GUIX_GSETTINGS_SCHEMA_DIR, Replace GIO_EXTRA_MODULES with GUIX_GIO_EXTRA_MODULES. Change-Id: I1d6d113fc38b20ebd4dce195f6d9c58ce85967e4 --- gnu/local.mk | 1 + gnu/packages/glib.scm | 9 +- .../patches/glib-guix-search-paths.patch | 158 ++++++++++++++++++ 3 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 gnu/packages/patches/glib-guix-search-paths.patch base-commit: 7080aaf08102ec4c9c976582d6adfa0c14e6c640 diff --git a/gnu/local.mk b/gnu/local.mk index 5091f93eb8..6bb3a35770 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1436,6 +1436,7 @@ dist_patch_DATA = \ %D%/packages/patches/git-filter-repo-generate-doc.patch \ %D%/packages/patches/gklib-suitesparse.patch \ %D%/packages/patches/glib-appinfo-watch.patch \ + %D%/packages/patches/glib-guix-search-paths.patch \ %D%/packages/patches/glib-skip-failing-test.patch \ %D%/packages/patches/glibc-2.33-riscv64-miscompilation.patch \ %D%/packages/patches/glibc-2.39-git-updates.patch \ diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm index e04eedb7ba..0704ba2c53 100644 --- a/gnu/packages/glib.scm +++ b/gnu/packages/glib.scm @@ -258,7 +258,8 @@ (define glib (base32 "0c3vagxl77wma85qinbj974jvw96n5bvch2m7hqcwxq8fa5spsj4")) (patches (search-patches "glib-appinfo-watch.patch" - "glib-skip-failing-test.patch")) + "glib-skip-failing-test.patch" + "glib-guix-search-paths.patch")) (modules '((guix build utils))) (snippet '(begin @@ -516,9 +517,13 @@ (define glib (search-path-specification (variable "XDG_DATA_DIRS") (files '("share"))) + ;; To load gsettings schemas from GTK, etc. + (search-path-specification + (variable "GUIX_GSETTINGS_SCHEMA_DIR") + (files '("share/glib-2.0/schemas"))) ;; To load extra gio modules from glib-networking, etc. (search-path-specification - (variable "GIO_EXTRA_MODULES") + (variable "GUIX_GIO_EXTRA_MODULES") (files '("lib/gio/modules"))))) (search-paths native-search-paths) (synopsis "Low-level core library for GNOME projects") diff --git a/gnu/packages/patches/glib-guix-search-paths.patch b/gnu/packages/patches/glib-guix-search-paths.patch new file mode 100644 index 0000000000..ebd57024dd --- /dev/null +++ b/gnu/packages/patches/glib-guix-search-paths.patch @@ -0,0 +1,158 @@ +diff --git a/gio/giomodule.c b/gio/giomodule.c +index 76c2028..49b02bb 100644 +--- a/gio/giomodule.c ++++ b/gio/giomodule.c +@@ -1330,6 +1330,13 @@ _g_io_modules_ensure_loaded (void) + g_io_modules_scan_all_in_directory_with_scope (module_dir, scope); + g_free (module_dir); + ++ /* GUIX: Load gio modules from GUIX_GIO_EXTRA_MODULES */ ++ gchar **guix_giomodule_dirs = g_build_guix_search_path_dirs ("GUIX_GIO_EXTRA_MODULES"); ++ for (int i = 0; guix_giomodule_dirs[i] != NULL; i++) { ++ g_io_modules_scan_all_in_directory_with_scope (guix_giomodule_dirs[i], scope); ++ } ++ g_strfreev (guix_giomodule_dirs); ++ + g_io_module_scope_free (scope); + + /* Initialize types from built-in "modules" */ +diff --git a/gio/gsettingsschema.c b/gio/gsettingsschema.c +index e8ccc8c..b8bae14 100644 +--- a/gio/gsettingsschema.c ++++ b/gio/gsettingsschema.c +@@ -354,6 +354,13 @@ initialise_schema_sources (void) + while (i--) + try_prepend_data_dir (dirs[i]); + ++ /* GUIX: Load schemas from GUIX_GSETTINGS_SCHEMA_DIR. */ ++ char **guix_schema_dirs = g_build_guix_search_path_dirs ("GUIX_GSETTINGS_SCHEMA_DIR"); ++ i = g_strv_length(guix_schema_dirs); ++ while (i--) ++ try_prepend_dir (guix_schema_dirs[i]); ++ g_strfreev (guix_schema_dirs); ++ + try_prepend_data_dir (g_get_user_data_dir ()); + + /* Disallow loading extra schemas if running as setuid, as that could +diff --git a/glib/gutils.c b/glib/gutils.c +index 8628a56..bc21efc 100644 +--- a/glib/gutils.c ++++ b/glib/gutils.c +@@ -2708,6 +2708,16 @@ g_build_system_data_dirs (void) + data_dir_vector = g_strsplit (data_dirs, G_SEARCHPATH_SEPARATOR_S, 0); + #endif + ++ /* GUIX: Use data files from GUIX_XDG_DATA_DIRS. */ ++ GStrvBuilder *builder = g_strv_builder_new (); ++ g_strv_builder_addv (builder, (const gchar **) data_dir_vector); ++ g_strfreev (data_dir_vector); ++ data_dir_vector = g_build_guix_search_path_dirs ("GUIX_XDG_DATA_DIRS"); ++ g_strv_builder_addv (builder, (const gchar **) data_dir_vector); ++ g_strfreev (data_dir_vector); ++ data_dir_vector = g_strv_builder_end (builder); ++ g_strv_builder_unref (builder); ++ + return g_steal_pointer (&data_dir_vector); + } + +@@ -2800,6 +2810,16 @@ g_build_system_config_dirs (void) + conf_dir_vector = g_strsplit (conf_dirs, G_SEARCHPATH_SEPARATOR_S, 0); + #endif + ++ /* GUIX: Use config files from GUIX_XDG_CONFIG_DIRS. */ ++ GStrvBuilder *builder = g_strv_builder_new (); ++ g_strv_builder_addv (builder, (const gchar **) conf_dir_vector); ++ g_strfreev (conf_dir_vector); ++ conf_dir_vector = g_build_guix_search_path_dirs ("GUIX_XDG_CONFIG_DIRS"); ++ g_strv_builder_addv (builder, (const gchar **) conf_dir_vector); ++ g_strfreev (conf_dir_vector); ++ conf_dir_vector = g_strv_builder_end (builder); ++ g_strv_builder_unref (builder); ++ + return g_steal_pointer (&conf_dir_vector); + } + +@@ -2849,6 +2869,69 @@ g_get_system_config_dirs (void) + return system_config_dirs; + } + ++gchar ** ++g_build_guix_search_path_dirs (const gchar *variable) ++{ ++ gchar **dirs = NULL; ++ char *value = NULL; ++ GStrvBuilder *builder = g_strv_builder_new (); ++ ++#if defined(__linux__) || defined(__gnu_hurd__) ++ /* First add paths from the etc/search-paths.d, which can be used to replace wrapper script. */ ++ gchar *exe_path = g_file_read_link ("/proc/self/exe", NULL); ++ gchar *out_path = NULL; ++ gchar *search_paths_d = NULL; ++ ++ /* We install executables under "bin" or "libexec", can also be a subdirectory of "libexec". */ ++ if (exe_path && (g_str_match_string("/bin/", exe_path, FALSE) || ++ g_str_match_string("/libexec/", exe_path, FALSE))) { ++ /* Find output directory, which is the parent directory of "bin" or "libexec". */ ++ out_path = g_path_get_dirname (exe_path); ++ while (g_str_match_string("/bin/", out_path, FALSE) || ++ g_str_match_string("/libexec/", out_path, FALSE)) { ++ gchar *dir_path = out_path; ++ out_path = g_path_get_dirname (dir_path); ++ g_free (dir_path); ++ } ++ ++ /* Now add paths from etc/search-paths.d/VARIABLE file. */ ++ search_paths_d = g_build_filename (out_path, "etc", "search-paths.d", NULL); ++ if (g_file_test (search_paths_d, G_FILE_TEST_EXISTS)) { ++ gchar *var_path = g_build_filename (search_paths_d, variable, NULL); ++ if (g_file_get_contents (var_path, &value, NULL, NULL)) { ++ dirs = g_strsplit (value, G_SEARCHPATH_SEPARATOR_S, 0); ++ g_strv_builder_addv (builder, (const gchar **) dirs); ++ g_strfreev (dirs); ++ g_free (value); ++ } ++ g_free (var_path); ++ } ++ } ++ ++ g_free (exe_path); ++ g_free (out_path); ++ g_free (search_paths_d); ++#endif ++ ++ /* Then add paths from the environment variable. */ ++ gboolean is_setuid = GLIB_PRIVATE_CALL (g_check_setuid) (); ++ if (is_setuid) /* we don't want to access arbitrary files when running as setuid. */ ++ value = NULL; ++ else ++ value = g_strdup (g_getenv (variable)); ++ ++ if (value && value[0]) { ++ dirs = g_strsplit (value, G_SEARCHPATH_SEPARATOR_S, 0); ++ g_strv_builder_addv (builder, (const gchar **) dirs); ++ g_strfreev (dirs); ++ } ++ g_free (value); ++ ++ dirs = g_strv_builder_end (builder); ++ g_strv_builder_unref (builder); ++ return dirs; ++} ++ + /** + * g_nullify_pointer: + * @nullify_location: (not nullable): the memory address of the pointer. +diff --git a/glib/gutils.h b/glib/gutils.h +index efc6914..710cf27 100644 +--- a/glib/gutils.h ++++ b/glib/gutils.h +@@ -36,6 +36,9 @@ + + G_BEGIN_DECLS + ++GLIB_AVAILABLE_IN_ALL ++gchar **g_build_guix_search_path_dirs (const gchar *variable); ++ + GLIB_AVAILABLE_IN_ALL + const gchar * g_get_user_name (void); + GLIB_AVAILABLE_IN_ALL