# Based on the AUR openclaw package:
# Maintainer: Ralph Torres <mail at ralphptorr dot es>
# Contributor: Evert Vorster <evorster@gmail.com>
# Contributor: Emir-Eins <emir-eins@outlook.com>
# Contributor: Wuxxin <wuxxin@gmail.com>
# Followed here straight from the npm registry (see .omarchy/package.json), since
# upstream's release cadence outruns the AUR.
#
# This is the release Omarchy ships, not the OpenClaw that runs: a copy in /usr
# belongs to pacman, and `openclaw update` refuses to write there.
# omarchy-install-openclaw-cli seeds a copy under ~/.openclaw from this tarball
# with the installer that came in it, and that copy updates itself.

pkgname=openclaw
pkgver=2026.9.6
pkgrel=2
pkgdesc='Multi-channel AI gateway with extensible messaging integrations'
arch=(x86_64 aarch64)
url=https://github.com/openclaw/openclaw
license=(MIT)

# The installer brings its own Node, and git is the one thing it would
# otherwise try to install with sudo.
depends=(bash curl git)
optdepends=(
    'omarchy: sets up the self-updating OpenClaw under ~/.openclaw'
    '1password-cli: 1password skill'
    'ffmpeg: video-frames skill'
    'github-cli: github, gh-issues skills'
    'jq: session-logs, trello skills'
    'python-openai-whisper: openai-whisper skill'
    'ripgrep: session-logs skill'
    'tmux: tmux skill'
    'uv: nano-pdf skill'
    'go: for installing skill tools not packaged for Arch'
)
source=($pkgname-$pkgver.tgz::https://registry.npmjs.org/$pkgname/-/$pkgname-$pkgver.tgz)
sha256sums=('1a7355691bc0e605222ba818f1f72c1787253c78dfeb0df6be2086ec73b71e63')
options=(!debug !strip)
install=$pkgname.install
noextract=($pkgname-$pkgver.tgz)

package() {
    install -Dm644 "$srcdir"/$pkgname-$pkgver.tgz "$pkgdir"/usr/share/$pkgname/$pkgname.tgz

    bsdtar -xf "$srcdir"/$pkgname-$pkgver.tgz -C "$srcdir" \
        package/scripts/install-cli.sh package/dist/control-ui/apple-touch-icon.png package/LICENSE
    install -Dm644 "$srcdir"/package/scripts/install-cli.sh "$pkgdir"/usr/share/$pkgname/install-cli.sh
    install -Dm644 "$srcdir"/package/dist/control-ui/apple-touch-icon.png "$pkgdir"/usr/share/$pkgname/$pkgname.png
    install -Dm644 -t "$pkgdir"/usr/share/licenses/$pkgname "$srcdir"/package/LICENSE
}
