mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 21:06:09 +00:00
fix: keep failed Flatpak extensions non-fatal, give Electron AppImages a bus, X11 and time to relaunch
This commit is contained in:
1 parent
58ec3609b6
commit
b78b06b78d
3 files changed
+56
-3
No files matched your search
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user