Files
spotifast/packaging/flatpak/flathub.sh
T
Carmine Paolino ef50fc2d0e Ship a Flatpak bundle with each release
Fedora and the other distributions without a package had no build of
ours to turn to, and the community one broke for several people (#73).
The release workflow now packages the Linux build it already made into
rocks.fastpotify.Fastpotify, a bundle anyone with Flatpak can install,
in a sandbox with sound, the network, the tray, and MPRIS. The manifest
Flathub builds from source sits beside it with a script that pins it to
a tag, and the AppStream metadata both need. Inside a sandbox MPRIS
names the desktop entry by the app id, which is the name the entry is
exported under.
2026-08-30 11:11:58 +02:00

33 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Writes the manifest Flathub builds from, for one release tag:
#
# packaging/flatpak/flathub.sh v0.4.0 /path/to/flathub-checkout
#
# It pins the source to the tag and its commit, and generates
# cargo-sources.json from the lockfile with flatpak-cargo-generator, which
# needs python3 with aiohttp and toml (pip install aiohttp toml).
set -euo pipefail
tag="${1:?tag, like v0.4.0}"
out="${2:?directory to write into}"
here="$(cd "$(dirname "$0")" && pwd)"
root="$(cd "$here/../.." && pwd)"
commit="$(git -C "$root" rev-list -n 1 "$tag")"
generator="$here/flatpak-cargo-generator.py"
if [ ! -f "$generator" ]; then
curl -fsSL -o "$generator" \
https://raw.githubusercontent.com/flatpak/flatpak-builder-tools/master/cargo/flatpak-cargo-generator.py
fi
mkdir -p "$out"
python3 "$generator" "$root/Cargo.lock" -o "$out/cargo-sources.json"
python3 - "$here/rocks.fastpotify.Fastpotify.yml" "$out/rocks.fastpotify.Fastpotify.yml" "$tag" "$commit" <<'PY'
import sys
src, dst, tag, commit = sys.argv[1:]
text = open(src).read()
old = " - type: dir\n path: ../..\n"
new = f" - type: git\n url: https://github.com/crmne/fastpotify.git\n tag: {tag}\n commit: {commit}\n"
assert old in text, "the source block moved"
open(dst, "w").write(text.replace(old, new))
PY
cp "$here/rocks.fastpotify.Fastpotify.metainfo.xml" "$out/" 2>/dev/null || true
echo "wrote $out/rocks.fastpotify.Fastpotify.yml and cargo-sources.json for $tag ($commit)"