From b78b06b78d9fa27c056c0effcbdb11e6031ff905 Mon Sep 17 00:00:00 2001 From: xXJsonDeruloXx Date: Tue, 29 Sep 2026 23:59:07 -0400 Subject: [PATCH] fix: keep failed Flatpak extensions non-fatal, give Electron AppImages a bus, X11 and time to relaunch --- .../launcher/runtime/GuestCommand.kt | 1 + .../usr/local/bin/bannerlator-appimage-run | 45 ++++++++++++++++++- .../overlay/usr/local/bin/bannerlator-flatpak | 13 +++++- 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt b/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt index 6bc9a54a52..d420d5771d 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt @@ -46,6 +46,7 @@ object GuestCommand { "/usr/bin/env", "-i", "HOME=/root", "USER=root", "LANG=C.UTF-8", "PATH=/usr/local/bin:/usr/bin:/bin", "XDG_RUNTIME_DIR=${runtimeDir.path}", "XDG_DATA_HOME=/root/.local/share", "FLATPAK_BWRAP=${FlatpakManager.BWRAP}", + "XDG_DATA_DIRS=/root/.local/share/flatpak/exports/share:/usr/local/share:/usr/share", ) cmd += argv val builder = ProcessBuilder(cmd).directory(root).redirectErrorStream(true) diff --git a/tools/linuxfs/overlay/usr/local/bin/bannerlator-appimage-run b/tools/linuxfs/overlay/usr/local/bin/bannerlator-appimage-run index 8d7c851631..fbe13caaf6 100755 --- a/tools/linuxfs/overlay/usr/local/bin/bannerlator-appimage-run +++ b/tools/linuxfs/overlay/usr/local/bin/bannerlator-appimage-run @@ -17,6 +17,47 @@ if [ ! -x "$APPDIR/AppRun" ]; then echo "bannerlator-appimage-run: $APPDIR/AppRun is missing; import the AppImage again" >&2 exit 127 fi -echo "== appimage $ARGV0 ($APPDIR)" +# Browsers sandbox their own children with namespaces and a setuid helper, neither of which proot +# can give them (the Flatpak sandboxes get the same; see BwrapSpawner): Firefox and its forks (Zen, +# LibreWolf) by these switches, Electron and Chromium builds by --no-sandbox. Chromium on Wayland +# also asks the render node for a DRM version KGSL cannot give, so with an X server up it stays on +# X11, which it picks from the session type. +export MOZ_DISABLE_CONTENT_SANDBOX=1 MOZ_DISABLE_GMP_SANDBOX=1 MOZ_DISABLE_RDD_SANDBOX=1 +export MOZ_DISABLE_SOCKET_PROCESS_SANDBOX=1 MOZ_DISABLE_UTILITY_SANDBOX=1 +flags=() +if [ -e "$APPDIR/chrome-sandbox" ] || compgen -G "$APPDIR/*/chrome-sandbox" >/dev/null; then + flags+=(--no-sandbox) + if [ -n "${DISPLAY:-}" ]; then + export XDG_SESSION_TYPE=x11 + unset WAYLAND_DISPLAY + flags+=(--ozone-platform=x11) + fi +fi +echo "== appimage $ARGV0 ($APPDIR) ${flags[*]}" cd "$APPDIR" || exit 1 -exec "$APPDIR/AppRun" "$@" +# Apps expect a session bus; Electron's main process traps (SIGTRAP) on an address it cannot +# parse. A run mode has none, so one is started for the app, as for Flatpak apps. +case ${DBUS_SESSION_BUS_ADDRESS:-} in + unix:*) "$APPDIR/AppRun" "${flags[@]}" "$@" ;; + *) unset DBUS_SESSION_BUS_ADDRESS + if command -v dbus-run-session >/dev/null 2>&1; then + dbus-run-session -- "$APPDIR/AppRun" "${flags[@]}" "$@" + else + "$APPDIR/AppRun" "${flags[@]}" "$@" + fi ;; +esac +rc=$? +# The program a session was started for may hand over to another process and exit: Electron apps +# relaunch themselves (Obsidian on its first start), launchers fork their real program. The +# session ends with this script, and takes the rest with it - so it waits while anything running +# from the image is still up. +image_running() { + local p exe + for p in /proc/[0-9]*; do + exe=$(readlink "$p/exe" 2>/dev/null) || continue + case $exe in "$APPDIR"/*) return 0 ;; esac + done + return 1 +} +while image_running; do sleep 2; done +exit $rc diff --git a/tools/linuxfs/overlay/usr/local/bin/bannerlator-flatpak b/tools/linuxfs/overlay/usr/local/bin/bannerlator-flatpak index 4dd34b97c3..3b322539ff 100644 --- a/tools/linuxfs/overlay/usr/local/bin/bannerlator-flatpak +++ b/tools/linuxfs/overlay/usr/local/bin/bannerlator-flatpak @@ -83,11 +83,22 @@ def transaction(inst): def on_operation_error(tr, op, err, details): # A runtime extension that fails to install (a missing translation, an unneeded GL # driver) is not worth losing the app over; anything else ends the transaction. - # FLATPAK_TRANSACTION_ERROR_DETAILS_NON_FATAL is 1; the bindings do not always name it. + # FLATPAK_TRANSACTION_ERROR_DETAILS_NON_FATAL is 1, but PyGObject does not always hand the + # flags over ("g_value_get_flags: assertion ... failed" and a 0). An extension installed + # alongside an app - its translations, debug data, a GL or codecs runtime - is what Flatpak + # marks non-fatal, as the flatpak CLI does: its failure costs that extension, not the app. try: non_fatal = bool(int(details) & 1) except (TypeError, ValueError): non_fatal = False + if not non_fatal: + try: + related = bool(op.get_related_to_ops()) + except (AttributeError, TypeError): + related = False + ref_id = (op.get_ref() or "").split("/")[1:2] + ref_id = ref_id[0] if ref_id else "" + non_fatal = related or ref_id.endswith((".Locale", ".Debug")) or ".GL." in ref_id or "codecs" in ref_id emit(e="warning" if non_fatal else "error", message="%s: %s" % (op.get_ref(), err.message)) if not non_fatal: state["error"] = err.message