diff --git a/docs/nightly-release-preparation.md b/docs/nightly-release-preparation.md index 2b504a7e..28114854 100644 --- a/docs/nightly-release-preparation.md +++ b/docs/nightly-release-preparation.md @@ -95,11 +95,14 @@ those values in the same reviewed change that promotes the policy to `release`. ## App-side producer scripts (Windows and macOS) **Every Linux Nightly format starts the app the flavor's way.** The `.deb`/`.rpm` wrapper, the -Arch launcher, the Flatpak wrapper, the AppImage's `AppRun` and the launcher inside the plain -`nightly.tar.gz` all exec the real GUI with the literal +Arch launcher, the Flatpak wrapper and the AppImage's `AppRun` all exec the real GUI with the literal `--launch-profile nightly-v1 --profile-root <${XDG_DATA_HOME:-~/.local/share}/TextureCraft-Nightly> --`, and pass a Launcher protocol or a `--version`/`-V` query through untouched (so the smoke checks and -`texturecraft-nightly --version` still answer). The profile is outside stable's folders and outside +`texturecraft-nightly --version` still answer). The plain `nightly.tar.gz` (and `package.sh`'s tree tarball, which installs the same file) uses craft-common-actions' +shared launcher template (#363, rendered for this app) instead: its `texturecraft` adds its own +tokens unless the first argument is already a `--launch-profile` pair, execs `texturecraft-bin` beside it with +`--profile-root <${XDG_DATA_HOME:-~/.local/share}/ai.storyteller.texturecraft.nightly> --`, and asks a +bare `--version`/`-V` in the Launcher's own form. The profile is outside stable's folders and outside the unpacked or installed copy, which the flavor's fence would otherwise refuse. Every Nightly Linux format is GUI only. `texturecraft-cli` stays in the Stable packages: a headless diff --git a/packaging/linux/nightly-launch-test.sh b/packaging/linux/nightly-launch-test.sh index 4da17cd3..608de4b0 100755 --- a/packaging/linux/nightly-launch-test.sh +++ b/packaging/linux/nightly-launch-test.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -# The launcher inside the plain Nightly tarball (packaging/linux/nightly-launch.sh): a launch adds -# the Launcher's private profile, a version query or an existing protocol passes through, and the -# fence's shape holds (absolute root, no parent traversal, outside this copy). +# The launcher inside the plain Nightly tarball (packaging/linux/nightly-launch.sh): craft-common-actions' +# template rendered for TextureCraft. Every argument follows the profile tokens, the profile root is the +# package identity under the XDG data home (or HOME), and a version query is asked in the Launcher's +# own form so the GUI answers before any profile is read. set -euo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" @@ -16,42 +17,63 @@ printf '<%s>\n' "$@" RECORDER chmod 755 "$work/tree/texturecraft-bin" cp "$HERE/nightly-launch.sh" "$work/tree/texturecraft" +chmod 755 "$work/tree/texturecraft" -profile="${XDG_DATA_HOME:-${HOME:-}/.local/share}/TextureCraft-Nightly" -# The profile must be something the app's fence accepts: absolute, no parent traversal, and not -# inside the unpacked copy (the running install). -case "$profile" in - /*) ;; - *) echo "FAIL: the launcher profile is not absolute: $profile" >&2; exit 1 ;; -esac -case "/$profile/" in - */../*) echo "FAIL: the launcher profile contains parent traversal" >&2; exit 1 ;; -esac -case "$profile/" in - "$work/tree/"*) echo "FAIL: the launcher profile is inside the unpacked copy" >&2; exit 1 ;; -esac +# The bytes are the shared template rendered for this app, not a local script. +sha256sum "$HERE/nightly-launch.sh" | cut -d' ' -f1 | grep -qx \ + 8941ee4947ef4c3fc4a663600569d985b41c0b9ce6f9833d0c6777aa2b4d6acf || { + echo "FAIL: nightly-launch.sh is not the shared template rendered for texturecraft" >&2 + exit 1 +} +head -n 1 "$work/tree/texturecraft" | grep -qx '#!/bin/sh' || { echo "FAIL: texturecraft is not a script" >&2; exit 1; } -expect_launch() { - expected="$(printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$profile" -- "$@")" +# A hand-unpacked tar has to start the private profile even when nobody passes a flag. +export HOME="$work/home with space" +unset XDG_DATA_HOME +identity="ai.storyteller.texturecraft.nightly" + +expect() { + local root="$1" + shift + expected="$(printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$root" -- "$@")" actual=$("$work/tree/texturecraft" "$@") + [[ "$actual" == "$expected" ]] || { + printf 'profile root %s\nexpected:\n%s\nactual:\n%s\n' "$root" "$expected" "$actual" >&2 + exit 1 + } +} + +expect_query() { + local root="$1" + expected="$(printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$root" --version)" + actual=$("$work/tree/texturecraft" --version) [[ "$actual" == "$expected" ]] || { printf 'expected:\n%s\nactual:\n%s\n' "$expected" "$actual" >&2 exit 1 } -} -expect_forwarded() { - expected="$(printf '<%s>\n' "$@")" - actual=$("$work/tree/texturecraft" "$@") + actual=$("$work/tree/texturecraft" -V) [[ "$actual" == "$expected" ]] || { printf 'expected:\n%s\nactual:\n%s\n' "$expected" "$actual" >&2 exit 1 } } -expect_launch -expect_launch 'model with spaces.glb' '--other-name.tcraft' -expect_forwarded --version -expect_forwarded -V -expect_forwarded --launch-profile nightly-v1 --profile-root /launcher/profile --version +expect "$HOME/.local/share/$identity" +expect "$HOME/.local/share/$identity" 'model with spaces.glb' '--other-name.tcraft' +export XDG_DATA_HOME="$work/xdg with space" +expect "$XDG_DATA_HOME/$identity" 'model.glb' +expect_query "$XDG_DATA_HOME/$identity" +unset XDG_DATA_HOME +expect_query "$HOME/.local/share/$identity" -echo "PASS: tarball Nightly launcher starts the GUI with the Launcher profile and forwards files" +# The ArtCraft Launcher names its own profile and per-install root: the argv goes through unchanged. +actual=$("$work/tree/texturecraft" --launch-profile nightly-v1 --profile-root "$work/launcher profile with space" -- file.doc) +[[ "$actual" == "$(printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$work/launcher profile with space" -- file.doc)" ]] || { + printf 'expected the Launcher argv unchanged\nactual:\n%s\n' "$actual" >&2 + exit 1 +} + +# The launcher itself writes nothing: the profile folder is the GUI's to create. +[[ ! -e "$HOME/.local/share/$identity" ]] || { echo "FAIL: the launcher created the profile" >&2; exit 1; } + +echo "PASS: the tarball launcher is the shared template and starts the GUI through the channel's profile" diff --git a/packaging/linux/nightly-launch.sh b/packaging/linux/nightly-launch.sh index 77fa7d9c..ef4361a8 100755 --- a/packaging/linux/nightly-launch.sh +++ b/packaging/linux/nightly-launch.sh @@ -1,21 +1,16 @@ #!/bin/sh -# The entry point inside the Nightly tarball (packaging/linux/nightly.sh installs it as -# `texturecraft`, beside the GUI as `texturecraft-bin`). -# -# A Nightly build only starts with its private profile, and every package format passes the -# Launcher's literal protocol: `--launch-profile nightly-v1 --profile-root