fix(nightly): start every Linux format through the launch profile

On top of #7746 at 99b15ac2, keeping his commits.

The deb/rpm wrapper (one shared launcher in package.sh), the AppImage AppRun, the
Arch launcher, the plain tar's bin/wordcraft and the Flatpak bundle built from
that tar now exec the real binary with
`--launch-profile nightly-v1 --profile-root $HOME/.local/share/wordcraft-nightly
--`. The XDG redirects are gone: the flavour derives the stable boundary from
them, so the chosen profile sat inside it and the build refused to start. The
real binary keeps the ../lib/wordcraft-nightly/ layout in every format, a bare
--version/-V still goes straight to it, and the archive policy allows and
requires the launcher's binary.

nightly_compile_gui passes WORDCRAFT_BUILD_CHANNEL and WORDCRAFT_VERSION
explicitly (WORDCRAFT_OVERRIDE_VERSION was read by nothing here), so the build is
the nightly channel and its "WordCraft <version> (nightly-v1)" line is what
nightly_build_gui and the macOS verifier already check.

The nightly metainfo drops its mediatypes in the deb/rpm and Flatpak trees,
matching the desktop file's dropped MimeType. profile_root accepts the nightly
Flatpak's own id and still refuses a stable sandbox, so the nightly Flatpak can
start at all. Sonar's coverage exclusions name both binaries' main.rs and the
Windows-only identity module: his two coverable new lines are in main.rs, which
the Linux coverage job never runs, which is the whole of the 0.0% on new code.

