mirror of
https://github.com/storytold/lightcraft.git
synced 2026-11-09 09:59:52 -06:00
- brand.toml is the only place the product name lives; every crate and app
reads it through dac-brand (env vars with legacy fallback, settings folder
with copy-only migration, default library, preset extensions, i18n {app})
- cargo xtask brand check|test, run|install|package, docs, rename-crates,
deny and immich; packaging files are templates rendered from brand.toml
- icons regenerated from brand/icon.svg; upstream branding removed
- MIT licence (segment and fetch stay Apache-2.0); cargo deny licence policy
- clean-room rules in AGENTS.md/CLAUDE.md; docs/upstream-merge.md
- plan/ rebuilt and committed; parity tracker reopens Classic rows, adds
PLAN.md section 2 rows and the IMM Immich section; plan/immich.md and a
pinned Immich test server
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
74 lines
3.1 KiB
Bash
Executable File
74 lines
3.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Repackage the app's Linux tarball as a single-file Flatpak bundle (names from brand.toml):
|
|
#
|
|
# $DIST/<binary>-<version>-linux-<arch>.flatpak
|
|
#
|
|
# Usage: packaging/linux/flatpak-bundle.sh [--no-test] [TARBALL]
|
|
#
|
|
# TARBALL defaults to $DIST/<binary>-<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
|
|
# `<cli_binary> --version` is run inside the sandbox as a smoke test.
|
|
# Manifest template: packaging/linux/flatpak/{app_id}.bundle.yml.in.
|
|
set -euo pipefail
|
|
# shellcheck source=../env.sh
|
|
. "$(dirname "${BASH_SOURCE[0]}")/../env.sh"
|
|
HERE="$ROOT/packaging/linux"
|
|
APP_ID=$BRAND_APP_ID
|
|
APP=$BRAND_BINARY
|
|
FLATHUB=https://dl.flathub.org/repo/flathub.flatpakrepo
|
|
|
|
TEST=1
|
|
TARBALL=""
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
--no-test) TEST=0; 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="$APP-$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 "==> $BRAND_DISPLAY_NAME $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/$APP" ] || { echo "error: $TARBALL has no bin/$APP" >&2; exit 1; }
|
|
brand_render "$HERE/flatpak/{app_id}.bundle.yml.in" "$WORK/$APP_ID.yml"
|
|
|
|
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=stable --repo="$WORK/repo" --state-dir="$WORK/state" "$WORK/build" "$WORK/$APP_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" "$APP_ID" stable
|
|
echo "wrote $OUT"
|
|
|
|
if [ "$TEST" = 1 ]; then
|
|
flatpak install --user -y --noninteractive --reinstall "$OUT"
|
|
flatpak info --user "$APP_ID"
|
|
flatpak run --command="$BRAND_CLI_BINARY" "$APP_ID" --version
|
|
flatpak run --command=sh "$APP_ID" -c 'ls /app/share/applications /app/share/metainfo /app/share/mime/packages /app/share/icons/hicolor/scalable/apps'
|
|
fi
|
|
echo "==> done"
|
|
ls -lh "$OUT"
|