From c8bb8c385d72b1ad13d792880e84479a260c51ed Mon Sep 17 00:00:00 2001 From: Kalev Lember Date: Apr 02 2020 13:29:10 +0000 Subject: Support reading host schemas when built as flatpak https://bugzilla.redhat.com/show_bug.cgi?id=1727551 https://github.com/flathub/ca.desrt.dconf-editor/issues/3 --- diff --git a/dconf-editor.spec b/dconf-editor.spec index 0f78ae1..5b3b08c 100644 --- a/dconf-editor.spec +++ b/dconf-editor.spec @@ -10,6 +10,7 @@ Summary: Configuration editor for dconf License: GPLv3+ and CC0 URL: https://wiki.gnome.org/Projects/dconf Source0: https://download.gnome.org/sources/dconf-editor/3.36/dconf-editor-%{version}.tar.xz +Source1: https://raw.githubusercontent.com/flathub/ca.desrt.dconf-editor/master/start-dconf-editor.sh BuildRequires: /usr/bin/appstream-util BuildRequires: desktop-file-utils @@ -42,6 +43,10 @@ Graphical tool for editing the dconf configuration database. %install %meson_install +%if 0%{?flatpak} +install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_bindir}/start-dconf-editor +%endif + %find_lang dconf-editor %check @@ -51,6 +56,9 @@ desktop-file-validate $RPM_BUILD_ROOT%{_datadir}/applications/ca.desrt.dconf-edi %files -f dconf-editor.lang %license COPYING %{_bindir}/dconf-editor +%if 0%{?flatpak} +%{_bindir}/start-dconf-editor +%endif %{_datadir}/applications/ca.desrt.dconf-editor.desktop %{_datadir}/bash-completion/ %{_datadir}/dbus-1/services/ca.desrt.dconf-editor.service diff --git a/start-dconf-editor.sh b/start-dconf-editor.sh new file mode 100644 index 0000000..8b6d2f8 --- /dev/null +++ b/start-dconf-editor.sh @@ -0,0 +1,25 @@ +#!/usr/bin/bash + +IFS=: read -ra host_data_dirs < <(flatpak-spawn --host sh -c 'echo $XDG_DATA_DIRS') + +# To avoid potentially muddying up $XDG_DATA_DIRS too much, we link the schema paths +# into a temporary directory. +bridge_dir=$XDG_RUNTIME_DIR/dconf-bridge +mkdir -p "$bridge_dir" + +for dir in "${host_data_dirs[@]}"; do + if [[ "$dir" == /usr/* ]]; then + dir=/run/host/"$dir" + fi + + schemas="$dir/glib-2.0/schemas" + if [[ -d "$schemas" ]]; then + bridged=$(mktemp -d XXXXXXXXXX -p "$bridge_dir") + mkdir -p "$bridged"/glib-2.0 + ln -s "$schemas" "$bridged"/glib-2.0 + XDG_DATA_DIRS=$XDG_DATA_DIRS:"$bridged" + fi +done + +export XDG_DATA_DIRS +exec dconf-editor "$@"