Use the shared nightly launcher template (#9316)

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
2026-11-25 16:17:47 -06:00
committed by GitHub
parent 694f66a7bd
commit 016ead2572
4 changed files with 117 additions and 9 deletions
+12 -7
View File
@@ -93,13 +93,18 @@ build root every helper stays inside). `packaging/nightly-tests.py` runs the syn
runs them with the Windows PowerShell suites, and `.github/workflows/nightly-macos.yml` builds and
verifies the unsigned bundle behind the `full-ci` label.
Every Linux Nightly format starts the app the same way, through one launcher
(`packaging/linux/nightly-launch.sh`): the plain tar's `vectorcraft`, the deb/rpm's
`/usr/bin/vectorcraft-nightly`, the AppImage's `AppRun`, the Arch handoff's `bin/vectorcraft` and
the Flatpak's `/app/bin/vectorcraft`. It runs the GUI beside it (`<app>-bin`, the standard Nightly
layout; `/usr/lib/vectorcraft-nightly/vectorcraft-bin` for deb/rpm, `/app/libexec/vectorcraft-bin`
inside the Flatpak) with `--launch-profile nightly-v1 --profile-root <dir> -- "$@"`, and passes a
version query, help or the Launcher's own `--launch-profile` invocation straight through. The
Every packaged Linux Nightly format starts the app the same way, through one launcher
(`packaging/linux/nightly-launch.sh`): the deb/rpm's `/usr/bin/vectorcraft-nightly`, the AppImage's
`AppRun`, the Arch handoff's `bin/vectorcraft` and the Flatpak's `/app/bin/vectorcraft`. It runs the
GUI beside it (`<app>-bin`, the standard Nightly layout;
`/usr/lib/vectorcraft-nightly/vectorcraft-bin` for deb/rpm, `/app/libexec/vectorcraft-bin` inside the
Flatpak) with `--launch-profile nightly-v1 --profile-root <dir> -- "$@"`, and passes a version query,
help or the Launcher's own `--launch-profile` invocation straight through. The plain tar's
`vectorcraft` is craft-common-actions' shared template instead
(`packaging/linux/nightly-tar-launch.sh`, #363 rendered for this app): it adds its own tokens unless the first argument is already a `--launch-profile` pair,
execs `vectorcraft-bin` beside it with
`--profile-root <${XDG_DATA_HOME:-~/.local/share}/ai.storyteller.vectorcraft.nightly> --`, and asks a
bare `--version`/`-V` in the Launcher's form. The
Nightly tar therefore holds `vectorcraft` (launcher), `vectorcraft-bin` (GUI), `vectorcraft.png`
(the Nightly art) and the notices.
+85
View File
@@ -4,6 +4,7 @@
No build and no window: a recorder script stands in for the GUI, so the argv and environment the
launcher passes are read directly.
"""
import hashlib
import os
import subprocess
import sys
@@ -13,6 +14,10 @@ from pathlib import Path
HERE = Path(__file__).resolve().parent
LAUNCHER = HERE / "nightly-launch.sh"
# The plain tar's entrypoint is craft-common-actions' template rendered for this app; these are its bytes.
TAR_LAUNCHER = HERE / "nightly-tar-launch.sh"
TAR_PROFILE = "ai.storyteller.vectorcraft.nightly"
TAR_LAUNCHER_SHA256 = "bf00f60a1644c1fd0ce440f4c992cd009f812e539c729a4b63638b1b8aed0c01"
RECORDER = """#!/bin/sh
printf 'config=<%s>\n' "${VECTORCRAFT_CONFIG_DIR:-}"
@@ -167,5 +172,85 @@ class Launchers(unittest.TestCase):
self.assertIn("app binary is missing", result.stderr)
class TarLauncher(unittest.TestCase):
"""The plain tar's entrypoint: the shared template, rendered for VectorCraft."""
def setUp(self):
self.scratch = tempfile.TemporaryDirectory()
self.addCleanup(self.scratch.cleanup)
self.root = Path(self.scratch.name).resolve()
self.home = self.root / "home with space"
self.home.mkdir()
self.env = {"HOME": str(self.home), "PATH": "/usr/bin:/bin"}
def place(self):
"""The kit's flat tar: the `vectorcraft` launcher beside the `vectorcraft-bin` GUI."""
tree = self.root / "tar"
tree.mkdir()
(tree / "vectorcraft-bin").write_text(RECORDER, encoding="utf-8")
(tree / "vectorcraft-bin").chmod(0o755)
(tree / "vectorcraft").write_bytes(TAR_LAUNCHER.read_bytes())
(tree / "vectorcraft").chmod(0o755)
return tree / "vectorcraft"
def lines(self, launcher, *args, env=None):
result = subprocess.run([str(launcher), *args], cwd=str(self.root), env=env or self.env,
capture_output=True, text=True, timeout=30)
self.assertEqual(result.returncode, 0, result.stderr)
return result.stdout.splitlines()
def test_every_argument_follows_the_profile_tokens(self):
launcher = self.place()
root = f"{self.home}/.local/share/{TAR_PROFILE}"
tokens = ["config=<>", "<--launch-profile>", "<nightly-v1>", "<--profile-root>", f"<{root}>"]
self.assertEqual(self.lines(launcher), [*tokens, "<-->"])
self.assertEqual(self.lines(launcher, "drawing with spaces.svg", "--other-name.svg"),
[*tokens, "<-->", "<drawing with spaces.svg>", "<--other-name.svg>"])
def test_the_profile_follows_xdg_data_home(self):
launcher = self.place()
xdg = self.root / "xdg with space"
env = dict(self.env, XDG_DATA_HOME=str(xdg))
self.assertEqual(self.lines(launcher, "drawing.svg", env=env),
["config=<>", "<--launch-profile>", "<nightly-v1>", "<--profile-root>",
f"<{xdg / TAR_PROFILE}>", "<-->", "<drawing.svg>"])
self.assertFalse(xdg.exists(), "the launcher creates no folder of its own")
def test_a_version_query_asks_the_gui_in_the_launcher_form(self):
launcher = self.place()
root = f"{self.home}/.local/share/{TAR_PROFILE}"
for query in ("--version", "-V"):
with self.subTest(query=query):
self.assertEqual(self.lines(launcher, query),
["config=<>", "<--launch-profile>", "<nightly-v1>", "<--profile-root>",
f"<{root}>", "<--version>"])
def test_a_launcher_profile_argv_passes_through_unchanged(self):
launcher = self.place()
argv = ["--launch-profile", "nightly-v1", "--profile-root", str(self.root / "launcher root"), "--", "drawing.svg"]
self.assertEqual(self.lines(launcher, *argv, env=self.env),
["config=<>", *[f"<{arg}>" for arg in argv]])
def test_a_missing_gui_fails_rather_than_starting_another_binary(self):
launcher = self.place()
(self.root / "tar/vectorcraft-bin").unlink()
result = subprocess.run([str(launcher)], cwd=str(self.root), env=self.env,
capture_output=True, text=True, timeout=30)
self.assertNotEqual(result.returncode, 0)
self.assertEqual(result.stdout, "")
def test_the_bytes_are_the_shared_template_rendered_for_vectorcraft(self):
data = TAR_LAUNCHER.read_bytes()
self.assertEqual(hashlib.sha256(data).hexdigest(), TAR_LAUNCHER_SHA256,
"the tar launcher must stay byte for byte scripts/nightly-launcher.sh.in rendered for vectorcraft")
self.assertIn(b'target="$dir/vectorcraft-bin"', data)
self.assertIn(f'{TAR_PROFILE}"'.encode(), data)
def test_the_flat_tar_stages_the_template(self):
source = (HERE / "nightly.sh").read_text(encoding="utf-8")
self.assertIn('"$ROOT/packaging/linux/nightly-tar-launch.sh" "$STAGE/vectorcraft"', source)
self.assertNotIn('"$ROOT/packaging/linux/nightly-launch.sh" "$STAGE/vectorcraft"', source)
if __name__ == "__main__":
unittest.main()
+16
View File
@@ -0,0 +1,16 @@
#!/bin/sh
# 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
dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)
readonly dir
target="$dir/vectorcraft-bin"
readonly target
profile_root="${XDG_DATA_HOME:-$HOME/.local/share}/ai.storyteller.vectorcraft.nightly"
readonly profile_root
case "${1-}" in
# 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 "$target" --launch-profile nightly-v1 --profile-root "$profile_root" -- "$@"
+4 -2
View File
@@ -19,10 +19,12 @@ nightly_build_gui
STAGE="$NIGHTLY_WORK/stage"
mkdir -p "$STAGE"
# The standard Nightly layout: `<app>` is the launcher and `<app>-bin` the GUI it starts, so an
# unpacked tar is isolated like the packages and the shared smoke can query the entrypoint.
# unpacked tar is isolated like the packages and the shared smoke can query the entrypoint. The
# launcher is craft-common-actions' canonical template rendered for this app (scripts/nightly_app.py
# launcher); the formats package.sh stages keep their own launcher.
cp "$NIGHTLY_GUI" "$STAGE/vectorcraft-bin"
chmod 755 "$STAGE/vectorcraft-bin"
cp "$ROOT/packaging/linux/nightly-launch.sh" "$STAGE/vectorcraft"
cp "$ROOT/packaging/linux/nightly-tar-launch.sh" "$STAGE/vectorcraft"
chmod 755 "$STAGE/vectorcraft"
# The Nightly art, not stable's: with both channels open the two tars must not share an icon.
cp "$ROOT/assets/app-icon/vectorcraft-nightly.png" "$STAGE/vectorcraft.png"