Previously in a0505f52d9
the profile script was modified to preserve XDG_DATA_DIRS.
This had the side-effect of making the script not idempotent,
adding duplicate entries for every installation every time it's sourced.
On my current system that results in this value:
/home/mkhl/.local/share/flatpak/exports/share /var/lib/flatpak/exports/share /home/mkhl/.local/share/flatpak/exports/share /var/lib/flatpak/exports/share /usr/local/share /usr/share
which in turn has the side-effect of the GNOME search settings showing two entries
for every application installed via flatpak.
This change makes the script check that an entry is new before adding it.
It also uses `set -p` (short for `--prepend`) to add them.
N.B.
`set -p VAR val` is equivalent to `set VAR val $VAR`
`$var[-1..1]` reverses the order of elements
so after iterating the first element of `$installations`
becomes the first element of `$XDG_DATA_DIRS`
The profile script previously nuked `XDG_DATA_DIRS` and then
“helpfully” re-populated it with FHS paths. This was especially
bad for systems like NixOS, which do not have `/usr`
and rely on `XDG_DATA_DIRS` heavily.
Quoting from https://fishshell.com/docs/current/cmds/set.html
> If a variable is set to zero elements, it will become a list with zero elements.
And indeed, that is what the `set -x --path XDG_DATA_DIRS` command does.
We need to list the value explicitly, if we want to preserve it
while setting variable options.
Technically, Fish users can already make this work using
https://github.com/edc/bass, but it's also nice to have this working on
an out-of-the-box Flatpak installation.
Fixes#3109.
Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
When using OpenBSD ksh `flatpak.sh` gives the following error:
/etc/profile.d/flatpak.sh[16]: syntax error: `;;' unexpected
By adding in the POSIX compliant optional opening parentheses for the
case statement branches the profile can be made more portable. This
still works with them more common shells such as bash and zsh and also
still passes `shellcheck` checks.
Aware that using OpenBSD ksh on Linux might be an edge case but there
are probably BSD users who need to use Linux for work such as myself but
still want to use the OBSD shell which has been ported to Linux:
https://github.com/dimkr/loksh
Many thanks to @gumnos for pointing out the fix here via Twitter.
Closes: #2947
Approved by: mwleeds
In some OSs, removing a package does not immediately remove its
configuration files in /etc. In particular, `dpkg --remove` or
`apt-get remove` in Debian derivatives leaves configuration files intact
so that the package can be reinstalled later without having to
reconfigure it, with `dpkg --purge` or `apt-get purge` used to remove
the configuration files too.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Closes: #2840Closes: #2849
Approved by: alexlarsson
If G_MESSAGES_DEBUG is set in the shell's start-up scripts, then the
"flatpak --installations" output is contaminated with these strings:
(flatpak:4558): flatpak-DEBUG: ...
Fallout from 30c2919624Closes: #2673
Approved by: alexlarsson
In Debian, we reuse flatpak.sh in /etc/X11/Xsession.d (which is sourced
by /bin/sh, normally dash) so that these environment variables become
part of the X11 session environment. We might also have
non-bash-compatible shells that read profile.d (I'm not sure).
Fixes#2594
Signed-off-by: Simon McVittie <smcv@debian.org>
Closes: #2597
Approved by: matthiasclasen
This ensures that we end up with the same installations
in XDG_DATA_DIRS, regardless which way this variable
gets set.
Closes: #2122
Approved by: matthiasclasen
Avoid setting a temporary variable flatpak_dirs which, while not
exported to the environment, would still be defined as a
shell "parameter" (variable) in the login shell itself.
Consistently put the Flatpak directories before other XDG_DATA_DIRS,
rather than putting them last if XDG_DATA_DIRS happens to be already
set.
Expand XDG_DATA_HOME if necessary, rather than assuming it will
always be ~/.local/share.
I don't know exactly which shells source profile.d, but it's possible
that one of them might only implement POSIX test syntax, so prefer
[ x = y ] over [ x == y ].
Fix some insufficient quoting that could have gone wrong if
XDG_DATA_DIRS somehow contained spaces.
Signed-off-by: Simon McVittie <smcv@debian.org>
* Append flatpak data dirs if XDG_DATA_DIRS is already set
Otherwise it will be impossible to run flatpak apps from desktop menus.
This issue can happen if another app (e.g. snapd) wants to add custom
folders to XDG_DATA_DIRS through /etc/profile.d
If XDG_DATA_DIRS is empty or unset, define it as before.
Fixes#606