build_all --ram: move flatpak state dir to tmpfs too (same-fs requirement)

flatpak-builder hardlinks between its state dir and the build dir, so they must
share a filesystem. With only the build dir on tmpfs it errored ('state dir not
on the same filesystem as the target dir'). Move .flatpak-builder to tmpfs as
well via FLATPAK_STATEDIR; its download cache no longer persists across --ram
runs, which is the accepted trade for the tmpfs speedup.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-05-30 10:50:57 +02:00
parent f748dae369
commit ab3058d789
2 changed files with 18 additions and 11 deletions

View File

@@ -83,18 +83,21 @@ source "$SCRIPT_DIR/scripts/set_env.sh"
# ---------- RAM mode: put build scratch on tmpfs (--ram) ----------------------
# On slow storage (USB stick, SD card) the per-channel build dirs and temp
# churn dominate. --ram redirects them to /dev/shm and skips UPX. The
# .flatpak-builder cache stays on disk so source downloads persist. The tmpfs
# scratch is freed on exit.
# churn dominate. --ram redirects them to /dev/shm and skips UPX. The whole
# Flatpak working set (build dir + .flatpak-builder + repo) goes to tmpfs
# because flatpak-builder requires its state dir on the same filesystem as the
# build dir — so its download cache doesn't persist across --ram runs. The
# tmpfs scratch is freed on exit.
if [ "$RAM" -eq 1 ]; then
RAMROOT="/dev/shm/testium-build-${VERSION}"
echo "-- RAM mode: build scratch under $RAMROOT (tmpfs), freed on exit"
rm -rf "$RAMROOT"
mkdir -p "$RAMROOT"/{tmp,pip,pyi-work,flatpak-build,flatpak-repo,appdir}
mkdir -p "$RAMROOT"/{tmp,pip,pyi-work,flatpak-build,flatpak-state,flatpak-repo,appdir}
export TMPDIR="$RAMROOT/tmp"
export PIP_CACHE_DIR="$RAMROOT/pip"
export PYI_WORKPATH="$RAMROOT/pyi-work" # pyinstaller --workpath
export FLATPAK_BUILDDIR="$RAMROOT/flatpak-build" # flatpak-builder build dir
export FLATPAK_STATEDIR="$RAMROOT/flatpak-state" # .flatpak-builder (same fs as build dir, required)
export FLATPAK_REPODIR="$RAMROOT/flatpak-repo" # ostree repo
export APPIMAGE_APPDIR_TMPFS="$RAMROOT/appdir" # AppDir bind-mount
export TESTIUM_NO_UPX=1 # skip slow UPX in the spec

View File

@@ -7,12 +7,16 @@
set -e
# Build + install local. FLATPAK_BUILDDIR / FLATPAK_REPODIR (set by build_all
# --ram) redirect the build dir and the ostree repo to tmpfs. The
# .flatpak-builder cache stays local so source downloads persist between runs.
# Build + install local. FLATPAK_BUILDDIR / FLATPAK_STATEDIR / FLATPAK_REPODIR
# (set by build_all --ram) redirect the build dir, the state dir
# (.flatpak-builder) and the ostree repo to tmpfs. flatpak-builder hardlinks
# between the state dir and the build dir, so they MUST be on the same
# filesystem — hence the state dir moves to tmpfs too (its download cache then
# doesn't persist across --ram runs).
BUILDDIR="${FLATPAK_BUILDDIR:-build}"
STATEDIR="${FLATPAK_STATEDIR:-.flatpak-builder}"
REPODIR="${FLATPAK_REPODIR:-repo}"
flatpak-builder --user --verbose --force-clean --install --repo="$REPODIR" "$BUILDDIR" org.testium.Testium.yaml
flatpak-builder --user --verbose --force-clean --install --state-dir="$STATEDIR" --repo="$REPODIR" "$BUILDDIR" org.testium.Testium.yaml
# Génère le bundle distribuable
flatpak build-bundle "$REPODIR" testium.flatpak org.testium.Testium