[PATCH] gnu: flatpak: Pass system icons and fonts.

  • Open
  • quality assurance status badge
Details
2 participants
  • kasper.andersson
  • Zheng Junjie
Owner
unassigned
Submitted by
Zheng Junjie
Severity
normal
Z
Z
Zheng Junjie wrote on 31 Mar 08:43 +0200
(address . guix-patches@gnu.org)
54bd7d232c3a231704463801bb605b106e0757ad.1711867387.git.zhengjunjie@iscas.ac.cn
* gnu/packages/patches/flatpak-fix-fonts-icons.patch: New patch.
* gnu/packages/package-management.scm(flatpak): Use it.
* gnu/local.mk(dist_patch_DATA): Register it.

Change-Id: I0359d0d9bf10120a8b784c910c50d0e4a9b7a616
---
gnu/local.mk | 1 +
gnu/packages/package-management.scm | 4 +-
.../patches/flatpak-fix-fonts-icons.patch | 89 +++++++++++++++++++
3 files changed, 93 insertions(+), 1 deletion(-)
create mode 100644 gnu/packages/patches/flatpak-fix-fonts-icons.patch

Toggle diff (133 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index f2b480bded..2c1d794ec9 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1209,6 +1209,7 @@ dist_patch_DATA = \
%D%/packages/patches/firebird-riscv64-support-pt2.patch \
%D%/packages/patches/flann-cmake-3.11.patch \
%D%/packages/patches/flatpak-fix-path.patch \
+ %D%/packages/patches/flatpak-fix-fonts-icons.patch \
%D%/packages/patches/flatpak-unset-gdk-pixbuf-for-sandbox.patch \
%D%/packages/patches/fluxbox-1.3.7-no-dynamic-cursor.patch \
%D%/packages/patches/fluxbox-1.3.7-gcc.patch \
diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scm
index a0ede07d54..5e47f6aa1e 100644
--- a/gnu/packages/package-management.scm
+++ b/gnu/packages/package-management.scm
@@ -24,6 +24,7 @@
;;; Copyright © 2023 jgart <jgart@dismail.de>
;;; Copyright © 2023 M?d?lin Ionel Patra?cu <madalinionel.patrascu@mdc-berlin.de>
;;; Copyright © 2024 Arun Isaac <arunisaac@systemreboot.net>
+;;; Copyright © 2024 Zheng Junjie <873216071@qq.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -2019,7 +2020,8 @@ (define-public flatpak
(sha256
(base32 "16b7f7n2mms6zgm0lj3fn86ny11xjn8cd3mrk1slwhvwnv8dnd4a"))
(patches
- (search-patches "flatpak-fix-path.patch"
+ (search-patches "flatpak-fix-fonts-icons.patch"
+ "flatpak-fix-path.patch"
"flatpak-unset-gdk-pixbuf-for-sandbox.patch"))))
;; Wrap 'flatpak' so that GIO_EXTRA_MODULES is set, thereby allowing GIO to
diff --git a/gnu/packages/patches/flatpak-fix-fonts-icons.patch b/gnu/packages/patches/flatpak-fix-fonts-icons.patch
new file mode 100644
index 0000000000..5b9d855b2e
--- /dev/null
+++ b/gnu/packages/patches/flatpak-fix-fonts-icons.patch
@@ -0,0 +1,89 @@
+modify from https://github.com/NixOS/nixpkgs/pull/262462
+
+diff --git a/common/flatpak-run.c b/common/flatpak-run.c
+index 94ad013..5c9f55e 100644
+--- a/common/flatpak-run.c
++++ b/common/flatpak-run.c
+@@ -871,6 +871,49 @@ out:
+ return res;
+ }
+
++static void
++get_gnu_closure (GHashTable *closure, const gchar *source_path)
++{
++ if (g_file_test (source_path, G_FILE_TEST_IS_SYMLINK))
++ {
++ g_autofree gchar *path = g_malloc(PATH_MAX);
++ realpath(source_path, path);
++ if (g_str_has_prefix(path, "/gnu/store/"))
++ {
++ *strchr(path + strlen("/gnu/store/"), '/') = 0;
++ g_hash_table_add(closure, g_steal_pointer (&path));
++ }
++ }
++ else if (g_file_test (source_path, G_FILE_TEST_IS_DIR))
++ {
++ g_autoptr(GDir) dir = g_dir_open(source_path, 0, NULL);
++ const gchar *file_name;
++ while ((file_name = g_dir_read_name(dir)))
++ {
++ g_autofree gchar *path = g_build_filename (source_path, file_name, NULL);
++ get_gnu_closure (closure, path);
++ }
++ }
++}
++
++static void
++add_gnu_store_symlink_targets (FlatpakBwrap *bwrap, const gchar *source_path)
++{
++ GHashTable *closure = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
++
++ get_gnu_closure(closure, source_path);
++
++ GHashTableIter iter;
++ gpointer path;
++ g_hash_table_iter_init(&iter, closure);
++ while (g_hash_table_iter_next(&iter, &path, NULL))
++ {
++ flatpak_bwrap_add_args (bwrap, "--ro-bind", path, path, NULL);
++ }
++
++ g_hash_table_destroy(closure);
++}
++
+ static void
+ add_font_path_args (FlatpakBwrap *bwrap)
+ {
+@@ -898,6 +946,18 @@ add_font_path_args (FlatpakBwrap *bwrap)
+ "\t<remap-dir as-path=\"%s\">/run/host/fonts</remap-dir>\n",
+ SYSTEM_FONTS_DIR);
+ }
++ else if (g_file_test ("/run/current-system/profile/share/fonts", G_FILE_TEST_EXISTS))
++ {
++ add_gnu_store_symlink_targets (bwrap, "/run/current-system/profile/share/fonts");
++ flatpak_bwrap_add_args (bwrap,
++ "--ro-bind",
++ "/run/current-system/profile/share/fonts",
++ "/run/host/fonts",
++ NULL);
++ g_string_append_printf (xml_snippet,
++ "\t<remap-dir as-path=\"%s\">/run/host/fonts</remap-dir>\n",
++ "/run/current-system/profile/share/fonts");
++ }
+
+ if (g_file_test ("/usr/local/share/fonts", G_FILE_TEST_EXISTS))
+ {
+@@ -998,6 +1058,13 @@ add_icon_path_args (FlatpakBwrap *bwrap)
+ "--ro-bind", "/usr/share/icons", "/run/host/share/icons",
+ NULL);
+ }
++ else if (g_file_test ("/run/current-system/profile/share/icons", G_FILE_TEST_IS_DIR))
++ {
++ add_gnu_store_symlink_targets (bwrap, "/run/current-system/profile/share/icons");
++ flatpak_bwrap_add_args (bwrap,
++ "--ro-bind", "/run/current-system/profile/share/icons", "/run/host/share/icons",
++ NULL);
++ }
+
+ user_icons_path = g_build_filename (g_get_user_data_dir (), "icons", NULL);
+ user_icons = g_file_new_for_path (user_icons_path);

