aports/community/flatpak/tzdir.patch
2024-05-17 05:47:23 +00:00

50 lines
2.1 KiB
Diff

see https://gitlab.alpinelinux.org/alpine/aports/-/issues/14844
--
diff --git a/profile/flatpak.fish b/profile/flatpak.fish
index 117f0a4..630210a 100644
--- a/profile/flatpak.fish
+++ b/profile/flatpak.fish
@@ -3,6 +3,19 @@ if type -q flatpak
set -x --path XDG_DATA_DIRS $XDG_DATA_DIRS
+ # set TZDIR to our setup-timezone directory
+ # see https://gitlab.alpinelinux.org/alpine/aports/-/issues/14844
+ if test -d /etc/zoneinfo
+ # this directory only exists if setup-timezone was run to add one timezone and not add tzdata.
+ # unconditionally setting it would break things when it does not exist, so make sure it does.
+ # if it does not exist, then /etc/localtime is going to be pointing to /usr/share/zoneinfo.
+ set -l contents (command ls -A /etc/zoneinfo)
+ # it can also be empty. don't export it then
+ if test -n "$contents"
+ set -x TZDIR /etc/zoneinfo
+ end
+ end
+
set -q XDG_DATA_DIRS[1]; or set XDG_DATA_DIRS /usr/local/share /usr/share
set -q XDG_DATA_HOME; or set -l XDG_DATA_HOME $HOME/.local/share
diff --git a/profile/flatpak.sh b/profile/flatpak.sh
index 9dc6cf9..1feaddd 100644
--- a/profile/flatpak.sh
+++ b/profile/flatpak.sh
@@ -25,4 +25,18 @@ if command -v flatpak > /dev/null; then
XDG_DATA_DIRS="${new_dirs:+${new_dirs}:}${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
unset new_dirs
+
+ # set TZDIR to our setup-timezone directory
+ # see https://gitlab.alpinelinux.org/alpine/aports/-/issues/14844
+ if [ -d /etc/zoneinfo ]; then
+ # this directory only exists if setup-timezone was run to add one timezone and not add tzdata.
+ # unconditionally setting it would break things when it does not exist, so make sure it does.
+ # if it does not exist, then /etc/localtime is going to be pointing to /usr/share/zoneinfo.
+ contents="$(command ls -A /etc/zoneinfo)"
+ # it can also be empty. don't export it then
+ if [ -n "$contents" ]; then
+ export TZDIR=/etc/zoneinfo
+ fi
+ unset contents
+ fi
fi