Use the shared nightly launcher template (#4740)

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.

The red sonarcloud / SonarCloud Scan check is inherited: it fails on main too (ea033fbe).
This commit is contained in:
skylar taylor-barrick authored and GitHub committed 2026-11-25 16:17:24 -06:00
1 parent ea033fbe1c
commit 5bdb4e7a69
2 files changed
+43 -32

No files matched your search

+30 -17
View File
@@ -1,7 +1,8 @@
#!/usr/bin/env bash
# Validate the Nightly launchers without building or opening LightCraft: the unpacked tar's
# `lightcraft` (GUI in `lightcraft-bin`) and the deb/rpm/FHS `lightcraft-nightly` (GUI in
# lib/lightcraft-nightly). A recorder stands in for both binaries and prints its argv and env.
# `lightcraft` (craft-common-actions' rendered template, GUI in `lightcraft-bin`) and the
# deb/rpm/FHS `lightcraft-nightly` (GUI in lib/lightcraft-nightly). A recorder stands in for both
# binaries and prints its argv and env.
set -euo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
@@ -29,31 +30,40 @@ expect() {
unset XDG_DATA_HOME LIGHTCRAFT_CONFIG_DIR LIGHTCRAFT_LIBRARY
export HOME="$work/home with space"
# ---- the unpacked tar: lightcraft (launcher) + lightcraft-bin (the GUI) --------------------------
# ---- the unpacked tar: the shared template as lightcraft (GUI in lightcraft-bin) ----------------
tar_dir="$work/tar"
mkdir -p "$tar_dir"
cp "$work/recorder" "$tar_dir/lightcraft-bin"
install -m755 "$HERE/nightly-tar-launch.sh" "$tar_dir/lightcraft"
profile="$HOME/.local/share/lightcraft-nightly"
identity="ai.storyteller.lightcraft.nightly"
profile="$HOME/.local/share/$identity"
# A hand-unpacked tar opens its own Nightly profile, whatever the working directory is.
# The shared template, rendered for LightCraft: a hand-unpacked tar opens the channel's own profile
# whatever the working directory is, and every argument follows the profile tokens.
cd "$work"
expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<--launch-profile>\n<nightly-v1>\n<--profile-root>\n<%s>\n<-->\n<photo with spaces.dng>\n<--other-name.dng>\n' "$profile")" \
"$("$tar_dir/lightcraft" 'photo with spaces.dng' '--other-name.dng')"
export XDG_DATA_HOME="$work/xdg with space"
profile="$XDG_DATA_HOME/lightcraft-nightly"
profile="$XDG_DATA_HOME/$identity"
expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<--launch-profile>\n<nightly-v1>\n<--profile-root>\n<%s>\n<-->\n<sample.dng>\n' "$profile")" \
"$("$tar_dir/lightcraft" sample.dng)"
unset XDG_DATA_HOME
profile="$HOME/.local/share/lightcraft-nightly"
profile="$HOME/.local/share/$identity"
# The Launcher's own form arrives already shaped: its profile root wins and nothing is added.
expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<--launch-profile>\n<nightly-v1>\n<--profile-root>\n</launcher/profiles/lightcraft>\n<--version>\n')" \
"$("$tar_dir/lightcraft" --launch-profile nightly-v1 --profile-root /launcher/profiles/lightcraft --version)"
expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<--profile-root>\n<%s>\n<-->\n<photo.dng>\n' "$work/explicit root")" \
"$("$tar_dir/lightcraft" --profile-root "$work/explicit root" -- photo.dng)"
# The version query is answered by the binary itself, with no profile tokens.
expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<--version>\n')" "$("$tar_dir/lightcraft" --version)"
# A version query is asked in the Launcher's own form, so the binary answers before any profile.
expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<--launch-profile>\n<nightly-v1>\n<--profile-root>\n<%s>\n<--version>\n' "$profile")" \
"$("$tar_dir/lightcraft" --version)"
expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<--launch-profile>\n<nightly-v1>\n<--profile-root>\n<%s>\n<--version>\n' "$profile")" \
"$("$tar_dir/lightcraft" -V)"
# The ArtCraft Launcher names its own profile and per-install root: the pair goes to the GUI unchanged.
expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<--launch-profile>\n<nightly-v1>\n<--profile-root>\n<%s>\n<-->\n<photo.dng>\n' "$work/launcher profile with space")" \
"$("$tar_dir/lightcraft" --launch-profile nightly-v1 --profile-root "$work/launcher profile with space" -- photo.dng)"
# The bytes are the shared template rendered for this app, not a local script.
expected="dbb1dff470eaff5ecfe1cf03cc43459d4d8796a0e8875fc0bea9563e30deba59"
actual="$(sha256sum "$HERE/nightly-tar-launch.sh" | cut -d' ' -f1)"
[[ "$actual" == "$expected" ]] || { printf 'nightly-tar-launch.sh is %s, not the rendered template %s\n' "$actual" "$expected" >&2; exit 1; }
# ---- the deb/rpm and the unpacked FHS tar: bin/lightcraft-nightly + lib/lightcraft-nightly -------
fhs="$work/fhs"
@@ -62,22 +72,25 @@ cp "$work/recorder" "$fhs/lib/lightcraft-nightly/lightcraft"
cp "$work/recorder" "$fhs/lib/lightcraft-nightly/lightcraft-cli"
install -m755 "$HERE/nightly-fhs-launch.sh" "$fhs/bin/lightcraft-nightly"
install -m755 "$HERE/nightly-fhs-cli-launch.sh" "$fhs/bin/lightcraft-nightly-cli"
# The distro formats keep their own profile folder, so they are not the tar's identity.
fhs_profile="$HOME/.local/share/lightcraft-nightly"
# The real binary is resolved beside the launcher, so an unpacked tree works anywhere.
expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<--launch-profile>\n<nightly-v1>\n<--profile-root>\n<%s>\n<-->\n<photo with spaces.dng>\n' "$profile")" \
expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<--launch-profile>\n<nightly-v1>\n<--profile-root>\n<%s>\n<-->\n<photo with spaces.dng>\n' "$fhs_profile")" \
"$("$fhs/bin/lightcraft-nightly" 'photo with spaces.dng')"
expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<--launch-profile>\n<nightly-v1>\n<--profile-root>\n</launcher/profiles/lightcraft>\n<--version>\n')" \
"$("$fhs/bin/lightcraft-nightly" --launch-profile nightly-v1 --profile-root /launcher/profiles/lightcraft --version)"
expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<--version>\n')" "$("$fhs/bin/lightcraft-nightly" --version)"
# The headless CLI takes the same profile through its two host variables; explicit values win.
expect "$(printf 'CONFIG=<%s>\nLIBRARY=<%s>\n<calibrate>\n' "$profile/Settings" "$profile/Library")" \
expect "$(printf 'CONFIG=<%s>\nLIBRARY=<%s>\n<calibrate>\n' "$fhs_profile/Settings" "$fhs_profile/Library")" \
"$("$fhs/bin/lightcraft-nightly-cli" calibrate)"
expect "$(printf 'CONFIG=<%s>\nLIBRARY=<%s>\n<calibrate>\n' "$work/cli settings" "$work/cli library")" \
"$(LIGHTCRAFT_CONFIG_DIR="$work/cli settings" LIGHTCRAFT_LIBRARY="$work/cli library" "$fhs/bin/lightcraft-nightly-cli" calibrate)"
# Neither launcher writes anything by itself (no folder, no file).
test ! -e "$profile"
test ! -e "$fhs_profile"
test ! -e "$HOME/Pictures"
echo "PASS: the Nightly tar and FHS launchers isolate the profile and pass the Launcher protocol through"
echo "PASS: the Nightly tar launcher is the shared template and the FHS launchers isolate the profile"
+13 -15
View File
@@ -1,18 +1,16 @@
#!/bin/sh
# LightCraft Nightly as unpacked from its tar: start the GUI in the Nightly profile, so a download
# unzipped by hand is as isolated as the AppImage, the deb/rpm and the Flatpak.
#
# ./lightcraft [files…] opens the Nightly library under $XDG_DATA_HOME/lightcraft-nightly
# ./lightcraft-bin [files…] the binary itself (stable's settings folder unless given a profile)
# 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
self="$(readlink -f "$0")"
here="$(dirname "$self")"
# Never fall back to a relative path: an unresolvable $0 is a broken install, not a guess.
[ -n "$self" ] && [ "${here#/}" != "$here" ] || { echo "error: cannot resolve $0" >&2; exit 2; }
case "${1:-}" in
# The Launcher's own profile form is passed on untouched (its profile root wins over this
# default), and the queries are answered without any profile.
--launch-profile | --profile-root | --version | -V | --help | -h) exec "$here/lightcraft-bin" "$@" ;;
dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)
readonly dir
target="$dir/lightcraft-bin"
readonly target
profile_root="${XDG_DATA_HOME:-$HOME/.local/share}/ai.storyteller.lightcraft.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
profile="${XDG_DATA_HOME:-${HOME:?HOME is required}/.local/share}/lightcraft-nightly"
exec "$here/lightcraft-bin" --launch-profile nightly-v1 --profile-root "$profile" -- "$@"
exec "$target" --launch-profile nightly-v1 --profile-root "$profile_root" -- "$@"