Add an environment generator

This is a script that program that gets run by systemd
before every user service to set up the environment.

See systemd.environment-generator(7) for details.

Closes: #2122
Approved by: matthiasclasen
This commit is contained in:
Matthias Clasen 2018-09-20 12:56:56 -04:00 committed by Atomic Bot
parent 4f915388a5
commit adb288d19a
3 changed files with 27 additions and 0 deletions

View File

@ -159,6 +159,9 @@ flatpak.env: env.d/flatpak.env.in
$(AM_V_GEN) $(SED) -e "s|\@localstatedir\@|$(localstatedir)|" \
-e "s|\@sysconfdir\@|$(sysconfdir)|" $< > $@
envgendir = $(systemduserenvgendir)
envgen_DATA = env.d/60-flatpak
dbussnippetdir = $(systemduserunitdir)/dbus.service.d
dbussnippet_DATA = flatpak.conf
EXTRA_DIST += dbus.service.d/flatpak.conf.in

View File

@ -121,6 +121,15 @@ AC_ARG_WITH([systemdsystemunitdir],
[with_systemdsystemunitdir='${prefix}/lib/systemd/system'])
AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
AC_ARG_WITH([systemduserenvgendir],
[AS_HELP_STRING([--with-systemduserenvgendir=DIR],
[Directory for systemd user environment generators (default=PREFIX/lib/systemd/user-environment-generators)])],
[],
dnl This is deliberately not ${libdir}: systemd units always go in
dnl .../lib, never .../lib64 or .../lib/x86_64-linux-gnu
[with_systemduserenvgendir='${prefix}/lib/systemd/user-environment-generators'])
AC_SUBST([systemduserenvgendir], [$with_systemduserenvgendir])
AC_ARG_WITH(system_fonts_dir,
AS_HELP_STRING([--with-system-fonts-dir=PATH],[Directory where system fonts are, [default=/usr/share/fonts]]),
with_system_fonts_dir="$withval", with_system_fonts_dir=/usr/share/fonts)

15
env.d/60-flatpak Executable file
View File

@ -0,0 +1,15 @@
#!/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"