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
This commit is contained in:
Kalev Lember 2020-04-02 15:28:37 +02:00
parent 91191189b8
commit c8bb8c385d
2 changed files with 33 additions and 0 deletions

View File

@ -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

25
start-dconf-editor.sh Normal file
View File

@ -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 "$@"