diff --git a/pkgbuilds/grok-bot/.omarchy/package.json b/pkgbuilds/grok-bot/.omarchy/package.json index a2a26fe9..2a9719d3 100644 --- a/pkgbuilds/grok-bot/.omarchy/package.json +++ b/pkgbuilds/grok-bot/.omarchy/package.json @@ -1,5 +1,3 @@ { - "source": "aur", - "sync": false, - "upstream_commit": "05eb78fca06b482affda28b26223cbf249d4bbcd" + "source": "local" } diff --git a/pkgbuilds/grok-bot/.omarchy/upstream.sh b/pkgbuilds/grok-bot/.omarchy/upstream.sh new file mode 100755 index 00000000..55118d0b --- /dev/null +++ b/pkgbuilds/grok-bot/.omarchy/upstream.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# Cursor publishes Grok Bot through the linux-x64 sand update feed. The feed +# carries version plus the 40-char build id that the Linux .deb URL needs. +# Darwin's feed no longer embeds that id, so this hook reads Linux directly. +# +# bin/sync-upstream rewrites pkgver and sha256sums_x86_64. The Linux URL also +# needs _commit, which that rewriter does not touch, so this hook updates +# _commit itself when it reports a new release. +set -euo pipefail + +FEED='https://api2.cursor.sh/updates/api/update/linux-x64/sand/0.0.0/00000000-0000-0000-0000-000000000000/stable' +PKGBUILD="${PKGBUILD:-PKGBUILD}" + +if ! command -v vercmp >/dev/null 2>&1; then + echo "vercmp not found: this hook needs pacman to compare versions" >&2 + exit 1 +fi + +[[ -f "${PKGBUILD}" ]] || { + echo "PKGBUILD not found at ${PKGBUILD}" >&2 + exit 1 +} + +json=$(curl -fsSL -H 'cache-control: no-cache' "${FEED}") +version=$(jq -er '.version // .productVersion // .name' <<<"${json}") +feed_url=$(jq -er '.url' <<<"${json}") +commit=$(sed -nE 's@.*/grokbot/stable/([0-9a-f]{40})/.*@\1@p' <<<"${feed_url}") + +[[ -n "${version}" && -n "${commit}" ]] || { + echo "Could not parse version/commit from linux-x64 sand feed: ${json}" >&2 + exit 1 +} + +current=$(awk -F= '/^pkgver=/ { print $2; exit }' "${PKGBUILD}" | tr -d "\"'") +if [[ -n "${current}" ]] && [[ "$(vercmp "${version}" "${current}")" -le 0 ]]; then + echo '{}' + exit 0 +fi + +deb_url="https://downloads.cursor.com/grokbot/stable/${commit}/linux/x64/grok-bot_${version}_amd64.deb" +code=$(curl -fsSIL -o /dev/null -w '%{http_code}' "${deb_url}") +[[ "${code}" == "200" ]] || { + echo "Linux deb not fetchable (${code}): ${deb_url}" >&2 + exit 1 +} + +sha256=$(curl -fL --retry 3 -sS "${deb_url}" | sha256sum | awk '{print $1}') +[[ "${sha256}" =~ ^[0-9a-f]{64}$ ]] || { + echo "Could not hash ${deb_url}" >&2 + exit 1 +} + +if [[ $(grep -c '^_commit=' "${PKGBUILD}") -ne 1 ]]; then + echo "Expected exactly one _commit= assignment in ${PKGBUILD}" >&2 + exit 1 +fi +sed -i "s/^_commit=.*/_commit=${commit}/" "${PKGBUILD}" + +jq -n --arg pkgver "${version}" --arg sha256 "${sha256}" \ + '{pkgver: $pkgver, sha256sums: {x86_64: [$sha256]}}' diff --git a/pkgbuilds/grok-bot/PKGBUILD b/pkgbuilds/grok-bot/PKGBUILD index 11093337..6298f277 100644 --- a/pkgbuilds/grok-bot/PKGBUILD +++ b/pkgbuilds/grok-bot/PKGBUILD @@ -1,10 +1,15 @@ # Maintainer: petrouil # Contributor: Omarchy +# Cursor ships Grok Bot as a Debian package on downloads.cursor.com. The Linux +# sand update feed carries the version and the 40-char build id the .deb URL +# needs. .omarchy/upstream.sh rewrites pkgver, _commit, and sha256sums_x86_64 +# from that feed. Darwin's feed no longer embeds the build id. + pkgname=grok-bot -pkgver=0.29.0 +pkgver=0.39.0 pkgrel=1 -_commit=f0e5bfcee649ea84c0c61369cf896cd146d72136 +_commit=d8bc9c753edddb313047c9c69b480b7f8f321087 pkgdesc='Grok Bot desktop agent' arch=('x86_64') url='https://x.ai/bot' @@ -25,18 +30,21 @@ optdepends=('libappindicator-gtk3: tray support') provides=('sand') conflicts=('sand') options=('!strip' '!debug') +_deb="${pkgname}_${pkgver}.deb" source=( - "${pkgname}_${pkgver}.deb::https://downloads.cursor.com/grokbot/stable/${_commit}/linux/x64/Grok_Bot_${pkgver}.deb" 'grok-bot.sh' 'grok-bot.desktop' ) -sha256sums=('d223b5830282aef11d5c46d8f4d1edd239bf992e336405cbd288d4476b9233d4' - '6dfa6c305941afa6cbaefbeaae06d05ab5a88f31630005d25a819a160c20c7a3' +source_x86_64=( + "${_deb}::https://downloads.cursor.com/grokbot/stable/${_commit}/linux/x64/grok-bot_${pkgver}_amd64.deb" +) +sha256sums=('6dfa6c305941afa6cbaefbeaae06d05ab5a88f31630005d25a819a160c20c7a3' '856056c9ca63dda5d01158ce8fb6a9a7cbb3f67c13a92b573cd196d3e50f26e7') -noextract=("${pkgname}_${pkgver}.deb") +sha256sums_x86_64=('ae498adaf71f9ff1734a786163c5807fa50165acb5aa102bb68f43ead96de4fe') +noextract=("${_deb}") package() { - bsdtar -xOf "${srcdir}/${pkgname}_${pkgver}.deb" data.tar.xz | + bsdtar -xOf "${srcdir}/${_deb}" data.tar.xz | bsdtar -x -C "${pkgdir}" -f - rm -rf "${pkgdir}/usr/share/doc" \ diff --git a/pkgbuilds/grok-bot/update-pkgver.sh b/pkgbuilds/grok-bot/update-pkgver.sh deleted file mode 100755 index 40e9474e..00000000 --- a/pkgbuilds/grok-bot/update-pkgver.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env bash -# Resolve current Grok Bot stable from Cursor's update feed and pin PKGBUILD. -# Linux has no latest alias (linux-x64 feed returns 204). The darwin-arm64 -# sand feed publishes version + commit; the Linux .deb lives at the same commit. -# Darwin can ship first — HEAD-check the Linux URL and fail loudly if 404. -set -euo pipefail - -PKGBUILD_PATH="${1:-PKGBUILD}" -[[ -f "${PKGBUILD_PATH}" ]] || { echo "Error: PKGBUILD not found at '${PKGBUILD_PATH}'" >&2; exit 1; } - -FEED='https://api2.cursor.sh/updates/api/update/darwin-arm64/sand/0.0.0/00000000-0000-0000-0000-000000000000/stable' -json="$(curl -fsSL -H 'cache-control: no-cache' "${FEED}")" - -ver="$(jq -er '.name // .version' <<<"${json}")" -feed_url="$(jq -er '.url' <<<"${json}")" -commit="$(sed -nE 's@.*/(grokbot|sand)/stable/([0-9a-f]{40})/.*@\2@p' <<<"${feed_url}")" - -[[ -n "${ver}" && -n "${commit}" ]] || { - echo "Error: could not parse version/commit from feed: ${json}" >&2 - exit 1 -} - -deb_url="https://downloads.cursor.com/grokbot/stable/${commit}/linux/x64/Grok_Bot_${ver}.deb" -code="$(curl -fsSIL -o /dev/null -w '%{http_code}' "${deb_url}")" -[[ "${code}" == "200" ]] || { - echo "Error: Linux deb not fetchable (${code}): ${deb_url}" >&2 - exit 1 -} - -tmp="$(mktemp)" -trap 'rm -f "${tmp}"' EXIT -curl -fL --retry 3 -o "${tmp}" "${deb_url}" -sum="$(sha256sum "${tmp}" | awk '{print $1}')" - -current_ver="$(sed -nE 's/^pkgver=([^[:space:]#]+).*/\1/p' "${PKGBUILD_PATH}" | head -n1)" - -sed -i -E \ - -e "s/^_commit=.*/_commit=${commit}/" \ - -e "s/^pkgver=.*/pkgver=${ver}/" \ - -e "0,/^[[:space:]]*'[0-9a-f]{64}'/s// '${sum}'/" \ - "${PKGBUILD_PATH}" - -if [[ "${ver}" != "${current_ver}" ]]; then - sed -i -E 's/^pkgrel=.*/pkgrel=1/' "${PKGBUILD_PATH}" -fi - -echo "${ver} ${commit}" -echo "${deb_url}" -echo "${sum}"