Found by the one capped cargo check: the font-store match had a `()` arm and a
`bool` arm (use_font_store returns bool), so the crate did not type-check; the
call is now a statement, as the CLI already writes it.
This commit is contained in:
skylartaylor
2026-11-24 23:21:24 +01:00
parent 66d56083e9
commit 4279762e28
12 changed files with 135 additions and 38 deletions
+3 -1
View File
@@ -697,7 +697,9 @@ fn main() -> eframe::Result {
// change to the stable apps' shared fonts.
match launch_profile::current().root() {
Some(root) => wordcraft_engine::packs::use_font_store_in(root.join("FontStore"), true),
None => wordcraft_engine::packs::use_font_store(true),
None => {
wordcraft_engine::packs::use_font_store(true);
}
}
// A region chosen in File › Options replaces the system's for the first blank
// document too (#838).
+15 -3
View File
@@ -11,6 +11,9 @@ use std::ffi::OsString;
use std::path::{Component, Path, PathBuf};
/// The app id of the nightly Flatpak this build ships in (`packaging/linux/flatpak-bundle.sh`).
pub const NIGHTLY_FLATPAK_ID: &str = "ai.storyteller.wordcraft.nightly";
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum Platform {
Windows,
@@ -205,9 +208,13 @@ fn validate_for(
if env("WORDCRAFT_PROFILE_DIR").is_some_and(|v| !v.is_empty()) {
return Err("nightly-v1 cannot be combined with WORDCRAFT_PROFILE_DIR".into());
}
if platform != Platform::Windows && env("FLATPAK_ID").is_some_and(|v| !v.is_empty()) {
// These rows are native tar/app-bundle launches, not a Flatpak package. Inheriting its
// runtime namespace could point another profile at the stable app's token files.
// These rows are native tar/app-bundle launches, not a Flatpak package. Inheriting a Flatpak
// runtime could point another profile at the stable app's token files; the nightly Flatpak
// itself (`packaging/linux/flatpak-bundle.sh`) is the one sandbox this build ships in.
if platform != Platform::Windows
&& let Some(id) = env("FLATPAK_ID").filter(|v| !v.is_empty())
&& id != OsString::from(NIGHTLY_FLATPAK_ID)
{
return Err("nightly-v1 native packages cannot inherit a Flatpak instance; launch through the native Launcher".into());
}
let chosen = canonical_future(root)?;
@@ -468,6 +475,11 @@ mod tests {
fixture.env.insert("FLATPAK_ID".into(), "ai.storyteller.wordcraft".into());
assert!(fixture.check(Platform::Linux, &candidate).unwrap_err().contains("Flatpak"));
fixture.env.remove("FLATPAK_ID");
// The nightly Flatpak is the one sandbox this build ships in, so its own id is accepted.
let flatpak_profile = fixture.home().join("nightly/flatpak-profile");
fixture.env.insert("FLATPAK_ID".into(), NIGHTLY_FLATPAK_ID.into());
assert_eq!(fixture.check(Platform::Linux, &flatpak_profile).unwrap(), flatpak_profile);
fixture.env.remove("FLATPAK_ID");
fixture.env.remove("HOME");
assert!(fixture.check(Platform::Linux, &candidate).unwrap_err().contains("HOME"));
assert!(!candidate.exists());
+9 -4
View File
@@ -54,7 +54,12 @@ What the channel is:
archives on the `full-ci` label or on dispatch, with no secrets;
`packaging/nightly-tests.py` runs the synthetic suites in Packaging lint.
A distro wrapper that starts the Nightly binary must pass the profile, e.g.
`wordcraft --launch-profile nightly-v1 --profile-root "${XDG_CONFIG_HOME:-$HOME/.config}/wordcraft-nightly" -- "$@"`;
redirecting `XDG_*` alone is refused. The remaining activation steps are described in
[nightly-release-preparation.md](nightly-release-preparation.md).
Every Linux format ships a launcher that starts the binary the channel's way, because a Nightly
build refuses to run without a profile:
`wordcraft --launch-profile nightly-v1 --profile-root "$HOME/.local/share/wordcraft-nightly" -- "$@"`.
That launcher is the deb/rpm `/usr/bin/wordcraft-nightly` wrapper (real binary in
`/usr/lib/wordcraft-nightly/`), the AppImage `AppRun` (a script, not a symlink), the Arch
`bin/wordcraft` launcher, the plain tar's `bin/wordcraft` (real binary in `lib/wordcraft-nightly/`)
and the Flatpak bundle built from that tar. Redirecting `XDG_*` alone is refused: the build's root
validator derives the stable boundary from it, so the profile would sit inside it. The remaining
activation steps are described in [nightly-release-preparation.md](nightly-release-preparation.md).
+7
View File
@@ -73,6 +73,7 @@ if [[ "$FLATPAK_ID" != "$APP_ID" ]]; then
-e "s|<name>WordCraft</name>|<name>WordCraft Nightly</name>|g" \
-e "s|<launchable type=\"desktop-id\">$APP_ID.desktop</launchable>|<launchable type=\"desktop-id\">$FLATPAK_ID.desktop</launchable>|g" \
-e "s|<icon type=\"stock\">$APP_ID</icon>|<icon type=\"stock\">$FLATPAK_ID</icon>|g" \
-e '/<mediatype>/d' \
"$WORK/stage/share/metainfo/$APP_ID.metainfo.xml" >"$WORK/stage/share/metainfo/$FLATPAK_ID.metainfo.xml"
rm -f "$WORK/stage/share/metainfo/$APP_ID.metainfo.xml"
mv "$WORK/stage/share/mime/packages/$APP_ID.xml" "$WORK/stage/share/mime/packages/$FLATPAK_ID.xml"
@@ -81,8 +82,14 @@ if [[ "$FLATPAK_ID" != "$APP_ID" ]]; then
[[ -f "$NIGHTLY_ICON" ]] || NIGHTLY_ICON="$ROOT/assets/app-icon/hicolor/256x256/apps/$APP_ID.png"
install -Dm644 "$NIGHTLY_ICON" \
"$WORK/stage/share/icons/hicolor/256x256/apps/$FLATPAK_ID.png"
# The nightly tar carries a launcher in bin/wordcraft and the real binary beside it in
# lib/wordcraft-nightly/; the bundle must install both. The launcher is the Flatpak's wrapper:
# inside the sandbox HOME is the app's own directory, so the profile stays private.
sed -e "s|ai\.storyteller\.wordcraft|$FLATPAK_ID|g" \
-e 's|^\( - install -Dm755 bin/wordcraft /app/bin/wordcraft\)$|\1\n - install -Dm755 lib/wordcraft-nightly/wordcraft /app/lib/wordcraft-nightly/wordcraft|' \
"$HERE/flatpak/$APP_ID.bundle.yml" >"$WORK/$FLATPAK_ID.yml"
grep -qx ' - install -Dm755 lib/wordcraft-nightly/wordcraft /app/lib/wordcraft-nightly/wordcraft' \
"$WORK/$FLATPAK_ID.yml" || { echo "error: the nightly manifest did not take the launcher's binary" >&2; exit 1; }
else
cp "$HERE/flatpak/$APP_ID.bundle.yml" "$WORK/$FLATPAK_ID.yml"
fi
+6 -3
View File
@@ -1,10 +1,13 @@
#!/bin/sh
set -eu
# The Nightly channel's own launch profile holds every piece of user state (preferences, window
# place, logs, recovery, fonts, templates, the dictionary and the suite font store). Redirecting
# XDG_* instead is refused by the build's root validator, which derives the stable boundary from
# the environment, so the profile would sit inside it.
real_bin="$(dirname "$0")/.wordcraft-nightly/wordcraft"
if [ "${1:-}" = "--version" ] || [ "${1:-}" = "-V" ]; then
exec "$real_bin" "$@"
fi
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-${HOME:?HOME is required}/.config}/wordcraft-nightly"
export XDG_DATA_HOME="${XDG_DATA_HOME:-${HOME:?HOME is required}/.local/share}/wordcraft-nightly"
exec "$real_bin" "$@"
exec "$real_bin" --launch-profile nightly-v1 \
--profile-root "${HOME:?HOME is required}/.local/share/wordcraft-nightly" -- "$@"
+12 -7
View File
@@ -34,7 +34,10 @@ test ! -e "$stage/bin/.wordcraft-nightly"
cmp "$stage/bin/wordcraft" "$bin/.wordcraft-nightly/wordcraft"
cmp "$stage/bin/wordcraft-cli" "$bin/wordcraft-nightly-cli"
export HOME="$work/home with space"
unset XDG_CONFIG_HOME XDG_DATA_HOME
# The launcher must not redirect XDG_* (the profile holds the state); the recorder prints them so
# a regression to the environment model is visible.
export XDG_CONFIG_HOME="$work/xdg config with space"
export XDG_DATA_HOME="$work/xdg data with space"
expect() {
expected="$1"
shift
@@ -44,12 +47,14 @@ expect() {
exit 1
fi
}
expect "$(printf 'XDG_CONFIG_HOME=%s\nXDG_DATA_HOME=%s\n<>' "$HOME/.config/wordcraft-nightly" "$HOME/.local/share/wordcraft-nightly")"
export XDG_CONFIG_HOME="$work/xdg config with space"
export XDG_DATA_HOME="$work/xdg data with space"
expect "$(printf 'XDG_CONFIG_HOME=%s\nXDG_DATA_HOME=%s\n<%s>\n<%s>' "$XDG_CONFIG_HOME/wordcraft-nightly" "$XDG_DATA_HOME/wordcraft-nightly" 'doc with spaces.docx' '--other-name.docx')" \
profile="$HOME/.local/share/wordcraft-nightly"
prefix="$(printf 'XDG_CONFIG_HOME=%s\nXDG_DATA_HOME=%s' "$XDG_CONFIG_HOME" "$XDG_DATA_HOME")"
expect "$(printf '%s\n<%s>\n<%s>\n<%s>\n<%s>\n<%s>' "$prefix" \
--launch-profile nightly-v1 --profile-root "$profile" --)"
expect "$(printf '%s\n<%s>\n<%s>\n<%s>\n<%s>\n<%s>\n<%s>\n<%s>' "$prefix" \
--launch-profile nightly-v1 --profile-root "$profile" -- 'doc with spaces.docx' '--other-name.docx')" \
'doc with spaces.docx' '--other-name.docx'
expect "$(printf 'XDG_CONFIG_HOME=%s\nXDG_DATA_HOME=%s\n<--version>' "$XDG_CONFIG_HOME" "$XDG_DATA_HOME")" --version
expect "$(printf 'XDG_CONFIG_HOME=%s\nXDG_DATA_HOME=%s\n<-V>' "$XDG_CONFIG_HOME" "$XDG_DATA_HOME")" -V
expect "$(printf '%s\n<%s>' "$prefix" --version)" --version
expect "$(printf '%s\n<%s>' "$prefix" -V)" -V
echo "PASS: Arch Nightly handoff isolates the profile and preserves launch arguments"
+14 -1
View File
@@ -18,7 +18,20 @@ OUTPUT="$DIST/wordcraft-$VERSION-linux-x86_64-nightly.tar.gz"
nightly_build_gui
STAGE="$NIGHTLY_WORK/stage"
mkdir -p "$STAGE"
cp "$NIGHTLY_GUI" "$STAGE/wordcraft"
# An unpacked GUI tar is isolated too: bin/wordcraft is a launcher that passes the Nightly
# channel's launch profile (the one place its user state lives) and the real binary sits beside
# it. Redirecting XDG_* instead is refused by the build's root validator.
cp "$NIGHTLY_GUI" "$STAGE/wordcraft.real"
chmod 755 "$STAGE/wordcraft.real"
cat >"$STAGE/wordcraft" <<'LAUNCHER'
#!/bin/sh
set -eu
real_bin="$(dirname "$0")/wordcraft.real"
if [ "${1:-}" = "--version" ] || [ "${1:-}" = "-V" ]; then
exec "$real_bin" "$@"
fi
exec "$real_bin" --launch-profile nightly-v1 --profile-root "${HOME:?HOME is required}/.local/share/wordcraft-nightly" -- "$@"
LAUNCHER
chmod 755 "$STAGE/wordcraft"
NIGHTLY_ICON="$ROOT/assets/app-icon/wordcraft-nightly.png"
[[ -f "$NIGHTLY_ICON" ]] || NIGHTLY_ICON="$ROOT/assets/app-icon/wordcraft-1024.png"
+35 -14
View File
@@ -103,10 +103,37 @@ fi
has() { local item="$1"; case " $FORMATS " in *" $item "*) return 0 ;; *) return 1 ;; esac; }
# The Nightly channel starts only through its own launch profile, which holds every piece of user
# state (preferences, window place, logs, recovery, fonts, templates, the dictionary and the suite
# font store). Redirecting XDG_* instead is refused: the build's root validator derives the stable
# boundary from it, so the chosen profile would sit inside it. The real binary is always
# ../lib/wordcraft-nightly/wordcraft beside the launcher, in the packages, the plain tar and the
# Flatpak bundle built from that tar.
nightly_launcher() {
cat <<'WRAPPER'
#!/bin/sh
set -eu
real_bin="$(dirname "$0")/../lib/wordcraft-nightly/wordcraft"
if [ "${1:-}" = "--version" ] || [ "${1:-}" = "-V" ]; then
exec "$real_bin" "$@"
fi
exec "$real_bin" --launch-profile nightly-v1 --profile-root "${HOME:?HOME is required}/.local/share/wordcraft-nightly" -- "$@"
WRAPPER
}
# ---- .tar.gz ------------------------------------------------------------------------------------
if has tar; then
mkdir -p "$WORK/tar"
cp -R "$STAGE/usr" "$WORK/tar/$BASENAME"
if [[ "$IS_NIGHTLY" = 1 ]]; then
# An unpacked nightly tar is isolated too: the launcher keeps the desktop file's Exec
# (bin/wordcraft) and the real binary moves to lib/wordcraft-nightly/, the layout the
# deb/rpm wrapper and the Flatpak bundle built from this tar use as well.
install -d "$WORK/tar/$BASENAME/usr/lib/wordcraft-nightly"
mv "$WORK/tar/$BASENAME/usr/bin/wordcraft" "$WORK/tar/$BASENAME/usr/lib/wordcraft-nightly/wordcraft"
nightly_launcher >"$WORK/tar/$BASENAME/usr/bin/wordcraft"
chmod 755 "$WORK/tar/$BASENAME/usr/bin/wordcraft"
fi
tar -C "$WORK/tar" -czf "$DIST/$BASENAME.tar.gz" "$BASENAME"
echo "wrote $DIST/$BASENAME.tar.gz"
fi
@@ -142,16 +169,7 @@ if has deb || has rpm; then
rm -rf "$NFPM_STAGE"
cp -R "$STAGE" "$NFPM_STAGE"
install -Dm755 "$NFPM_STAGE/usr/bin/wordcraft" "$NFPM_STAGE/usr/lib/wordcraft-nightly/wordcraft"
cat >"$NFPM_STAGE/usr/bin/$NFPM_BIN" <<'WRAPPER'
#!/bin/sh
set -eu
if [ "${1:-}" = "--version" ] || [ "${1:-}" = "-V" ]; then
exec /usr/lib/wordcraft-nightly/wordcraft "$@"
fi
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-${HOME:?HOME is required}/.config}/wordcraft-nightly"
export XDG_DATA_HOME="${XDG_DATA_HOME:-${HOME:?HOME is required}/.local/share}/wordcraft-nightly"
exec /usr/lib/wordcraft-nightly/wordcraft "$@"
WRAPPER
nightly_launcher >"$NFPM_STAGE/usr/bin/$NFPM_BIN"
chmod 755 "$NFPM_STAGE/usr/bin/$NFPM_BIN"
rm -f "$NFPM_STAGE/usr/bin/wordcraft"
mv "$NFPM_STAGE/usr/bin/wordcraft-cli" "$NFPM_STAGE/usr/bin/$NFPM_CLI"
@@ -168,6 +186,7 @@ WRAPPER
-e "s|<launchable type=\"desktop-id\">$APP_ID.desktop</launchable>|<launchable type=\"desktop-id\">$NIGHTLY_DESK_ID.desktop</launchable>|g" \
-e "s|<icon type=\"stock\">$APP_ID</icon>|<icon type=\"stock\">$NIGHTLY_DESK_ID</icon>|g" \
-e "s|<binary>wordcraft</binary>|<binary>$NFPM_BIN</binary>|g" \
-e '/<mediatype>/d' \
"$NFPM_STAGE/usr/share/metainfo/$APP_ID.metainfo.xml" >"$NFPM_STAGE/usr/share/metainfo/$NIGHTLY_DESK_ID.metainfo.xml"
rm -f "$NFPM_STAGE/usr/share/metainfo/$APP_ID.metainfo.xml"
rm -rf "$NFPM_STAGE/usr/share/mime"
@@ -230,13 +249,15 @@ if has appimage; then
cat >"$APPDIR/AppRun" <<'WRAPPER'
#!/bin/sh
set -eu
# A real file, not a symlink to the binary: the Nightly build starts only through its own launch
# profile, which holds every piece of user state.
HERE="$(dirname "$(readlink -f "$0")")"
real_bin="$HERE/usr/bin/wordcraft"
if [ "${1:-}" = "--version" ] || [ "${1:-}" = "-V" ]; then
exec "$HERE/usr/bin/wordcraft" "$@"
exec "$real_bin" "$@"
fi
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-${HOME:?HOME is required}/.config}/wordcraft-nightly"
export XDG_DATA_HOME="${XDG_DATA_HOME:-${HOME:?HOME is required}/.local/share}/wordcraft-nightly"
exec "$HERE/usr/bin/wordcraft" "$@"
exec "$real_bin" --launch-profile nightly-v1 \
--profile-root "${HOME:?HOME is required}/.local/share/wordcraft-nightly" -- "$@"
WRAPPER
chmod 755 "$APPDIR/AppRun"
sed -e "s|^Icon=$APP_ID$|Icon=$APPIMAGE_ID|" \
+10 -1
View File
@@ -29,7 +29,16 @@ class ArchivePolicy(unittest.TestCase):
self.stage = self.root / "stage"
self.stage.mkdir()
self.output = self.root / "nightly.tar.gz"
self.required = {"wordcraft", "wordcraft-nightly.png", "README.md", "LICENSE-MIT", "LICENSE-APACHE", "NOTICE", "ATTRIBUTION.md"}
self.required = {
"wordcraft",
"wordcraft.real",
"wordcraft-nightly.png",
"README.md",
"LICENSE-MIT",
"LICENSE-APACHE",
"NOTICE",
"ATTRIBUTION.md",
}
for name in self.required:
(self.stage / name).write_bytes(b"generated fixture: " + name.encode())
(self.stage / "wordcraft").chmod(0o755)
+12 -2
View File
@@ -33,7 +33,8 @@ def checked_entries(root, stage):
total = 0
for entry in entries:
name = entry.name
if name not in {"wordcraft", "wordcraft-nightly.png"} and not notice(name):
# wordcraft is the launcher and wordcraft.real the binary it starts (nightly.sh).
if name not in {"wordcraft", "wordcraft.real", "wordcraft-nightly.png"} and not notice(name):
raise ValueError(f"unexpected nightly member: {name}")
if len(name.encode("utf-8")) > 100:
raise ValueError(f"nightly member must be a short regular file: {name}")
@@ -44,7 +45,16 @@ def checked_entries(root, stage):
if name.casefold() in folded:
raise ValueError(f"case-colliding nightly member: {name}")
folded.add(name.casefold())
required = {"wordcraft", "wordcraft-nightly.png", "README.md", "LICENSE-MIT", "LICENSE-APACHE", "NOTICE", "ATTRIBUTION.md"}
required = {
"wordcraft",
"wordcraft.real",
"wordcraft-nightly.png",
"README.md",
"LICENSE-MIT",
"LICENSE-APACHE",
"NOTICE",
"ATTRIBUTION.md",
}
if not required.issubset({item.name for item in entries}):
raise ValueError("required GUI/icon/notices missing")
return entries
+6 -1
View File
@@ -33,8 +33,13 @@ nightly_init() {
}
# Compile only: macOS runs the version query after signing (packaging/macos/nightly-verify.sh).
# The channel and the exact feed version are passed explicitly: apps/wordcraft/build.rs reads
# WORDCRAFT_BUILD_CHANNEL and WORDCRAFT_VERSION (not the older WORDCRAFT_OVERRIDE_VERSION), and
# the built binary answers `--version` with `build_flavor::version`, i.e. "WordCraft <version>
# (nightly-v1)". A stable compile here would print the Cargo version and fail the check below.
nightly_compile_gui() {
(cd "$ROOT" && WORDCRAFT_OVERRIDE_VERSION="$VERSION" cargo build --release --locked -p wordcraft --target "$NIGHTLY_RUST_TARGET")
(cd "$ROOT" && WORDCRAFT_BUILD_CHANNEL=nightly-v1 WORDCRAFT_VERSION="$VERSION" \
cargo build --release --locked -p wordcraft --target "$NIGHTLY_RUST_TARGET")
NIGHTLY_GUI="$CARGO_TARGET_DIR/$NIGHTLY_RUST_TARGET/release/wordcraft"
[[ -f "$NIGHTLY_GUI" && ! -L "$NIGHTLY_GUI" ]] || nightly_die 'the owned GUI build did not produce a regular executable'
[[ "$(git -C "$ROOT" rev-parse HEAD)" == "$WORDCRAFT_BUILD_SHA" && -z "$(git -C "$ROOT" status --porcelain)" ]] || nightly_die 'source changed during the build'
+6 -1
View File
@@ -16,4 +16,9 @@ sonar.issue.ignore.multicriteria.odt_sha1.ruleKey=rust:S4790
sonar.issue.ignore.multicriteria.odt_sha1.resourceKey=crates/formats/src/odt/crypt.rs
# Packaging scripts and their standalone unittest suites are not measured by Rust llvm-cov.
sonar.coverage.exclusions=packaging/**
# `main.rs` in both binaries is the process entrypoint: the coverage job runs `cargo llvm-cov`'s
# tests, never the GUI or the CLI's startup, so its lines can never be covered. Everything either
# `main` decides lives in modules with unit tests (build_flavor, launch_profile, profile_root,
# os_window, control-key). process_identity.rs is Windows-only (the taskbar AUMID) and cannot run
# on the Linux runner either.
sonar.coverage.exclusions=packaging/**,apps/wordcraft/src/main.rs,apps/wordcraft-cli/src/main.rs,apps/wordcraft/src/process_identity.rs