diff --git a/packaging/linux/nightly-launcher-test.sh b/packaging/linux/nightly-launcher-test.sh index 1c3dd2275f..5c1f90a142 100755 --- a/packaging/linux/nightly-launcher-test.sh +++ b/packaging/linux/nightly-launcher-test.sh @@ -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=<>\nLIBRARY=<>\n<--launch-profile>\n\n<--profile-root>\n<%s>\n<-->\n\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=<>\nLIBRARY=<>\n<--launch-profile>\n\n<--profile-root>\n<%s>\n<-->\n\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=<>\nLIBRARY=<>\n<--launch-profile>\n\n<--profile-root>\n\n<--version>\n')" \ - "$("$tar_dir/lightcraft" --launch-profile nightly-v1 --profile-root /launcher/profiles/lightcraft --version)" -expect "$(printf 'CONFIG=<>\nLIBRARY=<>\n<--profile-root>\n<%s>\n<-->\n\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=<>\nLIBRARY=<>\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=<>\nLIBRARY=<>\n<--launch-profile>\n\n<--profile-root>\n<%s>\n<--version>\n' "$profile")" \ + "$("$tar_dir/lightcraft" --version)" +expect "$(printf 'CONFIG=<>\nLIBRARY=<>\n<--launch-profile>\n\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=<>\nLIBRARY=<>\n<--launch-profile>\n\n<--profile-root>\n<%s>\n<-->\n\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=<>\nLIBRARY=<>\n<--launch-profile>\n\n<--profile-root>\n<%s>\n<-->\n\n' "$profile")" \ +expect "$(printf 'CONFIG=<>\nLIBRARY=<>\n<--launch-profile>\n\n<--profile-root>\n<%s>\n<-->\n\n' "$fhs_profile")" \ "$("$fhs/bin/lightcraft-nightly" 'photo with spaces.dng')" expect "$(printf 'CONFIG=<>\nLIBRARY=<>\n<--launch-profile>\n\n<--profile-root>\n\n<--version>\n')" \ "$("$fhs/bin/lightcraft-nightly" --launch-profile nightly-v1 --profile-root /launcher/profiles/lightcraft --version)" expect "$(printf 'CONFIG=<>\nLIBRARY=<>\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\n' "$profile/Settings" "$profile/Library")" \ +expect "$(printf 'CONFIG=<%s>\nLIBRARY=<%s>\n\n' "$fhs_profile/Settings" "$fhs_profile/Library")" \ "$("$fhs/bin/lightcraft-nightly-cli" calibrate)" expect "$(printf 'CONFIG=<%s>\nLIBRARY=<%s>\n\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" diff --git a/packaging/linux/nightly-tar-launch.sh b/packaging/linux/nightly-tar-launch.sh index 53be551d38..4106fd98c6 100755 --- a/packaging/linux/nightly-tar-launch.sh +++ b/packaging/linux/nightly-tar-launch.sh @@ -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" -- "$@"