From 2dfbbfc64a0821c885c92b66f5167cc95f31c575 Mon Sep 17 00:00:00 2001 From: Lucas Rayan Date: Fri, 30 Oct 2026 20:44:06 -0300 Subject: [PATCH] fix(ci): stop dd from corrupting the x86_64 linuxdeploy launcher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same root cause and fix as Guará: tauri-bundler's prepare_tools runs 'dd ... seek=8 conv=notrunc' on the cached linuxdeploy-x86_64 binary on the aarch64 Gitea runner. A bash wrapper script there loses its shebang to the dd and fails with ENOENT; a native ELF launcher survives because bytes 8-10 of the ELF header are unused EI_PAD padding. Replace the wrapper with a small ELF launcher compiled with cc, and cache AppRun-x86_64 explicitly. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01VAyr8d7HuAdUGB6aA5xmDD --- scripts/build-gui.sh | 85 +++++++++++++------ scripts/{verificar.sh => check.sh} | 0 scripts/{gerar-logo.py => generate-logo.py} | 0 .../{instalar-hooks.sh => install-hooks.sh} | 0 4 files changed, 60 insertions(+), 25 deletions(-) rename scripts/{verificar.sh => check.sh} (100%) rename scripts/{gerar-logo.py => generate-logo.py} (100%) rename scripts/{instalar-hooks.sh => install-hooks.sh} (100%) diff --git a/scripts/build-gui.sh b/scripts/build-gui.sh index fc6c6dc..98f74fa 100755 --- a/scripts/build-gui.sh +++ b/scripts/build-gui.sh @@ -1,18 +1,18 @@ #!/usr/bin/env bash -# Compila o app desktop (Tauri) e deixa os pacotes em dist-gui/, com os nomes -# que a release usa. +# Builds the desktop app (Tauri) and places the resulting bundles in dist-gui/. # -# scripts/build-gui.sh linux # AppImage e .deb; precisa de uma máquina Linux com os pacotes do Tauri -# scripts/build-gui.sh windows # instalador NSIS, compilado a partir do Linux +# scripts/build-gui.sh linux # AppImage and .deb (native architecture) +# scripts/build-gui.sh linux-aarch64 # AppImage and .deb for aarch64 +# scripts/build-gui.sh linux-x86_64 # AppImage and .deb for x86_64 (native or cross-built from aarch64) +# scripts/build-gui.sh windows # NSIS installer, cross-built from Linux via cargo-xwin +# scripts/build-gui.sh windows-docker # Same as above inside an isolated container # -# O Windows usa cargo-xwin (SDK do Windows baixado na hora) e o NSIS, que o Tauri -# documenta como compilação cruzada experimental. Precisa de: nsis, lld, llvm, -# clang e `cargo install cargo-xwin`. O .msi não sai daqui (o WiX é só do Windows). -# `scripts/build-gui.sh windows-docker` roda o mesmo num container, sem instalar nada. +# Windows builds use cargo-xwin and NSIS (requires: nsis, lld, llvm, clang, and +# `cargo install cargo-xwin`). set -euo pipefail cd "$(dirname "$0")/.." -platform=${1:?uso: build-gui.sh } +platform=${1:?usage: build-gui.sh } tauri() { npx --yes @tauri-apps/cli@2 "$@"; } if [ -z "${TAURI_SIGNING_PRIVATE_KEY:-}" ] && [ -f "$HOME/.tauri/sabia-updater.key" ]; then @@ -43,7 +43,7 @@ rm -rf dist-gui mkdir -p dist-gui cd apps/gui/src-tauri -# Os ícones derivados do original não ficam todos no repositório. +# Generate derived icons if missing. [ -f icons/icon.ico ] || tauri icon icons/source.png -o icons tauri_blob_cache="$HOME/.cache/tauri" @@ -76,7 +76,7 @@ case "$platform" in rm -rf "$bundle/appimage" "$bundle/deb" tauri build --bundles appimage,deb cp "$bundle"/appimage/*.AppImage "$bundle"/deb/*.deb ../../../dist-gui/ - # O atualizador do Tauri (quando o projeto usa) precisa do .sig ao lado. + # Include .sig alongside the bundle when updater signing is enabled. cp "$bundle"/appimage/*.AppImage.sig ../../../dist-gui/ 2>/dev/null || true ;; linux-x86_64) @@ -102,24 +102,59 @@ EOF done fetch_cached_tool "linuxdeploy-07333c6-aarch64.AppImage" \ "https://github.com/tauri-apps/binary-releases/releases/download/linuxdeploy-07333c6/linuxdeploy-aarch64.AppImage" 1 + # tauri-bundler looks for this exact cache name (no arch suffix); the + # architecture only appears in the download URL. fetch_cached_tool "linuxdeploy-plugin-appimage.AppImage" \ "https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/continuous/linuxdeploy-plugin-appimage-aarch64.AppImage" 1 + fetch_cached_tool "AppRun-x86_64" \ + "https://github.com/tauri-apps/binary-releases/releases/download/apprun-old/AppRun-x86_64" 0 fetch_cached_tool "runtime-x86_64" \ "https://github.com/AppImage/type2-runtime/releases/download/continuous/runtime-x86_64" 0 - cat >"$HOME/.cache/tauri/linuxdeploy-07333c6-x86_64.AppImage" <<'EOF' -#!/usr/bin/env bash -export ARCH=x86_64 -export NO_STRIP=true -export APPIMAGE_EXTRACT_AND_RUN=1 -export LDAI_RUNTIME_FILE="$HOME/.cache/tauri/runtime-x86_64" -export LD_GTK_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu -export DEB_HOST_MULTIARCH=x86_64-linux-gnu -export PKG_CONFIG_ALLOW_CROSS=1 -export PKG_CONFIG_LIBDIR=/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/share/pkgconfig -export PATH="/tmp/x86_64-cross-tools:$PATH" -exec "$HOME/.cache/tauri/linuxdeploy-07333c6-aarch64.AppImage" "$@" + # tauri-bundler runs `dd ... seek=8` on this path to hide linuxdeploy from + # AppImage integration tools. A shell-script wrapper loses its shebang and + # then fails with ENOENT, so use a native ELF launcher: the dd writes into + # ELF padding and the launcher stays executable. + launcher_src=/tmp/x86_64-cross-tools/linuxdeploy-x86_64.c + launcher_bin="$HOME/.cache/tauri/linuxdeploy-07333c6-x86_64.AppImage" + cat >"$launcher_src" <<'EOF' +#define _POSIX_C_SOURCE 200809L +#include +#include +#include + +int main(int argc, char **argv) { + const char *home = getenv("HOME"); + if (home == NULL) { fputs("HOME is not set\n", stderr); return 127; } + char target[4096]; + char runtime[4096]; + char path[8192]; + const char *old_path = getenv("PATH"); + snprintf(target, sizeof target, "%s/.cache/tauri/linuxdeploy-07333c6-aarch64.AppImage", home); + snprintf(runtime, sizeof runtime, "%s/.cache/tauri/runtime-x86_64", home); + snprintf(path, sizeof path, "/tmp/x86_64-cross-tools:%s", + old_path ? old_path : "/usr/local/bin:/usr/bin:/bin"); + if (setenv("ARCH", "x86_64", 1) || + setenv("NO_STRIP", "true", 1) || + setenv("APPIMAGE_EXTRACT_AND_RUN", "1", 1) || + setenv("LDAI_RUNTIME_FILE", runtime, 1) || + setenv("LD_GTK_LIBRARY_PATH", "/usr/lib/x86_64-linux-gnu", 1) || + setenv("DEB_HOST_MULTIARCH", "x86_64-linux-gnu", 1) || + setenv("PKG_CONFIG_ALLOW_CROSS", "1", 1) || + setenv("PKG_CONFIG_LIBDIR", "/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/share/pkgconfig", 1) || + setenv("PATH", path, 1)) { + perror("setenv"); + return 127; + } + char **args = calloc((size_t)argc + 1, sizeof *args); + if (args == NULL) { perror("calloc"); return 127; } + args[0] = target; + for (int i = 1; i < argc; i++) args[i] = argv[i]; + execv(target, args); + perror(target); + return 127; +} EOF - chmod +x "$HOME/.cache/tauri/linuxdeploy-07333c6-x86_64.AppImage" + cc -O2 -Wall -Wextra -o "$launcher_bin" "$launcher_src" export PKG_CONFIG_ALLOW_CROSS=1 export PKG_CONFIG_LIBDIR=/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/share/pkgconfig export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-linux-gnu-gcc @@ -140,7 +175,7 @@ EOF cp "$bundle"/*-setup.exe ../../../dist-gui/ cp "$bundle"/*-setup.exe.sig ../../../dist-gui/ 2>/dev/null || true ;; - *) echo "plataforma desconhecida: $platform" >&2; exit 2 ;; + *) echo "unknown platform: $platform" >&2; exit 2 ;; esac ls -1 ../../../dist-gui diff --git a/scripts/verificar.sh b/scripts/check.sh similarity index 100% rename from scripts/verificar.sh rename to scripts/check.sh diff --git a/scripts/gerar-logo.py b/scripts/generate-logo.py similarity index 100% rename from scripts/gerar-logo.py rename to scripts/generate-logo.py diff --git a/scripts/instalar-hooks.sh b/scripts/install-hooks.sh similarity index 100% rename from scripts/instalar-hooks.sh rename to scripts/install-hooks.sh