mirror of
https://github.com/storytold/effectcraft.git
synced 2026-11-28 14:08:40 -08:00
Second commit on top of Dylan Taylor's #4154; his commits, names and files stay his. The Nightly build refuses EFFECTCRAFT_CONFIG_DIR (its state root comes from the Launcher), so his wrappers, which export that variable, would have been refused at startup. Every one of them now passes the protocol instead - `--launch-profile nightly-v1 --profile-root <dir> --`: - the deb/rpm GUI wrapper in packaging/linux/package.sh, plus a wrapper for its headless CLI; - the AppImage AppRun (a script, not the stable symlink), and its CLI; - the Flatpak wrapper in packaging/linux/flatpak-bundle.sh; - the Arch launcher, with its test updated; - and a new launcher inside the flat Nightly tar (packaging/linux/nightly-launch.sh), which stages the GUI as `effectcraft-bin`; the archive helper allows and requires exactly that one extra member. The profile folder is `${XDG_DATA_HOME:-$HOME/.local/share}/effectcraft-nightly` everywhere: outside every stable boundary and inside the Nightly Flatpak's own sandbox home. Each launcher passes a first-argument --version/-V, and an already-supplied --launch-profile, through unchanged, because after the injected `--` both would be file names. build.rs now reads EFFECTCRAFT_VERSION and falls back to EFFECTCRAFT_OVERRIDE_VERSION, which is what this repo's packaging scripts export, so the binary reports the prepared identity and nightly-common.sh's exact `EffectCraft <version> (nightly-v1)` check can pass. profile_root accepts exactly the Nightly's own Flatpak instance (ai.storyteller.effectcraft.nightly) and refuses every other, with a test; before, any FLATPAK_ID was refused and the Nightly Flatpak could not start inside its own sandbox. Cargo.lock's effectcraft entry names thiserror and winsafe, which the flavor added to the manifest, so `cargo check --locked` resolves again. With his enabled callers kept whole, the flavor's `.github/actionlint.yaml` (a suppression for a `queue:` key his signer no longer sets) and its `packaging-lint.yml` path entry are gone; nothing in the tree names `queue:` or the `macos-release` label. Already right here: the window class matches the Nightly desktop entry's StartupWMClass, the metainfo declares no mediatypes, the Nightly build needs no extra features, and sonar.coverage.exclusions already covers packaging/**. The flavor itself had three compile errors that only a real `cargo check` finds, fixed here: the user-preset folder asked `effectcraft_host` for the profile root from a crate that does not depend on it (the UI now carries the profile's `Presets` folder through `channel::set_profile_presets`, set from `prepare_launch`), `channel::channel_label` was `const` while it reads a non-const atomic identity, and a test built `"--launch-profile="` with `+` on `&str`s. Tests: packaging/nightly-tests.py (71 suite tests plus the two Linux launcher argv tests), bash -n over every changed script, rustfmt --edition 2024 --check on the changed Rust, and `cargo check --locked -p effectcraft --tests` / `-p effectcraft-cli --tests`, both green locally (with a check-only alsa.pc, because this host has no libasound outside the Nix dev shell). package.sh was also rendered with stub binaries and a stub nfpm, and the installed deb tree read back. Co-authored-by: dylanmtaylor <dylan@dylanmtaylor.com> Co-authored-by: skylartaylor <skylartaylor@users.noreply.github.com>
125 lines
5.9 KiB
Bash
Executable File
125 lines
5.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Repackage a EffectCraft Linux tarball as a single-file Flatpak bundle:
|
|
#
|
|
# $DIST/effectcraft-<version>-linux-<arch>.flatpak
|
|
#
|
|
# Usage: packaging/linux/flatpak-bundle.sh [--no-test] [TARBALL]
|
|
#
|
|
# TARBALL defaults to $DIST/effectcraft-<version>-linux-<arch>.tar.gz from package.sh. The bundle
|
|
# is built for the host architecture (x86_64 or aarch64), which must match the tarball's.
|
|
# Needs flatpak, flatpak-builder and the SVG pixbuf loader (librsvg2-common) for the host's
|
|
# `appstreamcli compose`; the freedesktop runtime and SDK named in the manifest are
|
|
# installed per-user from Flathub. Unless --no-test, the bundle is then installed per-user and
|
|
# `effectcraft-cli --version` is run inside the sandbox as a smoke test.
|
|
# Manifest: packaging/linux/flatpak/ai.storyteller.effectcraft.bundle.yml.
|
|
set -euo pipefail
|
|
# shellcheck source=../env.sh
|
|
. "$(dirname "${BASH_SOURCE[0]}")/../env.sh"
|
|
HERE="$ROOT/packaging/linux"
|
|
APP_ID=ai.storyteller.effectcraft
|
|
FLATPAK_ID="$APP_ID"
|
|
# The remote indexes both app IDs on the stable ref branch; IDs isolate installations.
|
|
FLATPAK_BRANCH=stable
|
|
if [[ "${EFFECTCRAFT_BUILD_CHANNEL:-}" == nightly-v1 || "$VERSION" == *-nightly* ]]; then
|
|
FLATPAK_ID="$APP_ID.nightly"
|
|
fi
|
|
FLATHUB=https://dl.flathub.org/repo/flathub.flatpakrepo
|
|
|
|
TEST=1
|
|
OCI=0
|
|
TARBALL=""
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--no-test) TEST=0; shift ;;
|
|
--oci) OCI=1; shift ;;
|
|
-h | --help) sed -n '2,14p' "$0"; exit 0 ;;
|
|
-*) echo "unknown argument: $1" >&2; exit 2 ;;
|
|
*) TARBALL="$1"; shift ;;
|
|
esac
|
|
done
|
|
|
|
ARCH="$(uname -m)"
|
|
case "$ARCH" in
|
|
x86_64) ;;
|
|
aarch64 | arm64) ARCH=aarch64 ;;
|
|
*) echo "unsupported architecture $ARCH" >&2; exit 2 ;;
|
|
esac
|
|
BASENAME="effectcraft-$VERSION-linux-$ARCH"
|
|
TARBALL="${TARBALL:-$DIST/$BASENAME.tar.gz}"
|
|
[[ -f "$TARBALL" ]] || { echo "error: $TARBALL not found (run packaging/linux/package.sh --formats tar first)" >&2; exit 1; }
|
|
for tool in flatpak flatpak-builder; do
|
|
command -v "$tool" >/dev/null || { echo "error: $tool not found (apt install flatpak flatpak-builder librsvg2-common)" >&2; exit 1; }
|
|
done
|
|
|
|
echo "==> EffectCraft $VERSION Flatpak bundle for $ARCH from $(basename "$TARBALL")"
|
|
|
|
WORK="$CARGO_TARGET_DIR/flatpak-bundle"
|
|
rm -rf "$WORK"
|
|
mkdir -p "$WORK/stage"
|
|
tar -xzf "$TARBALL" -C "$WORK/stage" --strip-components=1
|
|
[[ -x "$WORK/stage/bin/effectcraft" ]] || { echo "error: $TARBALL has no bin/effectcraft" >&2; exit 1; }
|
|
if [[ "$FLATPAK_ID" != "$APP_ID" ]]; then
|
|
mv "$WORK/stage/bin/effectcraft" "$WORK/stage/bin/effectcraft-bin"
|
|
# The Nightly build refuses EFFECTCRAFT_CONFIG_DIR, so the wrapper passes the profile protocol.
|
|
# Inside the sandbox $HOME is this app id's own folder, so the profile is the Nightly's alone.
|
|
cat >"$WORK/stage/bin/effectcraft" <<'WRAPPER'
|
|
#!/bin/sh
|
|
set -eu
|
|
real_bin=/app/libexec/effectcraft
|
|
case "${1:-}" in
|
|
--version|-V|--launch-profile) exec "$real_bin" "$@" ;;
|
|
esac
|
|
profile_base="${XDG_DATA_HOME:-${HOME:?HOME is required}/.local/share}"
|
|
exec "$real_bin" --launch-profile nightly-v1 --profile-root "$profile_base/effectcraft-nightly" -- "$@"
|
|
WRAPPER
|
|
chmod 755 "$WORK/stage/bin/effectcraft"
|
|
sed -e "s|^Icon=$APP_ID$|Icon=$FLATPAK_ID|" \
|
|
-e "s|^Name=EffectCraft$|Name=EffectCraft Nightly|" \
|
|
-e 's|^StartupWMClass=.*|StartupWMClass=ai.storyteller.effectcraft.nightly-v1|' \
|
|
-e '/^MimeType=/d' \
|
|
"$WORK/stage/share/applications/$APP_ID.desktop" >"$WORK/stage/share/applications/$FLATPAK_ID.desktop"
|
|
rm -f "$WORK/stage/share/applications/$APP_ID.desktop"
|
|
sed -e "s|<id>$APP_ID</id>|<id>$FLATPAK_ID</id>|g" \
|
|
-e "s|<name>EffectCraft</name>|<name>EffectCraft 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" \
|
|
"$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"
|
|
NIGHTLY_ICON="$ROOT/assets/app-icon/effectcraft-nightly.png"
|
|
[[ -f "$NIGHTLY_ICON" ]] || NIGHTLY_ICON="$ROOT/assets/app-icon/hicolor/256x256/apps/$APP_ID.png"
|
|
rm -rf "$WORK/stage/share/icons/hicolor"
|
|
install -Dm644 "$NIGHTLY_ICON" \
|
|
"$WORK/stage/share/icons/hicolor/256x256/apps/$FLATPAK_ID.png"
|
|
sed -e "s|ai\.storyteller\.effectcraft|$FLATPAK_ID|g" \
|
|
-e 's|- install -Dm755 bin/effectcraft /app/bin/effectcraft|- install -Dm755 bin/effectcraft-bin /app/libexec/effectcraft\n - install -Dm755 bin/effectcraft /app/bin/effectcraft|' \
|
|
"$HERE/flatpak/$APP_ID.bundle.yml" >"$WORK/$FLATPAK_ID.yml"
|
|
else
|
|
cp "$HERE/flatpak/$APP_ID.bundle.yml" "$WORK/$FLATPAK_ID.yml"
|
|
fi
|
|
|
|
flatpak remote-add --user --if-not-exists flathub "$FLATHUB"
|
|
# --disable-rofiles-fuse: no FUSE in containers and CI runners.
|
|
flatpak-builder --user --install-deps-from=flathub --disable-rofiles-fuse --force-clean \
|
|
--default-branch="$FLATPAK_BRANCH" --repo="$WORK/repo" --state-dir="$WORK/state" "$WORK/build" "$WORK/$FLATPAK_ID.yml"
|
|
|
|
OUT="$DIST/$BASENAME.flatpak"
|
|
# --runtime-repo lets `flatpak install` fetch the freedesktop runtime from Flathub if missing.
|
|
flatpak build-bundle --runtime-repo="$FLATHUB" "$WORK/repo" "$OUT" "$FLATPAK_ID" "$FLATPAK_BRANCH"
|
|
echo "wrote $OUT"
|
|
if [[ "$OCI" = 1 ]]; then
|
|
OUT_OCI="$DIST/$BASENAME-oci"
|
|
rm -rf "$OUT_OCI"
|
|
flatpak build-bundle --oci "$WORK/repo" "$OUT_OCI" "$FLATPAK_ID" "$FLATPAK_BRANCH"
|
|
echo "wrote OCI layout to $OUT_OCI"
|
|
fi
|
|
|
|
if [[ "$TEST" = 1 ]]; then
|
|
flatpak install --user -y --noninteractive --reinstall "$OUT"
|
|
flatpak info --user "$FLATPAK_ID"
|
|
flatpak run --command=effectcraft-cli "$FLATPAK_ID" --version
|
|
flatpak run --command=sh "$FLATPAK_ID" -c 'ls /app/share/applications /app/share/metainfo /app/share/mime/packages /app/share/icons/hicolor/*/apps'
|
|
fi
|
|
echo "==> done"
|
|
ls -lh "$OUT"
|