base-commit: f5558ee0cc1a11a8b61d3f4d43f05dd79d53ac77
--
2.41.0
K
K
kasper.andersson wrote on 28 Jun 15:15 +0200
(name . 70099)(address . 70099@debbugs.gnu.org)
O0Tz86x--3-9@tutanota.com
Tried the patch on my system, works well for me. :)
Best regards, Kasper
Attachment: file
Z
Z
Zheng Junjie wrote on 29 Jun 06:47 +0200
(name . kasper.andersson--- via Guix-patches via)(address . guix-patches@gnu.org)
87ed8giccq.fsf@iscas.ac.cn
"kasper.andersson--- via Guix-patches" via <guix-patches@gnu.org> writes:

Toggle quote (3 lines)
> Tried the patch on my system, works well for me. :)
> Best regards, Kasper

thanks, push.
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEfr6klGDOXiwIdX/bO1qpk+Gi3/AFAmZ/kfUACgkQO1qpk+Gi
3/AOsg/9GKUtUc4jUpBrIN9mfTFBZITo5lFKUB+IqDqW+GFyF9fDBsRMkDukoQEU
bofN8pHmURH4pMivV6ndZOKw2SuVpFtBpKFSWTyIC4PPq8QzKSrGYWygw+JaI7fA
qukoUbxvHMmhhYAXpXqS0acTfgLuL40RdUs5v1hpqoupDrnNUDQvwp5LCIJ1FDoJ
yyZFpqJqWzIZtigw8zL9Q4GBZq+jXrPLVvGdR5JHthID709ypPPkvvsjvy94O17o
C8gvtpHnekwXDwzu2uXCoIayG73vER85DOPO14sPxzaphUI1UkVxMXeYU9Gp/60/
bOxjMRY5rc16zr9N0yxrGW4T3jn9m7z/hyVHiRVAnK65woTmT9F/pM0Is4xbAyjl
Tgq+8ja8cPcEHZDbf0Vkp7MMrTnvkns7zeIx3GWRs1X+evOt9eyYx5hwCGzhYPxs
gmLoDv1kVC1urLwFvrmMe/NTWE0w4PlINY4xB7zegf2u5pk/Bma4bT+wo5YvCC4u
2UC8dm8KRs0iEw0h1W7ySjYKVU+IifSEju02KHZvS8R9tWsm9XtR05L76P46iY0x
y7PmThs2NwKo7TbEGv9u+cptjUHjA5o3OqHQqM4I/OP8CF5GT7gIOx5GnWZ1OdDA
xs/u1NYbSmltBvY34XTJs87nyHgKpSAtbG0Yo/5QNrT8Rk1ClKo=
=h0jH
-----END PGP SIGNATURE-----

?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 70099@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 70099
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch