Files
GeoLibre/scripts/render-aur-pkgbuild.sh
Qiusheng Wu 3ad8bed9a1 ci(aur): publish geolibre-bin to the AUR on each release (#645)
* ci(aur): publish geolibre-bin to the AUR on each release

Add a binary AUR package that repackages the Linux .deb already attached
to every release (no source build, full desktop integration from the
.deb's binary/.desktop/icons).

- scripts/render-aur-pkgbuild.sh renders the PKGBUILD for a version + deb
  checksum (mirrors render-homebrew-cask.sh).
- packaging/aur/PKGBUILD is a generated reference for the first manual
  import; packaging/aur/README.md documents account/SSH/secret setup.
- release.yml gains an `aur` job that downloads the release .deb, renders
  the PKGBUILD, and pushes PKGBUILD + .SRCINFO to the AUR.

The job is isolated: it only `needs` build, nothing depends on it, it
skips when AUR_SSH_PRIVATE_KEY is unset (forks), and runs as
continue-on-error so an AUR failure never fails the release or affects the
asset build or Homebrew update.

* Address Claude review feedback

- Anchor the VERSION regex at both ends so a hyphen/suffix tag (e.g.
  1.2.3-rc1) is rejected rather than producing an invalid AUR pkgver.
- Guard the data.tar.* glob in package(): capture it and abort if no data
  member exists, instead of passing a literal name to bsdtar.
- Pin KSXGitHub/github-actions-deploy-aur to a commit SHA (v4.1.3) rather
  than a mutable tag, since the step receives the AUR SSH private key.
2026-06-20 19:44:01 -04:00

71 lines
3.1 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Render the PKGBUILD for the `geolibre-bin` AUR package.
#
# This is a binary AUR package: it repackages the Linux `.deb` that the release
# workflow already attaches to each GitHub release (it does not build from
# source), so installs are fast and need no Rust/Node toolchain. The `.deb`
# already carries the binary, the `.desktop` entry, and the icons, so extracting
# it gives full desktop integration.
#
# Usage:
# VERSION=1.5.0 \
# SHA256_AMD64=<sha256 of GeoLibre.Desktop_<version>_amd64.deb> \
# scripts/render-aur-pkgbuild.sh > PKGBUILD
#
# Both variables are required. REPO defaults to opengeos/GeoLibre. The rendered
# PKGBUILD is written to stdout.
set -euo pipefail
: "${VERSION:?Set VERSION to the release version, e.g. 1.5.0}"
: "${SHA256_AMD64:?Set SHA256_AMD64 to the sha256 of the amd64 .deb}"
# Validate formats so a truncated hash or stray metacharacter can't silently
# produce a malformed PKGBUILD that only fails at install time.
[[ "$SHA256_AMD64" =~ ^[0-9a-f]{64}$ ]] || { echo "SHA256_AMD64 is not a 64-char sha256 hex string" >&2; exit 1; }
# Anchored at both ends: a suffix like 1.2.3-rc1 must NOT pass, because AUR
# pkgver forbids hyphens (the pkgver/pkgrel separator), so makepkg would reject
# the resulting PKGBUILD.
[[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "VERSION does not look like a semver string" >&2; exit 1; }
REPO="${REPO:-opengeos/GeoLibre}"
# Shell-expanded: ${VERSION}, ${SHA256_AMD64}, ${REPO}. Everything escaped with
# \$ stays literal so it is a normal makepkg variable in the emitted PKGBUILD.
cat <<PKGBUILD
# Maintainer: Qiusheng Wu <giswqs@gmail.com>
#
# Generated by scripts/render-aur-pkgbuild.sh and republished to the AUR by
# .github/workflows/release.yml on every non-prerelease GitHub release. Edit the
# render script rather than this file; CI overwrites it on the next release.
pkgname=geolibre-bin
pkgver=${VERSION}
pkgrel=1
pkgdesc="Lightweight, cloud-native GIS platform for visualizing and analyzing geospatial data"
arch=('x86_64')
url="https://geolibre.app/"
license=('MIT')
depends=('webkit2gtk-4.1' 'gtk3' 'libayatana-appindicator')
optdepends=('xdotool: global keyboard shortcuts')
provides=('geolibre')
conflicts=('geolibre')
options=('!strip' '!debug')
source=("\${pkgname}-\${pkgver}.deb::https://github.com/${REPO}/releases/download/v\${pkgver}/GeoLibre.Desktop_\${pkgver}_amd64.deb")
sha256sums=('${SHA256_AMD64}')
noextract=("\${pkgname}-\${pkgver}.deb")
package() {
cd "\${srcdir}"
# A .deb is an \`ar\` archive of control/data tarballs. Unpack it, then
# extract the data tree (gz/xz/zst, whichever tauri used; bsdtar detects
# it) straight into the package root, preserving the binary, the .desktop
# entry, and the icons the .deb already ships.
bsdtar -xf "\${pkgname}-\${pkgver}.deb"
# Capture the glob so a corrupt .deb with no data member fails loudly here
# instead of bsdtar choking on the literal string "data.tar.*".
local data_tar=(data.tar.*)
[[ -f \${data_tar[0]} ]] || { echo "no data.tar.* member in the .deb" >&2; return 1; }
bsdtar -xpf "\${data_tar[0]}" -C "\${pkgdir}/"
}
PKGBUILD