#!/usr/bin/env bash # Bump PKGBUILD/.SRCINFO when Cursor publishes a newer linux-x64 Grok Bot. set -euo pipefail cd "$(dirname "$0")/.." FEED='https://api2.cursor.sh/updates/api/update/linux-x64/sand/0.0.0/00000000-0000-0000-0000-000000000000/stable' resp=$(curl -fsSL "$FEED") version=$(jq -r .version <<<"$resp") commit=$(jq -r .url <<<"$resp" | sed -E 's#.*/stable/([^/]+)/.*#\1#') current=$(sed -n 's/^pkgver=//p' PKGBUILD) if [[ -z "$version" || "$version" == "null" || ! "$commit" =~ ^[0-9a-f]{40}$ ]]; then echo "Could not parse update feed: $resp" >&2 exit 1 fi if [[ "$version" == "$current" ]]; then echo "Up to date at $version" exit 0 fi echo "Bump $current -> $version (commit $commit)" deb_url="https://downloads.cursor.com/grokbot/stable/${commit}/linux/x64/grok-bot_${version}_amd64.deb" tmp=$(mktemp) trap 'rm -f "$tmp"' EXIT curl -fsSL --retry 3 "$deb_url" -o "$tmp" sha=$(sha256sum "$tmp" | cut -d' ' -f1) sed -i \ -e "s/^pkgver=.*/pkgver=${version}/" \ -e "s/^_commit=.*/_commit=${commit}/" \ -e "s/^sha256sums=.*/sha256sums=('${sha}')/" \ PKGBUILD # Refresh .SRCINFO source URL + hashes without requiring makepkg. sed -i \ -e "s/^\\tpkgver = .*/\\tpkgver = ${version}/" \ -e "s#^\\tsource = https://downloads.cursor.com/grokbot/stable/.*/linux/x64/grok-bot_.*_amd64.deb#\\tsource = https://downloads.cursor.com/grokbot/stable/${commit}/linux/x64/grok-bot_${version}_amd64.deb#" \ -e "s/^\\tnoextract = grok-bot_.*_amd64.deb/\\tnoextract = grok-bot_${version}_amd64.deb/" \ -e "s/^\\tsha256sums = .*/\\tsha256sums = ${sha}/" \ .SRCINFO echo "Updated PKGBUILD and .SRCINFO to ${version} sha256=${sha}"