mirror of
https://github.com/narrrl/proton-stream.git
synced 2026-12-03 20:01:50 +01:00
The manifest builds the checkout offline on the GNOME 51 runtime, with libass, libplacebo and libmpv as modules and every crate vendored through cargo-sources.json. scripts/build-flatpak.sh regenerates the sources, builds, optionally installs, and bundles into dist/. Sandbox: network, Wayland with X11 fallback, DRI, PulseAudio, the Secret Service, notifications and the MPRIS name. The screensaver inhibit goes through the portal, which needs no extra permission. Refs #3
58 lines
2.3 KiB
Bash
Executable File
58 lines
2.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Build the Flatpak from this checkout, offline, as Flathub would.
|
|
#
|
|
# scripts/build-flatpak.sh regenerate cargo-sources.json, build, bundle
|
|
# scripts/build-flatpak.sh --install ...and install it for this user
|
|
# scripts/build-flatpak.sh --sources only regenerate cargo-sources.json
|
|
#
|
|
# Needs flatpak, flatpak-builder and python3 with aiohttp and tomlkit (for
|
|
# flatpak-cargo-generator). The GNOME SDK and the rust-stable extension are
|
|
# installed from Flathub on first run. The bundle lands in dist/.
|
|
set -euo pipefail
|
|
|
|
script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
|
ROOT="$(cd -- "$script_dir/.." && pwd)"
|
|
APP_ID=io.narl.proton-stream
|
|
MANIFEST="$ROOT/packaging/flatpak/$APP_ID.yml"
|
|
WORK="$ROOT/.build/flatpak"
|
|
# Pinned so a regenerated cargo-sources.json is reproducible.
|
|
TOOLS_REV=9d86d336a39b9af38b86f114b6ce5820fe260f91
|
|
GENERATOR="$WORK/flatpak-cargo-generator-$TOOLS_REV.py"
|
|
|
|
die() { echo "error: $*" >&2; exit 1; }
|
|
|
|
install=false
|
|
sources_only=false
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--install) install=true ;;
|
|
--sources) sources_only=true ;;
|
|
*) die "unknown argument: $arg (see the header of $0)" ;;
|
|
esac
|
|
done
|
|
|
|
# Flathub builds the registry crates; a path patch cannot resolve in its sandbox.
|
|
grep -q '^\[patch\.crates-io\]' "$ROOT/Cargo.toml" &&
|
|
die "Cargo.toml carries [patch.crates-io]; the Flatpak builds against crates.io"
|
|
|
|
mkdir -p "$WORK" "$ROOT/dist"
|
|
if [[ ! -f "$GENERATOR" ]]; then
|
|
curl -fsSL -o "$GENERATOR.tmp" \
|
|
"https://raw.githubusercontent.com/flatpak/flatpak-builder-tools/$TOOLS_REV/cargo/flatpak-cargo-generator.py"
|
|
mv "$GENERATOR.tmp" "$GENERATOR"
|
|
fi
|
|
python3 -I "$GENERATOR" "$ROOT/Cargo.lock" -o "$ROOT/packaging/flatpak/cargo-sources.json"
|
|
echo "regenerated packaging/flatpak/cargo-sources.json"
|
|
$sources_only && exit 0
|
|
|
|
version="$(sed -n 's/^version = "\([^"]*\)"/\1/p' "$ROOT/Cargo.toml" | head -n1)"
|
|
bundle="$ROOT/dist/proton-stream-$version-x86_64.flatpak"
|
|
|
|
flatpak-builder --user --install-deps-from=flathub --force-clean --ccache \
|
|
--state-dir="$WORK/state" --repo="$WORK/repo" \
|
|
$($install && echo --install) \
|
|
"$WORK/build" "$MANIFEST"
|
|
flatpak build-bundle --runtime-repo=https://dl.flathub.org/repo/flathub.flatpakrepo \
|
|
"$WORK/repo" "$bundle" "$APP_ID"
|
|
echo "built ${bundle#$ROOT/}"
|