env.d: Port the environment generators to use --print-updated-env

This reduces the amount of shell in use, and the number of subprocesses
spawned by that, so our system environment generator is as fast as
possible when used in the critical startup path.

It adds a new system environment generator so that the system flatpak
installation can be used outside of a user session. In particular, this
allows enumeration of system-installed flatpaks in gnome-initial-setup
in order to set parental controls on them.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2020-10-21 17:10:46 +01:00 committed by Alexander Larsson
parent 9411fe2bca
commit f434508b07
4 changed files with 17 additions and 16 deletions

View File

@ -161,13 +161,16 @@ if INSTALL_GDM_ENV_FILE
env_DATA += flatpak.env
endif
EXTRA_DIST += env.d/flatpak.env.in env.d/60-flatpak
EXTRA_DIST += env.d/flatpak.env.in env.d/60-flatpak env.d/60-flatpak-system-only
DISTCLEANFILES += flatpak.env
flatpak.env: env.d/flatpak.env.in
$(AM_V_GEN) $(SED) -e "s|\@localstatedir\@|$(localstatedir)|" \
-e "s|\@sysconfdir\@|$(sysconfdir)|" $< > $@
systemenvgendir = $(systemdsystemenvgendir)
systemenvgen_SCRIPTS = env.d/60-flatpak-system-only
userenvgendir = $(systemduserenvgendir)
userenvgen_SCRIPTS = env.d/60-flatpak

View File

@ -122,6 +122,15 @@ AC_ARG_WITH([systemdsystemunitdir],
[with_systemdsystemunitdir='${prefix}/lib/systemd/system'])
AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
AC_ARG_WITH([systemdsystemenvgendir],
[AS_HELP_STRING([--with-systemdsystemenvgendir=DIR],
[Directory for systemd system environment generators (default=PREFIX/lib/systemd/system-environment-generators)])],
[],
dnl This is deliberately not ${libdir}: systemd units always go in
dnl .../lib, never .../lib64 or .../lib/x86_64-linux-gnu
[with_systemdsystemenvgendir='${prefix}/lib/systemd/system-environment-generators'])
AC_SUBST([systemdsystemenvgendir], [$with_systemdsystemenvgendir])
AC_ARG_WITH([systemduserenvgendir],
[AS_HELP_STRING([--with-systemduserenvgendir=DIR],
[Directory for systemd user environment generators (default=PREFIX/lib/systemd/user-environment-generators)])],

View File

@ -1,15 +1,2 @@
#!/bin/bash
new_dirs=
while read -r install_path
do
share_path=$install_path/exports/share
case ":$XDG_DATA_DIRS:" in
*":$share_path:"*) :;;
*":$share_path/:"*) :;;
*) new_dirs=${new_dirs:+${new_dirs}:}$share_path;;
esac
done < <(echo "${XDG_DATA_HOME:-"$HOME/.local/share"}/flatpak"; flatpak --installations)
XDG_DATA_DIRS="${new_dirs:+${new_dirs}:}${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
echo "XDG_DATA_DIRS=$XDG_DATA_DIRS"
#!/bin/sh
exec flatpak --print-updated-env

2
env.d/60-flatpak-system-only Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
exec flatpak --print-updated-env --print-system-only