Files
DroidDeck/tools/linuxfs/overlay/usr/local/bin/droiddeck-appimage-run
T
MaxsTechReview 65ebefc38f fix(desktop): Help Center, Software Sources and the driver manager open (#3371)
* fix(desktop): apps built on Qt's web engine start in the desktop and from AppImages

The desktop runs as root, and Qt WebEngine refuses to start as root with its
sandbox on, so Help Center and any other QtWebEngine app exited at once. Flatpaks
already had the sandbox off; the desktop and the AppImage runner now set it the
same way they turn off Firefox's sandboxes.

* fix(desktop): Software Sources and the driver manager open

software-properties-qt imports PyQt6.uic and UbuntuDrivers but does not depend
on the packages that ship them, so both tools died with an ImportError on the
installed-without-recommends desktop. The desktop package list now carries
pyqt6-dev-tools and ubuntu-drivers-common.
2026-11-28 10:24:50 -05:00

116 lines
4.7 KiB
Bash
Executable File

#!/bin/bash
set -u
dir=${1:?usage: droiddeck-appimage-run <imported AppImage directory> [args...]}
shift
export APPDIR=$dir/app
unset APPIMAGE
export ARGV0=$(cat "$dir/name" 2>/dev/null || basename "$dir")
if [ ! -x "$APPDIR/AppRun" ]; then
echo "droiddeck-appimage-run: $APPDIR/AppRun is missing; import the AppImage again" >&2
exit 127
fi
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
export MOZ_SHM_NO_SEALS=1
export QTWEBENGINE_DISABLE_SANDBOX=1
if [ -s /etc/ld.so.preload ]; then
preload=$(tr -s '\n' ':' < /etc/ld.so.preload)
export LD_PRELOAD="${preload%:}${LD_PRELOAD:+:$LD_PRELOAD}" SHARUN_ALLOW_LD_PRELOAD=1
fi
flags=()
if [ -n "$(find -H "$APPDIR" -maxdepth 4 \( -name chrome-sandbox -o -name chrome_100_percent.pak -o -name v8_context_snapshot.bin \) -print -quit 2>/dev/null)" ]; then
flags+=(--no-sandbox)
if [ -n "${DISPLAY:-}" ]; then
export XDG_SESSION_TYPE=x11
unset WAYLAND_DISPLAY
flags+=(--ozone-platform=x11)
fi
fi
qt=$(cat "$dir/qt" 2>/dev/null)
case $qt in wayland|xcb) ;; *) qt=auto ;; esac
wayland=${GAMESCOPE_WAYLAND_DISPLAY:-${WAYLAND_DISPLAY:-}}
if [ "$qt" = auto ] && [ -n "$wayland" ]; then
bundled=$(find "$APPDIR" -maxdepth 6 \( -name 'libQt6Quick.so.6*' -o -name libvulkan.so.1 -o -name 'libqwayland*.so' \) -printf '%f\n' 2>/dev/null)
if grep -q '^libQt6Quick\.so\.6' <<<"$bundled"; then
if grep -q '^libqwayland' <<<"$bundled" \
&& { grep -qx libvulkan.so.1 <<<"$bundled" || grep -qs QVulkanInstance "$APPDIR"/usr/bin/* "$APPDIR"/bin/*; }; then
qt=wayland
else
echo "== appimage: Qt Quick without Vulkan or Qt's Wayland plugin stays on X11 ($(tr '\n' ' ' <<<"$bundled"))"
fi
fi
fi
if [ "$qt" = wayland ] && [ -n "$wayland" ]; then
export QT_QPA_PLATFORM='wayland;xcb' WAYLAND_DISPLAY=$wayland SDL_VIDEODRIVER=wayland XDG_SESSION_TYPE=wayland
[ "$wayland" = "${GAMESCOPE_WAYLAND_DISPLAY:-}" ] && export QT_WAYLAND_DISABLE_WINDOWDECORATION=1 DISABLE_GAMESCOPE_WSI=1
elif [ "$qt" = xcb ] && [ -n "${DISPLAY:-}" ]; then
export QT_QPA_PLATFORM=xcb
fi
arch=$(cat "$dir/arch" 2>/dev/null)
if [ "$arch" = arm64 ]; then
find -H "$APPDIR" -maxdepth 6 ! -type d \( -name libGL.so.1 -o -name libGLX.so.0 -o -name libEGL.so.1 -o -name libGLESv2.so.2 \
-o -name libOpenGL.so.0 -o -name libGLdispatch.so.0 \) -print 2>/dev/null |
while IFS= read -r lib; do
kept=$dir/bundled-gl/${lib#"$APPDIR"/}
mkdir -p "${kept%/*}" && mv -f "$lib" "$kept" && echo "== appimage: the session's ${lib##*/} replaces the bundled one"
done
fi
fex=$(cat "$dir/fex" 2>/dev/null)
case $fex in on|off) ;; *) fex=auto ;; esac
run=("$APPDIR/AppRun")
if [ -x /usr/local/bin/droiddeck-fex ]; then
case $fex:$arch in
auto:x86_64|auto:i386) run=(/usr/local/bin/droiddeck-fex run --mode on -- "$APPDIR/AppRun") ;;
auto:arm64) ;;
*) run=(/usr/local/bin/droiddeck-fex run --mode "$fex" --for "$APPDIR" -- "$APPDIR/AppRun") ;;
esac
fi
gpu=("${BASH_SOURCE[0]%/*}/droiddeck-game-gpu")
[ ${#flags[@]} -gt 0 ] && gpu+=(--chromium)
run=("${gpu[@]}" -- "${run[@]}")
echo "== appimage $ARGV0 ($APPDIR) ${flags[*]} FEX $fex Qt $qt${QT_QPA_PLATFORM:+ ($QT_QPA_PLATFORM)}"
cd "$APPDIR" || exit 1
started=$(mktemp "${TMPDIR:-/tmp}/droiddeck-appimage.XXXXXX")
case ${DBUS_SESSION_BUS_ADDRESS:-} in
unix:*) "${run[@]}" "${flags[@]}" "$@" ;;
*) unset DBUS_SESSION_BUS_ADDRESS
if command -v dbus-run-session >/dev/null 2>&1; then
dbus-run-session -- "${run[@]}" "${flags[@]}" "$@"
else
"${run[@]}" "${flags[@]}" "$@"
fi ;;
esac
rc=$?
if [ "$rc" -gt 128 ]; then
echo "== appimage $ARGV0: ended by signal $((rc - 128)) ($(kill -l $((rc - 128)) 2>/dev/null))"
else
echo "== appimage $ARGV0: exited with status $rc"
fi
if [ "$rc" -ne 0 ] && [ -n "$started" ]; then
find "${HOME:-/root}/.local/share" "${HOME:-/root}/.config" "${HOME:-/root}/.cache" -maxdepth 4 -type f \
\( -iname '*.log' -o -iname '*log*.txt' \) -newer "$started" -size -64M 2>/dev/null | head -n 3 |
while IFS= read -r log; do
echo "== appimage $ARGV0: end of $log"
tail -n 40 "$log" | LC_ALL=C tr -cd '\11\12\40-\176' | cut -c1-400
done
fi
rm -f "$started"
image_running() {
local p exe arg cwd
for p in /proc/[0-9]*; do
exe=$(readlink "$p/exe" 2>/dev/null) || continue
case $exe in "$APPDIR"/*) return 0 ;; esac
case $exe in
*/FEX|*/FEXInterpreter)
arg=$(tr '\0' '\n' < "$p/cmdline" 2>/dev/null | sed -n 2p)
cwd=$(readlink "$p/cwd" 2>/dev/null)
case $arg in "$APPDIR"/*) return 0 ;; esac
case $cwd in "$APPDIR"|"$APPDIR"/*) return 0 ;; esac
;;
esac
done
return 1
}
while image_running; do sleep 2; done
exit $rc