mirror of
https://github.com/storytold/texturecraft.git
synced 2026-11-26 17:30:45 +01:00
Use the shared nightly launcher template (#835)
Renders the plain nightly tar's launcher from craft-common-actions' shared template. Independent check: dylanmtaylor compared all 14 app launcher PRs byte for byte with the template rendered from the registry (https://github.com/storytold/craft-common-actions/pull/367#issuecomment-7172085284); this head was re-checked against craft-common-actions main 88148a5.
This commit is contained in:
1 parent
2d86cc04ba
commit
dcf91a4f05
3 files changed
+68
-48
No files matched your search
@@ -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
|
||||
|
||||
@@ -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"
|
||||
@@ -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 <dir> -- <files>`. The
|
||||
# profile sits outside stable's folders (its own settings, ui.json, crash log, autosaves, smart
|
||||
# materials, layouts, templates and presets) and outside this unpacked copy, which the app's own
|
||||
# fence would refuse.
|
||||
# Nightly launcher generated by craft-common-actions scripts/nightly-launcher.sh.in. Do not edit:
|
||||
# the shared nightly producer accepts this file only byte for byte as rendered for the app.
|
||||
set -eu
|
||||
|
||||
here="$(dirname "$(readlink -f "$0")")"
|
||||
bin="$here/texturecraft-bin"
|
||||
profile="${XDG_DATA_HOME:-${HOME:-}/.local/share}/TextureCraft-Nightly"
|
||||
|
||||
# The Launcher's protocol, and a bare version query, pass through untouched: the first already
|
||||
# names its profile, and the second must answer without one.
|
||||
dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)
|
||||
readonly dir
|
||||
target="$dir/texturecraft-bin"
|
||||
readonly target
|
||||
profile_root="${XDG_DATA_HOME:-$HOME/.local/share}/ai.storyteller.texturecraft.nightly"
|
||||
readonly profile_root
|
||||
case "${1-}" in
|
||||
--launch-profile | --profile-root | --version | -V) exec "$bin" "$@" ;;
|
||||
# The ArtCraft Launcher passes its own profile and per-install root; the app validates the pair.
|
||||
--launch-profile) exec "$target" "$@" ;;
|
||||
--version | -V) exec "$target" --launch-profile nightly-v1 --profile-root "$profile_root" --version ;;
|
||||
esac
|
||||
exec "$bin" --launch-profile nightly-v1 --profile-root "$profile" -- "$@"
|
||||
exec "$target" --launch-profile nightly-v1 --profile-root "$profile_root" -- "$@"
|
||||
Reference in new issue
Block a user