114 lines
4.6 KiB
Bash
114 lines
4.6 KiB
Bash
# Maintainer: Spencer Bull <spencerbull2554@gmail.com>
|
|
|
|
# cua-driver ships prebuilt from the trycua/cua monorepo release feed, so this
|
|
# repackages the vendor tarball. Upstream keeps the CLI, its cursor-theme
|
|
# compiler, and the SDK artifacts together in one directory and exposes the
|
|
# CLI through a symlink -- the binary resolves its helpers as siblings of
|
|
# /proc/self/exe -- so the whole tree lands under /usr/lib/cua-driver with a
|
|
# /usr/bin symlink. .omarchy/upstream.sh rewrites the version and checksums
|
|
# below from the release feed.
|
|
#
|
|
# The binary carries its own updater: `cua-driver update --apply` pipes the
|
|
# vendor installer into bash, which would install a second copy under
|
|
# ~/.cua-driver and link it into ~/.local/bin, stepping around pacman and
|
|
# this repository's release gate. Upstream offers no switch for that path,
|
|
# and a /usr/bin wrapper would not cover it either, since the MCP
|
|
# configurations the binary generates record the resolved executable. So
|
|
# prepare() rewrites the installer URL inside the binary to point at pm.sh,
|
|
# a stand-in that declines and names pacman instead.
|
|
|
|
pkgname=cua-driver-bin
|
|
pkgver=0.26.1
|
|
pkgrel=1
|
|
pkgdesc="Computer-use driver for native GUI apps: accessibility-tree snapshots and input injection"
|
|
arch=('x86_64' 'aarch64')
|
|
url="https://github.com/trycua/cua"
|
|
license=('MIT')
|
|
# at-spi2-core carries the AT-SPI accessibility bus the driver reads GUI
|
|
# trees through; the X libraries are linked, not dlopen'd.
|
|
depends=(
|
|
'at-spi2-core'
|
|
'gcc-libs'
|
|
'glibc'
|
|
'libx11'
|
|
'libxcb'
|
|
'libxext'
|
|
'libxi'
|
|
'libxkbcommon'
|
|
)
|
|
provides=("cua-driver=${pkgver}")
|
|
conflicts=('cua-driver')
|
|
# Prebuilt Rust binaries ship byte-exact apart from the installer rewrite
|
|
# below: their build ids are what upstream symbolication matches.
|
|
options=('!strip' '!debug')
|
|
source=('LICENSE' 'pm.sh')
|
|
source_x86_64=("https://github.com/trycua/cua/releases/download/cua-driver-rs-v${pkgver}/cua-driver-rs-${pkgver}-linux-x86_64.tar.gz")
|
|
source_aarch64=("https://github.com/trycua/cua/releases/download/cua-driver-rs-v${pkgver}/cua-driver-rs-${pkgver}-linux-arm64.tar.gz")
|
|
sha256sums=('c0779290c1d4783169aa3dbfb55feb505e563ef8a004bbf55298ceffcfbda8d9'
|
|
'c76e251c3ed424200eac52bec35ba534336307fabd83a175ab0b47e2084ab0d8')
|
|
sha256sums_x86_64=('a38e2a812b2c04b6e5dac2cf7e534b04ff9a5a6711b1d13db657ac0166387d7a')
|
|
sha256sums_aarch64=('c418dd4573174d6c3bc36a643d64c013c3abceb399033fc7ed0ecb2c3384cae2')
|
|
|
|
case "${CARCH}" in
|
|
x86_64) _platform="linux-x86_64" ;;
|
|
aarch64) _platform="linux-arm64" ;;
|
|
esac
|
|
_vendor_tree="cua-driver-rs-${pkgver}-${_platform}"
|
|
|
|
# Rust strings carry their length out of band, so the replacement has to be
|
|
# exactly as long as the original: 32 bytes, which is what fixes the
|
|
# stand-in's short name and location.
|
|
_vendor_installer='https://cua.ai/driver/install.sh'
|
|
_pacman_installer='file:///usr/lib/cua-driver/pm.sh'
|
|
|
|
prepare() {
|
|
cd "${srcdir}/${_vendor_tree}"
|
|
|
|
if (( ${#_vendor_installer} != ${#_pacman_installer} )); then
|
|
echo "installer URLs must be the same length to rewrite in place" >&2
|
|
return 1
|
|
fi
|
|
|
|
# The URL appears twice: once in the updater and once in the printed
|
|
# reinstall one-liner. Any other count means upstream moved the updater
|
|
# and this rewrite needs another look, so the build stops rather than
|
|
# shipping a live self-updater.
|
|
local found
|
|
found=$(grep -obUaF "${_vendor_installer}" cua-driver | wc -l)
|
|
if (( found != 2 )); then
|
|
echo "expected the vendor installer URL twice in cua-driver, found ${found}" >&2
|
|
return 1
|
|
fi
|
|
|
|
local size_before size_after
|
|
size_before=$(stat -c %s cua-driver)
|
|
sed -i "s|${_vendor_installer//./\\.}|${_pacman_installer}|g" cua-driver
|
|
size_after=$(stat -c %s cua-driver)
|
|
|
|
if (( size_before != size_after )) \
|
|
|| grep -qUaF "${_vendor_installer}" cua-driver \
|
|
|| (( $(grep -obUaF "${_pacman_installer}" cua-driver | wc -l) != 2 )); then
|
|
echo "installer URL rewrite did not land cleanly in cua-driver" >&2
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
package() {
|
|
cd "${srcdir}/${_vendor_tree}"
|
|
|
|
# The vendor tree stays together: cua-driver execs cua-cursor-theme as a
|
|
# sibling of the resolved binary, and the SDK library, node runtime, ABI
|
|
# header, and the GNOME wayland-helper extension are versioned with it.
|
|
install -d "${pkgdir}/usr/lib/cua-driver"
|
|
cp -a . "${pkgdir}/usr/lib/cua-driver/"
|
|
chmod -R a+rX "${pkgdir}/usr/lib/cua-driver"
|
|
|
|
# The path prepare() wrote into the binary.
|
|
install -Dm755 "${srcdir}/pm.sh" "${pkgdir}/usr/lib/cua-driver/pm.sh"
|
|
|
|
install -d "${pkgdir}/usr/bin"
|
|
ln -s ../lib/cua-driver/cua-driver "${pkgdir}/usr/bin/cua-driver"
|
|
|
|
install -Dm644 "${srcdir}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
|
|
}
|