Files
amethyst/desktopApp/packaging/flatpak/flathub/tools/regenerate-gradle-sources.sh
Vitor PamplonaandClaude Opus 5.5 062b25246c feat(flatpak): a Flathub manifest that builds Amethyst from source
Flathub doesn't accept the release manifest, which repackages CI's
prebuilt tree. desktopApp/packaging/flatpak/flathub/ builds the tag
offline instead:

- com.vitorpamplona.amethyst.Amethyst.yml compiles the tag tarball with
  `:desktopApp:createReleaseDistributable` on the JetBrains Runtime SDK
  21.0.11 (prebuilt, as Flathub ships it for com.prof18.feedflow), so the
  bundled runtime keeps JBR's Wayland toolkit. Sources: the tarball, JBR
  per arch, Gradle 9.8.0, the init script and gradle-sources.json.
- gradle-sources.json: the 2,185 Maven files the build resolves on
  x86_64 and aarch64 (1,566 Maven Central, 591 Google, 28 JitPack), each
  with its sha256, laid out as a local Maven repo.
- flathub-offline.init.gradle replaces every repository with that repo.
- tools/regenerate-gradle-sources.sh reruns the build online per arch in
  Docker on a fresh Gradle home and turns the module cache into the list
  (tools/gradle-cache-to-sources.py, which also maps Gradle module
  metadata's local file names to their published URLs).

Checked on aarch64: flatpak-builder builds it without network, the
installed Flatpak is 1.19.0 on runtime 26.08 with libawt_wlawt.so, and
`flatpak run` reaches the login screen. flatpak-builder-lint passes the
manifest and the metainfo; on the build it reports only the two
media-URL checks, which expect the absolute dl.flathub.org/media URLs
Flathub's builder writes where Debian's AppStream 1.0.5 writes relative
ones. Not checked: x86_64 through flatpak-builder, and Flathub's own
builder (it can't nest in Docker).

The flatpak README's Flathub section now tracks what is left: the AI
policy (these files are AI-written, the manifest says so, and the
submission must disclose it), domain verification, and submitting from
the next tag, whose metainfo has the screenshot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 12:48:29 -04:00

50 lines
2.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Regenerate gradle-sources.json, the Maven files the Flathub build reads
# offline, for a release tag. Run it whenever a release changes dependencies.
#
# desktopApp/packaging/flatpak/flathub/tools/regenerate-gradle-sources.sh v1.20.0
#
# For each arch it runs the manifest's own build command online, in a Debian
# container on the JetBrains Runtime the manifest pins, with a fresh Gradle
# home; the module cache then holds exactly what the build resolves. The two
# caches become one list (the arch-specific jars of both, which each arch
# ignores the other's of). x86_64 runs under emulation on an arm64 host (and
# the reverse), so expect ~10 min native plus ~25 min emulated.
#
# Requires: docker, curl, python3. Writes ../gradle-sources.json and prints the
# tag tarball's sha256 for the manifest's archive source. Work files go to
# build/flathub-regen/ at the repo root.
set -euo pipefail
TAG="${1:?usage: regenerate-gradle-sources.sh vX.Y.Z}"
HERE="$(cd "$(dirname "$0")" && pwd)"
OUT="$(dirname "$HERE")"
WORK="$(cd "$HERE/../../../../.." && pwd)/build/flathub-regen/$TAG"
JBR_BUILD=21.0.11-linux-%s-b1163.116 # keep in step with the manifest's jbrsdk sources
mkdir -p "$WORK/dl"
curl -fsSL -o "$WORK/dl/src.tar.gz" "https://github.com/vitorpamplona/amethyst/archive/refs/tags/$TAG.tar.gz"
sha256() { if command -v sha256sum >/dev/null; then sha256sum "$1"; else shasum -a 256 "$1"; fi | cut -d' ' -f1; }
echo "archive sha256: $(sha256 "$WORK/dl/src.tar.gz")"
capture() { # docker-platform jbr-arch
local platform=$1 arch=$2 jbr
jbr="jbrsdk-$(printf "$JBR_BUILD" "$arch").tar.gz"
[ -f "$WORK/dl/$jbr" ] || curl -fsSL -o "$WORK/dl/$jbr" "https://cache-redirector.jetbrains.com/intellij-jbr/$jbr"
rm -rf "$WORK/cap-$arch" && mkdir -p "$WORK/cap-$arch"
docker run --rm --platform "$platform" -v "$WORK/dl:/dl:ro" -v "$WORK/cap-$arch:/cap" debian:trixie bash -c "
set -e
apt-get update -qq >/dev/null && apt-get install -y -qq --no-install-recommends ca-certificates binutils >/dev/null
mkdir -p /jbr /src && tar xzf /dl/$jbr -C /jbr --strip-components=1 && tar xzf /dl/src.tar.gz -C /src --strip-components=1
cd /src && JAVA_HOME=/jbr GRADLE_USER_HOME=/cap/gradle-home ./gradlew --no-daemon --console=plain \
:desktopApp:createReleaseDistributable > /cap/build.log 2>&1 || { tail -40 /cap/build.log; exit 1; }"
echo "captured $arch"
}
capture linux/arm64 aarch64
capture linux/amd64 x64
python3 -I "$HERE/gradle-cache-to-sources.py" "$WORK/cap-aarch64/gradle-home" "$OUT/gradle-sources.json" \
"$WORK/cap-x64/gradle-home"
echo "wrote $OUT/gradle-sources.json; delete $WORK when done"