#!/usr/bin/env bash
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}"
[[ "$SHA256_AMD64" =~ ^[0-9a-f]{64}$ ]] || { echo "SHA256_AMD64 is not a 64-char sha256 hex string" >&2; exit 1; }
[[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "VERSION does not look like a semver string" >&2; exit 1; }
REPO="${REPO:-opengeos/GeoLibre}"
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