From 857d68a1e997aa95d8a11e1695ba34ded102cc82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C5=ABdolfs=20O=C5=A1i=C5=86=C5=A1?= Date: Tue, 2 Jun 2026 14:32:13 +0200 Subject: [PATCH] Fix Linux AppImage on non-Debian distros Force-bundle libjpeg.so.8 (Fedora/RHEL lack the libjpeg8 ABI the bundled gdk-pixbuf needs) and strip the mismatched bundled glib core so the whole glib stack resolves from the host. Repackage with mksquashfs, reusing the AppImage's own runtime, so the step fetches nothing from the network. --- Dockerfile.release | 16 ++++++++---- crates/radicle-tauri/tauri.conf.json | 5 ++++ scripts/appimage-build | 39 +++++++++++++++++++++++++++- 3 files changed, 54 insertions(+), 6 deletions(-) diff --git a/Dockerfile.release b/Dockerfile.release index d3dd1a427..9d9c27d0d 100644 --- a/Dockerfile.release +++ b/Dockerfile.release @@ -13,8 +13,11 @@ RUN dpkg --add-architecture amd64 && \ > /etc/apt/sources.list.d/archive-amd64.sources && \ apt-get update -# Native ARM64 build essentials + cross-compilation toolchain -RUN apt-get install -y --no-install-recommends \ +# Native ARM64 build essentials + cross-compilation toolchain. +# Each install runs apt-get update so a cache-invalidated layer can't resolve +# against the stale index from the standalone update above (404s on packages +# the mirror has since superseded). +RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ ca-certificates \ crossbuild-essential-amd64 \ @@ -24,7 +27,8 @@ RUN apt-get install -y --no-install-recommends \ wget \ file \ jq \ - zstd + zstd \ + squashfs-tools # Tauri system library headers for the amd64 target. # The :amd64 suffix installs the x86_64 variant via multiarch. @@ -46,7 +50,8 @@ RUN for pkg in gobject-introspection-bin gobject-introspection-bin-linux; do \ /tmp/gobject-introspection-bin-linux_1.80.1-1_amd64.deb && \ rm -f /tmp/gobject-introspection-bin*.deb -RUN apt-get install -y --no-install-recommends \ +# Refreshes the index in-layer; see the note on the build-essentials install. +RUN apt-get update && apt-get install -y --no-install-recommends \ libxdo-dev:amd64 \ libssl-dev:amd64 \ libayatana-appindicator3-dev:amd64 \ @@ -54,7 +59,8 @@ RUN apt-get install -y --no-install-recommends \ libwebkit2gtk-4.1-0:amd64 \ libjavascriptcoregtk-4.1-0:amd64 \ libwebkit2gtk-4.1-dev:amd64 \ - libjavascriptcoregtk-4.1-dev:amd64 + libjavascriptcoregtk-4.1-dev:amd64 \ + libjpeg-turbo8:amd64 # Rust: native ARM64 toolchain so the Tauri CLI runs without emulation, # plus the x86_64 target for the actual compiled output. diff --git a/crates/radicle-tauri/tauri.conf.json b/crates/radicle-tauri/tauri.conf.json index ceb38e69e..f6ed35351 100644 --- a/crates/radicle-tauri/tauri.conf.json +++ b/crates/radicle-tauri/tauri.conf.json @@ -43,6 +43,11 @@ "depends": [ "radicle" ] + }, + "appimage": { + "files": { + "/usr/lib/libjpeg.so.8": "/usr/lib/x86_64-linux-gnu/libjpeg.so.8" + } } }, "active": true, diff --git a/scripts/appimage-build b/scripts/appimage-build index 2f0b88625..da4ef1f0e 100755 --- a/scripts/appimage-build +++ b/scripts/appimage-build @@ -52,4 +52,41 @@ npm exec -- tauri build \ --config '{"build":{"beforeBuildCommand":""}}' \ --target x86_64-unknown-linux-gnu \ --bundles appimage -cp target/x86_64-unknown-linux-gnu/release/bundle/appimage/*.AppImage /output/ + +appimage=(target/x86_64-unknown-linux-gnu/release/bundle/appimage/*.AppImage) +src="${appimage[0]}" + +# A type-2 AppImage is an ELF runtime followed by a squashfs image. Reuse the +# runtime (bytes before --appimage-offset) and rebuild only the squashfs. +offset=$("$src" --appimage-offset) +head -c "$offset" "$src" > AppImage.runtime +rm -rf squashfs-root +# -no-xattrs: the build container's filesystem can't restore them. +unsquashfs -no-xattrs -o "$offset" -d squashfs-root "$src" >/dev/null + +# linuxdeploy bundles libgobject/libgio but not libglib/libgmodule. On hosts +# with a newer glib (e.g. Fedora) the mismatched bundled libs crash GTK at +# startup. Drop them so the whole glib stack resolves from the host. +rm -f squashfs-root/usr/lib/libgobject-2.0.so* \ + squashfs-root/usr/lib/libgio-2.0.so* + +# Fail the build here, not at a user's launch, if the bundle is wrong. +if [ ! -f squashfs-root/usr/lib/libjpeg.so.8 ]; then + echo "error: libjpeg.so.8 is not bundled in the AppImage" >&2 + exit 1 +fi +for lib in libgobject-2.0.so libgio-2.0.so; do + if compgen -G "squashfs-root/usr/lib/$lib*" >/dev/null; then + echo "error: $lib is still bundled; it must resolve from the host" >&2 + exit 1 + fi +done + +# Reassemble: runtime + new squashfs, matching the runtime's zstd/128K. +mksquashfs squashfs-root AppImage.squashfs \ + -comp zstd -b 131072 -root-owned -noappend -no-progress -no-xattrs +cat AppImage.runtime AppImage.squashfs > "$src" +chmod +x "$src" +rm -rf squashfs-root AppImage.runtime AppImage.squashfs + +cp "$src" /output/