Use the shared nightly launcher template (#5251)

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:
skylar taylor-barrick authored and GitHub committed 2026-11-25 16:17:11 -06:00
1 parent 2d1d1b6920
commit 7303127462
6 files changed
+120 -66

No files matched your search

+8 -3
View File
@@ -209,10 +209,15 @@ per-run human approval is introduced by candidate-v3; provider gaps remain block
A Nightly build refuses to start without its private profile, and refuses the stable
`FILMCRAFT_DATA_DIR` override, so every Linux format starts the GUI through the Launcher's literal
protocol `--launch-profile nightly-v1 --profile-root <dir> -- <files>`. The profile is
protocol `--launch-profile nightly-v1 --profile-root <dir> -- <files>`. The deb/rpm wrapper, the
AppImage's `AppRun`, the Arch handoff and the Flatpak use
`${XDG_DATA_HOME:-$HOME/.local/share}/filmcraft-nightly/profile` (outside stable's folders and
outside the installed copy, which the app's own fence would reject). A first-argument `--version`
or `-V`, and an already-named protocol, pass through untouched, so version queries still answer.
outside the installed copy, which the app's own fence would reject). The plain tar is the exception:
its `filmcraft` is craft-common-actions' shared launcher template, rendered for this app, whose
default root is `${XDG_DATA_HOME:-$HOME/.local/share}/ai.storyteller.filmcraft.nightly`. A
first-argument `--version` or `-V` still answers, and a first-argument `--launch-profile` pair is
forwarded unchanged; the packaged launchers also pass `--profile-root`, `--help` and `-h` through
untouched, which the plain tar's narrower template does not.
| Format | Shape |
|---|---|
+43 -42
View File
@@ -1,7 +1,10 @@
#!/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), which is the
# canonical shared template from craft-common-actions: a launch starts `filmcraft-bin` beside the
# script with the Launcher's private profile under the Nightly package identity, a version query
# reaches the GUI as one plain `--version`, and every other argument is a file argument. The distro
# tarball's own launcher (packaging/linux/nightly-package-launch.sh) is pinned by
# packaging/nightly-release-tests.py.
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -17,52 +20,50 @@ RECORDER
chmod 755 "$work/tree/filmcraft-bin"
cp "$HERE/nightly-launch.sh" "$work/tree/filmcraft"
profile="${XDG_DATA_HOME:-${HOME:-}/.local/share}/filmcraft-nightly/profile"
# 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
expect_launch() {
expected="$(printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$profile" -- "$@")"
actual=$("$work/tree/filmcraft" "$@")
[[ "$actual" == "$expected" ]] || {
printf 'expected:\n%s\nactual:\n%s\n' "$expected" "$actual" >&2
exit 1
}
}
expect_forwarded() {
expected="$(printf '<%s>\n' "$@")"
identity=ai.storyteller.filmcraft.nightly
profile="${XDG_DATA_HOME:-${HOME:-}/.local/share}/$identity"
expect() {
expected="$1"
shift
actual=$("$work/tree/filmcraft" "$@")
[[ "$actual" == "$expected" ]] || {
printf 'expected:\n%s\nactual:\n%s\n' "$expected" "$actual" >&2
exit 1
}
}
launch() { printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$profile" -- "$@"; }
expect_launch
expect_launch 'project with spaces.fcproj' '--other-name.fcproj'
# A caller-written `--` is dropped: the launcher's own separator must arrive once, never twice,
# and what follows the caller's separator stays a file name (here `--version`).
expected="$(printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$profile" -- 'project with spaces.fcproj' --version)"
actual=$("$work/tree/filmcraft" -- 'project with spaces.fcproj' --version)
[[ "$actual" == "$expected" ]] || {
printf 'caller separator:\nexpected:\n%s\nactual:\n%s\n' "$expected" "$actual" >&2
# The profile is the identity's own folder: absolute and outside the unpacked copy.
case "$profile" in /*) ;; *) echo "FAIL: the profile is not absolute: $profile" >&2; exit 1 ;; esac
case "$profile/" in "$work/tree/"*) echo "FAIL: the profile is inside the unpacked copy" >&2; exit 1 ;; esac
expect "$(launch)"
expect "$(launch 'project with spaces.fcproj' '--other-name.fcproj')" 'project with spaces.fcproj' '--other-name.fcproj'
# A file spelled like a flag is a file once the caller writes the delimiter, and only the first
# argument can be a version query: the template keeps the caller's own `--`, so it arrives once more.
expect "$(launch -- --version)" -- --version
# Both version spellings reach the GUI as one plain `--version`.
expect "$(printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$profile" --version)" --version
expect "$(printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$profile" --version)" -V
# The ArtCraft Launcher starts the entry point with its own profile pair and per-install root; the
# template hands that line to the GUI unchanged.
expect "$(printf '<%s>\n' --launch-profile nightly-v1 --profile-root '/launcher profile' -- a.fcproj)" \
--launch-profile nightly-v1 --profile-root '/launcher profile' -- a.fcproj
# Anything else is wrapped in the template's own root, including a profile line that does not open
# the arguments.
expect "$(launch --profile-root /launcher/profile --)" --profile-root /launcher/profile --
# XDG_DATA_HOME decides the root when it is set.
XDG_DATA_HOME="$work/xdg with space" expect "$(printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$work/xdg with space/$identity" -- b.fcproj)" b.fcproj
# Nothing but the GUI beside the script is started, and no data folder means no launch.
mv "$work/tree/filmcraft-bin" "$work/moved"
if "$work/tree/filmcraft" a.fcproj >/dev/null 2>&1; then
echo "FAIL: the launcher started without its GUI beside it" >&2
exit 1
}
expect_forwarded --version
expect_forwarded -V
expect_forwarded --help
expect_forwarded -h
expect_forwarded --launch-profile nightly-v1 --profile-root /launcher/profile --version
expect_forwarded --launch-profile nightly-v1 --profile-root /launcher/profile -- a.fcproj
fi
mv "$work/moved" "$work/tree/filmcraft-bin"
if env -u XDG_DATA_HOME -u HOME "$work/tree/filmcraft" a.fcproj >/dev/null 2>&1; then
echo "FAIL: the launcher started without a data folder" >&2
exit 1
fi
echo "PASS: tarball Nightly launcher starts the GUI with the Launcher profile and forwards files"
+12 -19
View File
@@ -1,23 +1,16 @@
#!/bin/sh
# The entry point inside the Nightly tarball (packaging/linux/nightly.sh stages it as `filmcraft`,
# beside the GUI as `filmcraft-bin`), and the form every other Nightly Linux package installs.
#
# 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 (settings, recovery autosaves, media cache, presets, logs,
# models) 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/filmcraft-bin"
profile="${XDG_DATA_HOME:-${HOME:-}/.local/share}/filmcraft-nightly/profile"
# The Launcher's protocol, a bare version query and the usage screen pass through untouched: the
# first already names its profile, the others must answer without one.
dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)
readonly dir
target="$dir/filmcraft-bin"
readonly target
profile_root="${XDG_DATA_HOME:-$HOME/.local/share}/ai.storyteller.filmcraft.nightly"
readonly profile_root
case "${1-}" in
--launch-profile | --profile-root | --version | -V | --help | -h) 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
# A caller-written `--` already separates the files from the options: drop it, so the launcher's
# own separator never arrives as a file name.
if [ "${1-}" = -- ]; then shift; fi
exec "$bin" --launch-profile nightly-v1 --profile-root "$profile" -- "$@"
exec "$target" --launch-profile nightly-v1 --profile-root "$profile_root" -- "$@"
+27
View File
@@ -0,0 +1,27 @@
#!/bin/sh
# The FilmCraft Nightly launcher inside the distro tarball package.sh builds (bin/filmcraft beside
# bin/filmcraft-bin). Those distro artifacts keep their own profile folder
# (`XDG_DATA_HOME/filmcraft-nightly/profile`); the plain nightly tar the Launcher installs uses the
# canonical shared template in nightly-launch.sh instead.
# The entry point inside the Nightly tarball (packaging/linux/nightly.sh stages it as `filmcraft`,
# beside the GUI as `filmcraft-bin`), and the form every other Nightly Linux package installs.
#
# 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 (settings, recovery autosaves, media cache, presets, logs,
# models) and outside this unpacked copy, which the app's own fence would refuse.
set -eu
here="$(dirname "$(readlink -f "$0")")"
bin="$here/filmcraft-bin"
profile="${XDG_DATA_HOME:-${HOME:-}/.local/share}/filmcraft-nightly/profile"
# The Launcher's protocol, a bare version query and the usage screen pass through untouched: the
# first already names its profile, the others must answer without one.
case "${1-}" in
--launch-profile | --profile-root | --version | -V | --help | -h) exec "$bin" "$@" ;;
esac
# A caller-written `--` already separates the files from the options: drop it, so the launcher's
# own separator never arrives as a file name.
if [ "${1-}" = -- ]; then shift; fi
exec "$bin" --launch-profile nightly-v1 --profile-root "$profile" -- "$@"
+1 -1
View File
@@ -128,7 +128,7 @@ if has tar; then
# A Nightly binary only starts with its private profile, so an unpacked tarball gets the same
# launcher the other Nightly formats install: `filmcraft` starts `filmcraft-bin`.
mv "$WORK/tar/$BASENAME/bin/filmcraft" "$WORK/tar/$BASENAME/bin/filmcraft-bin"
install -Dm755 "$HERE/nightly-launch.sh" "$WORK/tar/$BASENAME/bin/filmcraft"
install -Dm755 "$HERE/nightly-package-launch.sh" "$WORK/tar/$BASENAME/bin/filmcraft"
fi
install -m755 "$HERE/install.sh" "$WORK/tar/$BASENAME/install.sh"
tar -C "$WORK/tar" -czf "$DIST/$BASENAME.tar.gz" "$BASENAME"
+29 -1
View File
@@ -679,11 +679,13 @@ class LinuxNightlyLaunchers(unittest.TestCase):
PROFILE = "${XDG_DATA_HOME:-${HOME:-}/.local/share}/filmcraft-nightly/profile"
def launchers(self):
"""The distro artifacts' launchers. The plain Nightly tar is the canonical shared template
instead (packaging/linux/nightly-launch.sh), pinned by LinuxNightlyTarTemplate below."""
package = (ROOT / "packaging/linux/package.sh").read_text()
heredocs = re.findall(r"<<'WRAPPER'\n(.*?)\nWRAPPER\n", package, re.DOTALL)
self.assertGreaterEqual(len(heredocs), 1, "the deb/rpm Nightly wrapper is missing")
files = {}
for name, path in (("tarball", "packaging/linux/nightly-launch.sh"),
for name, path in (("tarball", "packaging/linux/nightly-package-launch.sh"),
("arch", "packaging/linux/nightly-arch-launch.sh"),
("apprun", "packaging/linux/AppRun"),
("flatpak", "packaging/linux/flatpak-bundle.sh")):
@@ -705,6 +707,32 @@ class LinuxNightlyLaunchers(unittest.TestCase):
# arrive at the app as a file name.
self.assertIn('if [ "${1-}" = -- ]; then shift; fi', source)
class LinuxNightlyTarTemplate(unittest.TestCase):
"""The plain Nightly tar's launcher is the canonical shared template, byte for byte.
It is rendered from craft-common-actions scripts/nightly-launcher.sh.in for this app's registry
row (entrypoint `filmcraft`, binary `filmcraft-bin`, identity ai.storyteller.filmcraft.nightly),
which is what the shared nightly producer checks the archive's entry point against.
"""
def test_the_tar_launcher_is_the_rendered_shared_template(self):
source = (ROOT / "packaging/linux/nightly-launch.sh").read_text()
self.assertIn("# Nightly launcher generated by craft-common-actions scripts/nightly-launcher.sh.in.", source)
self.assertIn('dir=$(CDPATH=\'\' cd -- "$(dirname -- "$0")" && pwd -P)', source)
self.assertIn('target="$dir/filmcraft-bin"', source)
self.assertIn('profile_root="${XDG_DATA_HOME:-$HOME/.local/share}/ai.storyteller.filmcraft.nightly"', source)
# The Launcher's own profile line passes through; a version query answers with one plain
# `--version`; every other argument is wrapped in the fixed profile.
self.assertIn(' --launch-profile) exec "$target" "$@" ;;', source)
self.assertIn(' --version | -V) exec "$target" --launch-profile nightly-v1 --profile-root "$profile_root" --version ;;', source)
self.assertIn('exec "$target" --launch-profile nightly-v1 --profile-root "$profile_root" -- "$@"', source)
for placeholder in ("@BINARY@", "@APP_ID@"):
self.assertNotIn(placeholder, source, "the template is rendered, not a placeholder")
self.assertEqual([line for line in source.splitlines() if "--launch-profile" in line],
[' --launch-profile) exec "$target" "$@" ;;',
' --version | -V) exec "$target" --launch-profile nightly-v1 --profile-root "$profile_root" --version ;;',
'exec "$target" --launch-profile nightly-v1 --profile-root "$profile_root" -- "$@"'])
def test_no_linux_wrapper_routes_the_profile_through_the_environment(self):
# The flavor refuses FILMCRAFT_DATA_DIR with a nightly profile: a wrapper that exported it
# would make its own package exit 2.