From f22f2eb0a2dc7337c029182d510d7937f5c60b01 Mon Sep 17 00:00:00 2001 From: Logan Rawlins Date: Sat, 7 Nov 2026 10:53:52 -0700 Subject: [PATCH 1/3] fixing bundled libraries --- .github/workflows/build.yml | 8 +- README.md | 17 +-- scripts/appimage/Dockerfile | 4 +- scripts/appimage/dependencies.sh | 168 +++++++++++++++++++++++++++++ scripts/appimage/test_packaging.sh | 32 ++++++ scripts/appimage/test_runtime.sh | 27 ++--- scripts/appimage/verify_image.sh | 22 ++++ scripts/build_appimage.sh | 2 + 8 files changed, 246 insertions(+), 34 deletions(-) create mode 100644 scripts/appimage/dependencies.sh create mode 100644 scripts/appimage/verify_image.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 935b9106..7b59ada3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,7 +56,7 @@ jobs: - name: Install Linux build deps run: | sudo apt-get update - sudo apt-get install -y clang cmake ninja-build pkg-config jq libgtk-3-dev librsvg2-dev libgirepository1.0-dev libgtk-3-bin libgdk-pixbuf2.0-bin libgdk-pixbuf-2.0-dev dpkg-dev patchelf file desktop-file-utils xdg-user-dirs shellcheck libssl-dev libunwind-dev libvulkan-dev libgl1-mesa-dev libasound2-dev libsecret-1-dev + sudo apt-get install -y clang cmake ninja-build pkg-config jq libgtk-3-dev librsvg2-dev libgirepository1.0-dev libgtk-3-bin libgdk-pixbuf2.0-bin libgdk-pixbuf-2.0-dev dpkg-dev patchelf file desktop-file-utils xdg-user-dirs shellcheck libssl-dev libunwind-dev libvulkan-dev libgl1-mesa-dev libasound2-dev libsecret-1-dev libgpg-error0 - uses: actions/cache@v4 with: path: ~/.cache/meshcore-open/appimage @@ -87,7 +87,7 @@ jobs: - name: Test AppImage in clean Ubuntu run: | mkdir -p build/appimage-runtime - docker run --rm --stop-timeout 15 --user "$(id -u):$(id -g)" --mount "type=bind,source=$PWD/build/linux/x64/release/meshcore-open-x86_64.AppImage,target=/artifact.AppImage,readonly" --mount "type=bind,source=$PWD/scripts/appimage/test_runtime.sh,target=/test_runtime.sh,readonly" --mount "type=bind,source=$PWD/build/appimage-runtime,target=/results" meshcore-appimage-runtime:ci timeout --verbose --signal=TERM --kill-after=15s 300s xvfb-run -a bash /test_runtime.sh /artifact.AppImage /results + docker run --rm --stop-timeout 15 --user "$(id -u):$(id -g)" --mount "type=bind,source=$PWD/build/linux/x64/release/meshcore-open-x86_64.AppImage,target=/artifact.AppImage,readonly" --mount "type=bind,source=$PWD/scripts/appimage/test_runtime.sh,target=/test_runtime.sh,readonly" --mount "type=bind,source=$PWD/scripts/appimage/dependencies.sh,target=/dependencies.sh,readonly" --mount "type=bind,source=$PWD/build/appimage-runtime,target=/results" meshcore-appimage-runtime:ci env MESHCORE_APPIMAGE_DEPENDENCIES=/dependencies.sh timeout --verbose --signal=TERM --kill-after=15s 300s xvfb-run -a bash /test_runtime.sh /artifact.AppImage /results - uses: actions/upload-artifact@v4 if: always() with: @@ -126,7 +126,7 @@ jobs: - name: Install Linux build deps run: | sudo apt-get update - sudo apt-get install -y clang cmake ninja-build pkg-config jq libgtk-3-dev librsvg2-dev libgirepository1.0-dev libgtk-3-bin libgdk-pixbuf2.0-bin libgdk-pixbuf-2.0-dev dpkg-dev patchelf file desktop-file-utils xdg-user-dirs shellcheck libssl-dev libunwind-dev libvulkan-dev libgl1-mesa-dev libasound2-dev libsecret-1-dev + sudo apt-get install -y clang cmake ninja-build pkg-config jq libgtk-3-dev librsvg2-dev libgirepository1.0-dev libgtk-3-bin libgdk-pixbuf2.0-bin libgdk-pixbuf-2.0-dev dpkg-dev patchelf file desktop-file-utils xdg-user-dirs shellcheck libssl-dev libunwind-dev libvulkan-dev libgl1-mesa-dev libasound2-dev libsecret-1-dev libgpg-error0 - uses: actions/cache@v4 with: path: ~/.cache/meshcore-open/appimage @@ -163,7 +163,7 @@ jobs: - name: Test ARM64 AppImage in clean Ubuntu run: | mkdir -p build/appimage-runtime - docker run --rm --stop-timeout 15 --platform linux/arm64 --user "$(id -u):$(id -g)" --mount "type=bind,source=$PWD/build/linux/arm64/release/meshcore-open-aarch64.AppImage,target=/artifact.AppImage,readonly" --mount "type=bind,source=$PWD/scripts/appimage/test_runtime.sh,target=/test_runtime.sh,readonly" --mount "type=bind,source=$PWD/build/appimage-runtime,target=/results" meshcore-appimage-runtime-arm64:ci timeout --verbose --signal=TERM --kill-after=15s 300s xvfb-run -a bash /test_runtime.sh /artifact.AppImage /results + docker run --rm --stop-timeout 15 --platform linux/arm64 --user "$(id -u):$(id -g)" --mount "type=bind,source=$PWD/build/linux/arm64/release/meshcore-open-aarch64.AppImage,target=/artifact.AppImage,readonly" --mount "type=bind,source=$PWD/scripts/appimage/test_runtime.sh,target=/test_runtime.sh,readonly" --mount "type=bind,source=$PWD/scripts/appimage/dependencies.sh,target=/dependencies.sh,readonly" --mount "type=bind,source=$PWD/build/appimage-runtime,target=/results" meshcore-appimage-runtime-arm64:ci env MESHCORE_APPIMAGE_DEPENDENCIES=/dependencies.sh timeout --verbose --signal=TERM --kill-after=15s 300s xvfb-run -a bash /test_runtime.sh /artifact.AppImage /results - uses: actions/upload-artifact@v4 if: always() with: diff --git a/README.md b/README.md index acb8edea..9384a3cf 100644 --- a/README.md +++ b/README.md @@ -173,7 +173,7 @@ dependencies: ```bash sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev \ librsvg2-dev libgirepository1.0-dev libgtk-3-bin libgdk-pixbuf2.0-bin \ - libgdk-pixbuf-2.0-dev dpkg-dev patchelf binutils curl jq file desktop-file-utils xdg-user-dirs + libgdk-pixbuf-2.0-dev dpkg-dev patchelf binutils curl jq file desktop-file-utils xdg-user-dirs libgpg-error0 ``` The build automatically downloads checksum-verified architecture-matched @@ -199,12 +199,15 @@ container can write the host-owned output and cache directories. The original 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 -redistributable GTK dependencies. It does not include 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 +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 FUSE by extracting: ```bash diff --git a/scripts/appimage/Dockerfile b/scripts/appimage/Dockerfile index 605484d4..fdb54385 100644 --- a/scripts/appimage/Dockerfile +++ b/scripts/appimage/Dockerfile @@ -7,7 +7,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ librsvg2-dev libgirepository1.0-dev libgdk-pixbuf-2.0-dev libgtk-3-bin \ libgdk-pixbuf2.0-bin binutils patchelf curl jq \ file desktop-file-utils xdg-user-dirs git rsync unzip xz-utils make g++ dpkg-dev \ - libssl-dev libunwind-dev libvulkan-dev libgl1-mesa-dev libglu1-mesa-dev \ + libssl-dev libunwind-dev libvulkan-dev libgl1-mesa-dev libglu1-mesa-dev libgpg-error0 \ libasound2-dev libsecret-1-dev \ && rm -rf /var/lib/apt/lists/* @@ -23,5 +23,5 @@ FROM ${BASE_IMAGE} AS runtime-test ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y --no-install-recommends \ xvfb xauth x11-utils x11-apps xdotool imagemagick dbus-x11 binutils libgl1 libegl1 libgles2 \ - libgl1-mesa-dri fonts-dejavu-core \ + libgl1-mesa-dri libgpg-error0 fonts-dejavu-core \ && rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/scripts/appimage/dependencies.sh b/scripts/appimage/dependencies.sh new file mode 100644 index 00000000..50df48ef --- /dev/null +++ b/scripts/appimage/dependencies.sh @@ -0,0 +1,168 @@ +#!/usr/bin/env bash +set -euo pipefail + +fail() { + printf 'AppImage dependencies: %s\n' "$*" >&2 + return 1 +} + +is_host_interface() { + case "$1" in + 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.*) + return 0 + ;; + *) return 1 ;; + esac +} + +is_inside_appdir() { + [[ "$1" == "$2/"* ]] +} + +copy_dependency() { + local appdir="$1" soname="$2" source="$3" source_real real_name library_dir target existing_real + source_real="$(realpath -e -- "$source")" || { + fail "Cannot resolve dependency $soname from $source" + return 1 + } + [[ -f "$source_real" ]] || { fail "Dependency is not a regular file: $source_real"; return 1; } + real_name="${source_real##*/}" + library_dir="$appdir/usr/lib" + target="$library_dir/$real_name" + mkdir -p "$library_dir" + if [[ -e "$target" || -L "$target" ]]; then + existing_real="$(realpath -e -- "$target")" || { + fail "Broken bundled library path: $target" + return 1 + } + if [[ "$existing_real" != "$source_real" ]] && ! cmp -s -- "$existing_real" "$source_real"; then + fail "Conflicting libraries map to $target" + return 1 + fi + else + cp -p -- "$source_real" "$target" + fi + if [[ "$soname" != "$real_name" ]]; then + if [[ -e "$library_dir/$soname" || -L "$library_dir/$soname" ]]; then + existing_real="$(realpath -e -- "$library_dir/$soname")" || { + fail "Broken bundled SONAME link: $library_dir/$soname" + return 1 + } + if [[ "$existing_real" != "$source_real" ]] && ! cmp -s -- "$existing_real" "$source_real"; then + fail "Conflicting libraries provide SONAME $soname" + return 1 + fi + else + ln -s "$real_name" "$library_dir/$soname" + fi + fi +} + +scan_appdir() { + local appdir="$1" report="$2" mode="$3" changed_name="$4" + local appdir_real search_path elf output status line soname resolution resolved resolved_real + local failed=0 copied_any=0 + local -a elf_files=() + appdir_real="$(realpath -e -- "$appdir")" + search_path="$appdir/usr/lib:$appdir/usr/bin/lib" + : > "$report" + mapfile -d '' -t elf_files < <(find "$appdir/usr/bin" "$appdir/usr/lib" \ + \( -type f -o -type l \) -print0 2>/dev/null || true) + for elf in "${elf_files[@]}"; do + readelf -h "$elf" >/dev/null 2>&1 || continue + printf '%s\n' "${elf#"$appdir/"}" >> "$report" + if output="$(LD_LIBRARY_PATH="$search_path" ldd "$elf" 2>&1)"; then + status=0 + else + status=$? + fi + while IFS= read -r line; do + soname='' + resolution='' + if [[ "$line" =~ ^[[:space:]]*([^[:space:]]+)[[:space:]]*=\>[[:space:]]*(.*)$ ]]; then + soname="${BASH_REMATCH[1]}" + resolution="${BASH_REMATCH[2]}" + elif [[ "$line" =~ ^[[:space:]]*(/[^[:space:]]+) ]]; then + resolution="${BASH_REMATCH[1]}" + soname="${resolution##*/}" + else + continue + 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 + 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 + continue + fi + if is_inside_appdir "$resolved_real" "$appdir_real"; then + printf ' %s => %s [bundled]\n' "$soname" "$resolved_real" >> "$report" + elif is_host_interface "$soname"; then + printf ' %s => %s [host interface]\n' "$soname" "$resolved_real" >> "$report" + elif [[ "$mode" == bundle ]]; then + printf ' %s => %s [bundling]\n' "$soname" "$resolved_real" >> "$report" + copy_dependency "$appdir" "$soname" "$resolved_real" + copied_any=1 + else + printf ' %s => %s [unexpected host dependency]\n' "$soname" "$resolved_real" >> "$report" + printf 'AppImage dependencies: %s resolves non-allowlisted %s from %s\n' \ + "$elf" "$soname" "$resolved_real" >&2 + failed=1 + fi + done <<< "$output" + if ((status != 0)) && [[ "$output" != *'not found'* ]]; then + printf 'AppImage dependencies: ldd failed for %s (exit %s): %s\n' \ + "$elf" "$status" "$output" >&2 + failed=1 + fi + done + printf -v "$changed_name" '%s' "$copied_any" + ((failed == 0)) +} + +bundle_appdir_dependencies() { + local appdir="$1" report="$2" pass changed + for ((pass = 1; pass <= 32; pass++)); do + scan_appdir "$appdir" "$report" bundle changed || return 1 + ((changed == 1)) || break + done + ((pass <= 32)) || { fail 'Dependency closure did not converge after 32 passes'; return 1; } + audit_appdir_dependencies "$appdir" "$report" +} + +audit_appdir_dependencies() { + local appdir="$1" report="$2" changed=0 + scan_appdir "$appdir" "$report" audit changed +} + +main() { + [[ $# == 3 ]] || { fail 'Usage: dependencies.sh bundle|audit APPDIR REPORT'; return 1; } + local mode="$1" appdir="$2" report="$3" + [[ -d "$appdir/usr/bin" && -d "$appdir/usr/lib" ]] || { + fail "Invalid AppDir: $appdir" + return 1 + } + command -v readelf >/dev/null || { fail 'Missing readelf'; return 1; } + command -v ldd >/dev/null || { fail 'Missing ldd'; return 1; } + case "$mode" in + bundle) bundle_appdir_dependencies "$appdir" "$report" ;; + audit) audit_appdir_dependencies "$appdir" "$report" ;; + *) fail "Unknown mode: $mode"; return 1 ;; + esac +} + +if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then + main "$@" +fi \ No newline at end of file diff --git a/scripts/appimage/test_packaging.sh b/scripts/appimage/test_packaging.sh index 5b7d8d51..ca91acd5 100644 --- a/scripts/appimage/test_packaging.sh +++ b/scripts/appimage/test_packaging.sh @@ -147,4 +147,36 @@ mock_glibc=2.39 requires_container_rebuild "$temporary/bundle/meshcore_open" 2.39 unset -f readelf getconf +mkdir -p "$temporary/audit-appdir/usr/bin" "$temporary/audit-appdir/usr/lib" \ + "$temporary/host" "$temporary/fakebin" +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" +cat > "$temporary/fakebin/ldd" <<'EOF' +#!/usr/bin/env bash +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 + printf 'libgpg-error.so.0 => %s (0x0)\n' "$MESHCORE_TEST_HOST_LIBRARY" +fi +EOF +chmod +x "$temporary/fakebin/ldd" +MESHCORE_TEST_APPDIR="$temporary/audit-appdir" \ + MESHCORE_TEST_HOST_LIBRARY="$temporary/host/libgpg-error.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" ]] +grep -Fq 'libgpg-error.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" \ + 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" + 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 3182ec5a..73445756 100644 --- a/scripts/appimage/test_runtime.sh +++ b/scripts/appimage/test_runtime.sh @@ -86,27 +86,12 @@ log "ELF architecture audit passed ($elf_count files)" dependencies="$output/dependencies.log" : > "$dependencies" -run_timed 'check application dependencies' 20s "$workspace/ldd.log" \ - ldd "$appdir/usr/bin/meshcore_open" -cat "$workspace/ldd.log" >> "$dependencies" -while IFS= read -r -d '' library; do - relative="${library#"$appdir/"}" - if run_timed "check dependencies: $relative" 20s "$workspace/ldd.log" ldd "$library"; then - cat "$workspace/ldd.log" >> "$dependencies" - else - status=$? - cat "$workspace/ldd.log" >> "$dependencies" - if [[ "$status" == 124 || "$status" == 137 ]]; then - exit "$status" - fi - log "ldd returned $status for $relative; continuing unresolved-dependency scan" - fi -done < <(find "$appdir/usr/bin/lib" "$appdir/usr/lib" -type f -name '*.so*' -print0) -if grep 'not found' "$dependencies"; then - log 'Unresolved AppImage dependencies' - exit 1 -fi -log 'Dependency audit passed' +dependency_checker="${MESHCORE_APPIMAGE_DEPENDENCIES:-$(dirname "${BASH_SOURCE[0]}")/dependencies.sh}" +[[ -f "$dependency_checker" ]] || { log "Missing dependency checker: $dependency_checker"; exit 1; } +run_timed 'audit dependency origins' 120s "$workspace/dependency-audit.log" \ + bash "$dependency_checker" audit "$appdir" "$dependencies" +cat "$workspace/dependency-audit.log" >> "$dependencies" +log 'Dependency origin audit passed' mkdir -p "$workspace/home/Documents" "$workspace/home/config" printf 'XDG_DOCUMENTS_DIR="%s/Documents"\n' "$workspace/home" > "$workspace/home/config/user-dirs.dirs" diff --git a/scripts/appimage/verify_image.sh b/scripts/appimage/verify_image.sh new file mode 100644 index 00000000..9ef2e385 --- /dev/null +++ b/scripts/appimage/verify_image.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [[ $# != 2 ]]; then + printf 'Usage: verify_image.sh APPIMAGE REPORT\n' >&2 + exit 2 +fi + +image="$(realpath -e -- "$1")" +report="$2" +dependency_checker="$(dirname "${BASH_SOURCE[0]}")/dependencies.sh" +workspace="$(mktemp -d)" +trap 'rm -rf "$workspace"' EXIT +mkdir -p "$(dirname "$report")" +cp -p -- "$image" "$workspace/extractor" +printf '\0\0\0' | dd of="$workspace/extractor" bs=1 seek=8 count=3 conv=notrunc status=none +( + cd "$workspace" + ./extractor --appimage-extract >/dev/null +) +bash "$dependency_checker" audit "$workspace/squashfs-root" "$report" +printf 'AppImage dependency audit passed: %s\n' "$report" \ No newline at end of file diff --git a/scripts/build_appimage.sh b/scripts/build_appimage.sh index 572e42a4..03b00c1a 100644 --- a/scripts/build_appimage.sh +++ b/scripts/build_appimage.sh @@ -156,6 +156,7 @@ package_direct() { dependencies+=(--deploy-deps-only "$library") done < <(find "$appdir/usr/bin/lib" -type f -print0) "$linuxdeploy" --appdir "$appdir" "${dependencies[@]}" + bash "$project/scripts/appimage/dependencies.sh" bundle "$appdir" "$work/dependency-audit.txt" while IFS= read -r -d '' library; do readelf -h "$library" >/dev/null 2>&1 || continue relative="$(realpath --relative-to="$(dirname "$library")" "$appdir/usr/lib")" @@ -187,6 +188,7 @@ package_direct() { cp "$MESHCORE_APPIMAGE_FLUTTER_ROOT/LICENSE" "$appdir/usr/share/doc/meshcore-open/Flutter-LICENSE" fi audit_appdir "$appdir" "$work/audit.txt" + cat "$work/dependency-audit.txt" >> "$work/audit.txt" ARCH="$appimage_arch" "$appimagetool" --runtime-file "$cache/runtime" --no-appstream \ "$appdir" "$work/$appimage_name" chmod +x "$work/$appimage_name" From ac350243e8b1052dd6b7133d4db481b4334bb50e Mon Sep 17 00:00:00 2001 From: Logan Rawlins Date: Sat, 7 Nov 2026 11:47:34 -0700 Subject: [PATCH 2/3] 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 \ From 2987532c4598d48f1fb27d7254f96a18aa087426 Mon Sep 17 00:00:00 2001 From: Logan Rawlins Date: Sat, 7 Nov 2026 12:23:45 -0700 Subject: [PATCH 3/3] resolve review comments --- scripts/appimage/dependencies.sh | 9 ++++++--- scripts/appimage/test_packaging.sh | 24 ++++++++++++++++++++++++ scripts/appimage/test_runtime.sh | 6 +++++- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/scripts/appimage/dependencies.sh b/scripts/appimage/dependencies.sh index 1f434b3d..1c153352 100644 --- a/scripts/appimage/dependencies.sh +++ b/scripts/appimage/dependencies.sh @@ -103,7 +103,10 @@ scan_appdir() { fi continue fi - resolved="${resolution%%[[:space:]]*}" + resolved="$resolution" + if [[ "$resolved" =~ ^(.*)[[:space:]]+\(0x[[:xdigit:]]+\)$ ]]; then + resolved="${BASH_REMATCH[1]}" + fi [[ "$resolved" == /* ]] || continue if ! resolved_real="$(realpath -e -- "$resolved" 2>/dev/null)"; then if is_host_interface "$soname"; then @@ -132,8 +135,8 @@ scan_appdir() { failed=1 fi done <<< "$output" - if ((status != 0)) && [[ "$output" != *'not found'* ]]; then - printf 'AppImage dependencies: ldd failed for %s (exit %s): %s\n' \ + if ((status != 0)) || [[ "$output" =~ version[[:space:]].*not[[:space:]]found ]]; then + printf 'AppImage dependencies: ldd dependency check failed for %s (exit %s): %s\n' \ "$elf" "$status" "$output" >&2 failed=1 fi diff --git a/scripts/appimage/test_packaging.sh b/scripts/appimage/test_packaging.sh index 04afa68b..02436fae 100644 --- a/scripts/appimage/test_packaging.sh +++ b/scripts/appimage/test_packaging.sh @@ -155,6 +155,11 @@ 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 [[ "${MESHCORE_TEST_LDD_VERSION_FAILURE:-0}" == 1 ]]; then + printf "%s: /lib/x86_64-linux-gnu/libc.so.6: version 'GLIBC_2.39' not found (required by %s)\n" \ + "$MESHCORE_TEST_APPDIR/usr/bin/fixture" "$MESHCORE_TEST_APPDIR/usr/bin/fixture" + exit 1 +fi if [[ -e "$MESHCORE_TEST_HOST_WAYLAND" ]]; then printf 'libwayland-client.so.0 => %s (0x0)\n' "$MESHCORE_TEST_HOST_WAYLAND" else @@ -179,6 +184,17 @@ MESHCORE_TEST_APPDIR="$temporary/audit-appdir" \ grep -Fq 'libgpg-error.so.0 =>' "$temporary/dependency-audit.log" grep -Fq 'libwayland-client.so.0 =>' "$temporary/dependency-audit.log" +mkdir -p "$temporary/audit AppDir/usr/bin" "$temporary/audit AppDir/usr/lib" +cp "$temporary/audit-appdir/usr/bin/fixture" "$temporary/audit AppDir/usr/bin/fixture" +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-spaces.log" +[[ -L "$temporary/audit AppDir/usr/lib/libgpg-error.so.0" ]] +grep -Fq 'libgpg-error.so.0 =>' "$temporary/dependency-audit-spaces.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" \ @@ -190,6 +206,14 @@ MESHCORE_TEST_APPDIR="$temporary/audit-missing" \ 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" +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" \ + MESHCORE_TEST_LDD_VERSION_FAILURE=1 \ + PATH="$temporary/fakebin:$PATH" \ + assert_fails bash "$project/scripts/appimage/dependencies.sh" audit \ + "$temporary/audit-appdir" "$temporary/dependency-version-rejected.log" +grep -Fq "version 'GLIBC_2.39' not found" "$temporary/error" mkdir -p "$temporary/launcher-appdir/usr/bin" cp "$project/scripts/appimage/AppRun" "$temporary/launcher-appdir/AppRun" diff --git a/scripts/appimage/test_runtime.sh b/scripts/appimage/test_runtime.sh index 69747769..c09e60f1 100644 --- a/scripts/appimage/test_runtime.sh +++ b/scripts/appimage/test_runtime.sh @@ -4,6 +4,11 @@ set -euo pipefail image="$(realpath "$1")" mkdir -p "$2" output="$(realpath "$2")" +script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" +dependency_checker="${MESHCORE_APPIMAGE_DEPENDENCIES:-$script_dir/dependencies.sh}" +if [[ "$dependency_checker" != /* ]]; then + dependency_checker="$(realpath -e -- "$dependency_checker")" +fi exec > >(tee -a "$output/runtime-test.log") 2>&1 log() { @@ -86,7 +91,6 @@ log "ELF architecture audit passed ($elf_count files)" dependencies="$output/dependencies.log" : > "$dependencies" -dependency_checker="${MESHCORE_APPIMAGE_DEPENDENCIES:-$(dirname "${BASH_SOURCE[0]}")/dependencies.sh}" [[ -f "$dependency_checker" ]] || { log "Missing dependency checker: $dependency_checker"; exit 1; } run_timed 'audit dependency origins' 120s "$workspace/dependency-audit.log" \ bash "$dependency_checker" audit "$appdir" "$dependencies"