mirror of
https://github.com/storytold/materialcraft.git
synced 2026-11-29 01:23:53 +01:00
Use the shared nightly launcher template (#321)
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
a52a8ff951
commit
83e7d0112b
3 files changed
+54
-27
No files matched your search
+10
-6
@@ -124,13 +124,17 @@ signing or publication pipeline.
|
||||
|
||||
A Nightly build only starts with the Launcher's protocol (`--launch-profile nightly-v1
|
||||
--profile-root <dir> -- files...`), and every Linux nightly format starts it that way: the deb/rpm
|
||||
wrapper (`/usr/bin/materialcraft-nightly`), the AppImage `AppRun`, the Arch launcher, the Flatpak
|
||||
command and the `materialcraft-nightly` launcher inside the plain nightly `.tar.gz`. They all use
|
||||
`$XDG_DATA_HOME/materialcraft-nightly` (the nightly Flatpak uses the same folder inside its own
|
||||
sandbox), so an installed, integrated, extracted or unpacked nightly keeps its autosaves, saved
|
||||
layout and preview cache out of `~/Documents/MaterialCraft` and the stable cache. A plain
|
||||
wrapper (`/usr/bin/materialcraft-nightly`), the AppImage `AppRun`, the Arch launcher and the Flatpak
|
||||
command use `$XDG_DATA_HOME/materialcraft-nightly` (the nightly Flatpak uses the same folder inside
|
||||
its own sandbox), so an installed, integrated, extracted or unpacked nightly keeps its autosaves,
|
||||
saved layout and preview cache out of `~/Documents/MaterialCraft` and the stable cache. A plain
|
||||
`--version` (and the Launcher's query form) is passed straight to the binary, which answers it
|
||||
without creating the profile. Stable `release.yml`, its schedule, tags, concurrency,
|
||||
without creating the profile. The plain nightly `.tar.gz` is the one format whose launcher is not
|
||||
ours: its `materialcraft` is craft-common-actions' shared template (craft-common-actions #363,
|
||||
rendered for this app), which adds its own profile tokens unless the first argument is already a `--launch-profile` pair,
|
||||
names the GUI `materialcraft-bin`
|
||||
beside it and uses `$XDG_DATA_HOME/ai.storyteller.materialcraft.nightly`, and which asks a bare
|
||||
`--version`/`-V` in the Launcher's own form. Stable `release.yml`, its schedule, tags, concurrency,
|
||||
environment values and environment rules are unchanged.
|
||||
|
||||
Initial installation **and later signer/policy updates** ride an already-intended reviewed
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#!/bin/sh
|
||||
# The launcher inside MaterialCraft Nightly's flat tar, installed as `materialcraft`: an unpacked
|
||||
# copy starts the GUI beside it (`materialcraft-bin`) the flavor's way -- with this channel's own
|
||||
# launch profile -- so it never reads or writes stable's settings, window state or recovery copies.
|
||||
# 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 "$0")"
|
||||
dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)
|
||||
readonly dir
|
||||
target="$dir/materialcraft-bin"
|
||||
readonly target
|
||||
profile_root="${XDG_DATA_HOME:-$HOME/.local/share}/ai.storyteller.materialcraft.nightly"
|
||||
readonly profile_root
|
||||
case "${1-}" in
|
||||
# The Launcher already named the profile (its version query does too), in either accepted order;
|
||||
# never pass it a second pair. A plain version or help query is answered without any profile.
|
||||
--launch-profile | --profile-root | --version | -V | --help | -h) exec "$here/materialcraft-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 `--` is ours to strip: the app receives exactly one, from here.
|
||||
if [ "${1-}" = "--" ]; then shift; fi
|
||||
profile_base="${XDG_DATA_HOME:-${HOME:?HOME is required}/.local/share}"
|
||||
exec "$here/materialcraft-bin" --launch-profile nightly-v1 --profile-root "$profile_base/materialcraft-nightly" -- "$@"
|
||||
exec "$target" --launch-profile nightly-v1 --profile-root "$profile_root" -- "$@"
|
||||
@@ -2,11 +2,14 @@
|
||||
"""Every Linux Nightly launcher starts the GUI the flavor's way; no build, no window.
|
||||
|
||||
The deb/rpm wrapper and the Flatpak wrapper are generated inside package.sh and
|
||||
flatpak-bundle.sh; the AppImage ships `AppRun` with its desktop id rewritten; the plain tar and the
|
||||
Arch handoff ship a launcher file. All of them must hand the binary the one protocol the flavor
|
||||
accepts -- `--launch-profile nightly-v1 --profile-root <dir> -- files...` -- and pass a version
|
||||
query through untouched, because a nightly that starts without its profile is refused.
|
||||
flatpak-bundle.sh; the AppImage ships `AppRun` with its desktop id rewritten; the Arch handoff ships
|
||||
its own launcher file. All of them must hand the binary the one protocol the flavor accepts --
|
||||
`--launch-profile nightly-v1 --profile-root <dir> -- files...` -- and pass a version query through
|
||||
untouched, because a nightly that starts without its profile is refused. The plain tar's launcher is
|
||||
not one of ours: it is craft-common-actions' template rendered for this app, so it is checked against
|
||||
the bytes it must have and the exact tokens that template passes.
|
||||
"""
|
||||
import hashlib
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
@@ -16,6 +19,9 @@ import unittest
|
||||
HERE = Path(__file__).resolve().parent
|
||||
LINUX = HERE / "linux"
|
||||
PROFILE = "materialcraft-nightly"
|
||||
# The plain tar's launcher is craft-common-actions' template rendered for this app; these are its bytes.
|
||||
TAR_PROFILE = "ai.storyteller.materialcraft.nightly"
|
||||
TAR_SHA256 = "ab578db5556368f1cbfdf2f098c46c3edbbd1a23f072b938a46c021e31bbcad2"
|
||||
STABLE_DESK_ID = "ai.storyteller.materialcraft"
|
||||
NIGHTLY_DESK_ID = "ai.storyteller.materialcraft.nightly-v1"
|
||||
RECORDER = '#!/bin/sh\nfor arg in "$@"; do printf "<%s>\\n" "$arg"; done\n'
|
||||
@@ -89,13 +95,30 @@ class Launcher(unittest.TestCase):
|
||||
launcher,
|
||||
)
|
||||
|
||||
def test_the_plain_tar_launcher_starts_the_profile(self):
|
||||
# The standard layout: the GUI beside the launcher is `<app>-bin`.
|
||||
def test_the_plain_tar_launcher_is_the_shared_template(self):
|
||||
# The plain tar's `materialcraft` is the shared template, so it names the GUI beside it and
|
||||
# the package identity's profile folder, and it always passes exactly one `--`.
|
||||
(self.root / "materialcraft-bin").write_text(RECORDER, encoding="utf-8")
|
||||
(self.root / "materialcraft-bin").chmod(0o755)
|
||||
installed = self.launcher("materialcraft", (LINUX / "nightly-launch.sh").read_text(encoding="utf-8"))
|
||||
self.assert_starts_the_profile(installed)
|
||||
self.assert_starts_the_profile(installed, {"XDG_DATA_HOME": str(self.root / "xdg with space")})
|
||||
source = (LINUX / "nightly-launch.sh").read_bytes()
|
||||
self.assertEqual(hashlib.sha256(source).hexdigest(), TAR_SHA256,
|
||||
"the tar launcher must stay byte for byte scripts/nightly-launcher.sh.in rendered for materialcraft")
|
||||
installed = self.launcher("materialcraft", source.decode("utf-8"))
|
||||
for env in (None, {"XDG_DATA_HOME": str(self.root / "xdg with space")}):
|
||||
with self.subTest(env=env):
|
||||
root = str(Path((env or {}).get("XDG_DATA_HOME") or self.home / ".local/share") / TAR_PROFILE)
|
||||
tokens = ["--launch-profile", "nightly-v1", "--profile-root", root]
|
||||
self.assertEqual(
|
||||
self.recording(installed, "graph.mcraft", "--dashes.mcraft", env=env),
|
||||
[*tokens, "--", "graph.mcraft", "--dashes.mcraft"],
|
||||
)
|
||||
self.assertEqual(self.recording(installed, env=env), [*tokens, "--"])
|
||||
# A version query is asked in the Launcher's own form, so the GUI answers first.
|
||||
for flag in ("--version", "-V"):
|
||||
self.assertEqual(self.recording(installed, flag, env=env), [*tokens, "--version"])
|
||||
# The ArtCraft Launcher names its own profile and per-install root: passed unchanged.
|
||||
launcher_argv = ["--launch-profile", "nightly-v1", "--profile-root", str(self.root / "launcher root"), "--", "graph.mcraft"]
|
||||
self.assertEqual(self.recording(installed, *launcher_argv, env=env), launcher_argv)
|
||||
|
||||
def test_the_arch_launcher_starts_the_profile(self):
|
||||
(self.root / ".materialcraft-nightly").mkdir()
|
||||
|
||||
Reference in new issue
Block a user