feat: multi arch support (#175)

* feat: multi arch support

* fix: sanitize GTK environment

Co-authored-by: kinou-p <kinou-p@users.noreply.github.com>
This commit is contained in:
Gustavo Carvalho
2026-02-13 20:59:40 -03:00
parent d1af288f5c
commit 0cde431e72
5 changed files with 321 additions and 81 deletions

View File

@@ -33,12 +33,65 @@ if [ -z "$BINARY" ]; then
exit 1
fi
# Clean up environment to avoid Snap/Flatpak library conflicts
# ---------------------------------------------------------------------------
# Runtime environment sanitization
# ---------------------------------------------------------------------------
# When launched from a Snap terminal (e.g. VS Code Snap) or a Flatpak host,
# the parent process may inject library/schema paths from its confined runtime
# into child processes. These paths point to sandbox-internal libraries that
# are incompatible with the host GTK/WebKit stack this app links against,
# causing crashes, missing schemas, or wrong icon themes.
# ---------------------------------------------------------------------------
# Always clear library/runtime overrides — they must never leak from a sandbox
# into the host-linked Tauri binary.
unset LD_LIBRARY_PATH
unset LD_PRELOAD
unset GTK_PATH
unset GIO_MODULE_DIR
unset GTK_IM_MODULE_FILE
unset GTK_EXE_PREFIX
unset LOCPATH
unset GSETTINGS_SCHEMA_DIR
# Fix XDG_DATA_DIRS only when contaminated by sandbox paths.
# Snap terminals inject entries like /snap/code/*/usr/share which cause the
# app to resolve wrong GSettings schemas, icons, or .desktop files.
# When contaminated we strip sandbox entries and place system dirs first
# (matching run-dev.sh) so host resources always win.
sanitize_xdg_data_dirs() {
local xdg="${XDG_DATA_DIRS:-}"
local system_dirs="/usr/local/share:/usr/share:/var/lib/snapd/desktop"
# Detect contamination: $SNAP/$FLATPAK_ID set, or paths contain sandbox dirs
if [[ -z "${SNAP:-}" && -z "${FLATPAK_ID:-}" && "$xdg" != *"/snap/"* && "$xdg" != *"/flatpak/"* ]]; then
return # Environment is clean — leave XDG_DATA_DIRS untouched
fi
# Rebuild: keep only non-sandbox entries that aren't already in system_dirs
local cleaned=""
local entry
IFS=':' read -ra entries <<< "$xdg"
for entry in "${entries[@]}"; do
# Skip sandbox-injected paths
case "$entry" in
*/snap/*|*/flatpak/*) continue ;;
esac
# Skip if already covered by system_dirs (avoid duplicates)
case ":$system_dirs:" in
*":$entry:"*) continue ;;
esac
cleaned="${cleaned:+$cleaned:}$entry"
done
# System dirs first (highest precedence), then remaining clean dirs
export XDG_DATA_DIRS="${system_dirs}${cleaned:+:$cleaned}"
}
sanitize_xdg_data_dirs
# ---------------------------------------------------------------------------
# Display & rendering defaults
# ---------------------------------------------------------------------------
export GDK_SCALE="${GDK_SCALE:-1}"
export GDK_DPI_SCALE="${GDK_DPI_SCALE:-1}"
@@ -48,7 +101,7 @@ export TAURI_TRAY="${TAURI_TRAY:-libayatana-appindicator3}"
export NO_AT_BRIDGE=1
# Force software rendering in virtualized environments to avoid GPU issues
if systemd-detect-virt -q; then
if systemd-detect-virt -q 2>/dev/null; then
export LIBGL_ALWAYS_SOFTWARE=1
fi