From ac350243e8b1052dd6b7133d4db481b4334bb50e Mon Sep 17 00:00:00 2001 From: Logan Rawlins Date: Sat, 7 Nov 2026 11:47:34 -0700 Subject: [PATCH] fixing the resolution of display libs --- README.md | 17 ++++++++-------- scripts/appimage/AppRun | 2 ++ scripts/appimage/dependencies.sh | 26 ++++++++++++++++-------- scripts/appimage/test_packaging.sh | 32 ++++++++++++++++++++++++++++++ scripts/appimage/test_runtime.sh | 6 +++++- 5 files changed, 66 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 9384a3cf..5579a34b 100644 --- a/README.md +++ b/README.md @@ -200,14 +200,15 @@ native bundle is retained. Custom targets, obfuscation and split-debug-info require a bundle-only build when container rebuilding is needed. The image includes Flutter assets, native plugins, ONNX Runtime and the -transitive redistributable runtime libraries, including GTK and X11/Wayland -client libraries. Packaging audits every bundled ELF and fails if a portable -dependency resolves from the build host instead of the AppDir. It does not -include glibc/the ELF loader, graphics drivers, BlueZ services, USB permissions, -downloaded inference models or user data. The GTK packaging plugin uses X11, so -Wayland sessions need XWayland. The host still needs compatible glibc and -graphics libraries (`libgl1`, `libegl1`, and `libgles2` on Ubuntu). Launch -normally, or without +transitive redistributable runtime libraries. Packaging audits every bundled +ELF and fails if a portable dependency resolves from the build host instead of +the AppDir. Host display-stack libraries (X11/XCB/Wayland) and graphics drivers +remain external so they stay ABI-compatible with the system's EGL/GL driver. +The image also relies on host glibc/the ELF loader, BlueZ services and USB +permissions; downloaded inference models and user data are not included. The +GTK packaging plugin uses X11, so Wayland sessions need XWayland. The host needs +compatible graphics libraries (`libgl1`, `libegl1`, and `libgles2` on Ubuntu). +Launch normally, or without FUSE by extracting: ```bash diff --git a/scripts/appimage/AppRun b/scripts/appimage/AppRun index 5aaaaece..c9e412d8 100644 --- a/scripts/appimage/AppRun +++ b/scripts/appimage/AppRun @@ -2,6 +2,8 @@ set -eo pipefail export APPDIR="${APPDIR:-$(cd "$(dirname "$0")" && pwd)}" +unset GIO_EXTRA_MODULES GIO_MODULE_DIR GI_TYPELIB_PATH GTK_PATH GTK_MODULES GDK_PIXBUF_MODULE_FILE +export GSETTINGS_SCHEMA_DIR="$APPDIR/usr/share/glib-2.0/schemas" export PATH="$APPDIR/usr/bin:$PATH" for hook in "$APPDIR"/apprun-hooks/*.sh; do # shellcheck source=/dev/null diff --git a/scripts/appimage/dependencies.sh b/scripts/appimage/dependencies.sh index 50df48ef..1f434b3d 100644 --- a/scripts/appimage/dependencies.sh +++ b/scripts/appimage/dependencies.sh @@ -11,7 +11,8 @@ is_host_interface() { linux-vdso.so.*|ld-linux*.so.*|ld64.so.*|libc.so.*|libm.so.*|libpthread.so.*|\ libdl.so.*|librt.so.*|libresolv.so.*|libutil.so.*|libanl.so.*|\ libBrokenLocale.so.*|libnss_*.so.*|libGL.so.*|libGLX.so.*|libEGL.so.*|\ - libGLES*.so.*|libOpenGL.so.*|libglapi.so.*|libvulkan.so.*|libdrm*.so.*|libgbm.so.*) + libGLES*.so.*|libOpenGL.so.*|libglapi.so.*|libvulkan.so.*|libdrm*.so.*|libgbm.so.*|\ + libX*.so.*|libxcb*.so.*|libwayland*.so.*|libxkbcommon.so.*) return 0 ;; *) return 1 ;; @@ -93,18 +94,27 @@ scan_appdir() { fi soname="${soname##*/}" if [[ "$resolution" == 'not found'* ]]; then - printf ' %s => NOT FOUND\n' "$soname" >> "$report" - printf 'AppImage dependencies: %s needs missing %s\n' "$elf" "$soname" >&2 - failed=1 + if is_host_interface "$soname"; then + printf ' %s => NOT PRESENT ON AUDIT HOST [host interface]\n' "$soname" >> "$report" + else + printf ' %s => NOT FOUND\n' "$soname" >> "$report" + printf 'AppImage dependencies: %s needs missing %s\n' "$elf" "$soname" >&2 + failed=1 + fi continue fi resolved="${resolution%%[[:space:]]*}" [[ "$resolved" == /* ]] || continue if ! resolved_real="$(realpath -e -- "$resolved" 2>/dev/null)"; then - printf ' %s => UNRESOLVED (%s)\n' "$soname" "$resolved" >> "$report" - printf 'AppImage dependencies: %s resolves %s to missing path %s\n' \ - "$elf" "$soname" "$resolved" >&2 - failed=1 + if is_host_interface "$soname"; then + printf ' %s => NOT PRESENT ON AUDIT HOST (%s) [host interface]\n' \ + "$soname" "$resolved" >> "$report" + else + printf ' %s => UNRESOLVED (%s)\n' "$soname" "$resolved" >> "$report" + printf 'AppImage dependencies: %s resolves %s to missing path %s\n' \ + "$elf" "$soname" "$resolved" >&2 + failed=1 + fi continue fi if is_inside_appdir "$resolved_real" "$appdir_real"; then diff --git a/scripts/appimage/test_packaging.sh b/scripts/appimage/test_packaging.sh index ca91acd5..04afa68b 100644 --- a/scripts/appimage/test_packaging.sh +++ b/scripts/appimage/test_packaging.sh @@ -152,8 +152,14 @@ mkdir -p "$temporary/audit-appdir/usr/bin" "$temporary/audit-appdir/usr/lib" \ cp "$(type -P true)" "$temporary/audit-appdir/usr/bin/fixture" printf 'test library\n' > "$temporary/host/libgpg-error.so.0.37.0" ln -s libgpg-error.so.0.37.0 "$temporary/host/libgpg-error.so.0" +printf 'host display library\n' > "$temporary/host/libwayland-client.so.0" cat > "$temporary/fakebin/ldd" <<'EOF' #!/usr/bin/env bash +if [[ -e "$MESHCORE_TEST_HOST_WAYLAND" ]]; then + printf 'libwayland-client.so.0 => %s (0x0)\n' "$MESHCORE_TEST_HOST_WAYLAND" +else + printf 'libwayland-client.so.0 => not found\n' +fi if [[ -e "$MESHCORE_TEST_APPDIR/usr/lib/libgpg-error.so.0" ]]; then printf 'libgpg-error.so.0 => %s/usr/lib/libgpg-error.so.0 (0x0)\n' "$MESHCORE_TEST_APPDIR" else @@ -163,20 +169,46 @@ EOF chmod +x "$temporary/fakebin/ldd" MESHCORE_TEST_APPDIR="$temporary/audit-appdir" \ MESHCORE_TEST_HOST_LIBRARY="$temporary/host/libgpg-error.so.0" \ + MESHCORE_TEST_HOST_WAYLAND="$temporary/host/libwayland-client.so.0" \ PATH="$temporary/fakebin:$PATH" \ bash "$project/scripts/appimage/dependencies.sh" bundle \ "$temporary/audit-appdir" "$temporary/dependency-audit.log" [[ -L "$temporary/audit-appdir/usr/lib/libgpg-error.so.0" ]] [[ -f "$temporary/audit-appdir/usr/lib/libgpg-error.so.0.37.0" ]] +[[ ! -e "$temporary/audit-appdir/usr/lib/libwayland-client.so.0" ]] grep -Fq 'libgpg-error.so.0 =>' "$temporary/dependency-audit.log" +grep -Fq 'libwayland-client.so.0 =>' "$temporary/dependency-audit.log" mkdir -p "$temporary/audit-missing/usr/bin" "$temporary/audit-missing/usr/lib" cp "$temporary/audit-appdir/usr/bin/fixture" "$temporary/audit-missing/usr/bin/fixture" MESHCORE_TEST_APPDIR="$temporary/audit-missing" \ MESHCORE_TEST_HOST_LIBRARY="$temporary/host/libgpg-error.so.0" \ + MESHCORE_TEST_HOST_WAYLAND="$temporary/host/missing-libwayland-client.so.0" \ PATH="$temporary/fakebin:$PATH" \ assert_fails bash "$project/scripts/appimage/dependencies.sh" audit \ "$temporary/audit-missing" "$temporary/dependency-rejected.log" grep -Fq 'unexpected host dependency' "$temporary/dependency-rejected.log" +grep -Fq 'libwayland-client.so.0 => NOT PRESENT ON AUDIT HOST [host interface]' \ + "$temporary/dependency-rejected.log" + +mkdir -p "$temporary/launcher-appdir/usr/bin" +cp "$project/scripts/appimage/AppRun" "$temporary/launcher-appdir/AppRun" +cat > "$temporary/launcher-appdir/usr/bin/meshcore_open" <<'EOF' +#!/usr/bin/env bash +env | sort +EOF +chmod +x "$temporary/launcher-appdir/usr/bin/meshcore_open" +env APPDIR="$temporary/launcher-appdir" \ + GIO_EXTRA_MODULES=/host/gio/modules GIO_MODULE_DIR=/host/gio/modules \ + GI_TYPELIB_PATH=/host/girepository GTK_PATH=/host/gtk/modules \ + GTK_MODULES=host-module GDK_PIXBUF_MODULE_FILE=/host/pixbuf.loaders \ + bash "$temporary/launcher-appdir/AppRun" > "$temporary/launcher-environment" +for variable in GIO_EXTRA_MODULES GIO_MODULE_DIR GI_TYPELIB_PATH GTK_PATH \ + GTK_MODULES GDK_PIXBUF_MODULE_FILE; do + if grep -q "^$variable=" "$temporary/launcher-environment"; then + printf 'Host plugin environment leaked through AppRun: %s\n' "$variable" >&2 + exit 1 + fi +done printf 'AppImage packaging contract tests passed\n' \ No newline at end of file diff --git a/scripts/appimage/test_runtime.sh b/scripts/appimage/test_runtime.sh index 73445756..69747769 100644 --- a/scripts/appimage/test_runtime.sh +++ b/scripts/appimage/test_runtime.sh @@ -97,7 +97,11 @@ mkdir -p "$workspace/home/Documents" "$workspace/home/config" printf 'XDG_DOCUMENTS_DIR="%s/Documents"\n' "$workspace/home" > "$workspace/home/config/user-dirs.dirs" log 'Starting AppRun under a private D-Bus session (also used as the system bus)' # shellcheck disable=SC2016 -env -u LD_LIBRARY_PATH -u GTK_PATH -u GSETTINGS_SCHEMA_DIR \ +env -u LD_LIBRARY_PATH \ + GIO_EXTRA_MODULES=/host/gio/modules GIO_MODULE_DIR=/host/gio/modules \ + GI_TYPELIB_PATH=/host/girepository GTK_PATH=/host/gtk/modules \ + GTK_MODULES=host-module GDK_PIXBUF_MODULE_FILE=/host/pixbuf.loaders \ + GSETTINGS_SCHEMA_DIR=/host/glib-2.0/schemas \ HOME="$workspace/home" XDG_CONFIG_HOME="$workspace/home/config" \ XDG_DATA_HOME="$workspace/home/data" XDG_CACHE_HOME="$workspace/home/cache" \ dbus-run-session -- bash -c \