summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: fd0f25e30cb03d99dcbf0b1dc0c9f678069b8943 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# SPDX-License-Identifier: 0BSD
# Maintainer: Samuel Bernard <samuel.bernard@gmail.com>

pkgname=funes
pkgver=1.10.0
pkgrel=1
pkgdesc='Durable, searchable memory of your past AI agent sessions'
arch=('x86_64' 'aarch64')
url='https://github.com/huggingface/funes'
license=('Apache-2.0')
depends=('ca-certificates' 'glibc' 'libgcc' 'tar' 'trufflehog')
makedepends=('cargo' 'cmake' 'protobuf')
checkdepends=('git')
optdepends=('git: associate sessions with their Git repositories')
# Cargo controls LTO; avoid makepkg injecting incompatible cross-language flags.
options=('!lto')
source=("$pkgname-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz"
        'system-package.patch')
sha256sums=('57a6452685c501e739ee63664f17145c313ec49c2bce171c269cc7990aa38cfd'
            'ac2c6ed0df8abf27b32078b78f0819d3518f66224ccdc390f1cf80ed96e6eec8')

prepare() {
  cd "$pkgname-$pkgver"

  patch -Np1 -i "$srcdir/system-package.patch"

  # Upstream stamps the release version in CI; set it for source builds too.
  # Update only this package's version, preserving every locked dependency.
  sed -i "/^\[package\]$/,/^\[/s/^version = .*/version = \"$pkgver\"/" Cargo.toml
  sed -i "/^name = \"funes\"$/{n;s/^version = .*/version = \"$pkgver\"/;}" Cargo.lock

  export CARGO_HOME="$srcdir/cargo-home"
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd "$pkgname-$pkgver"
  export CARGO_HOME="$srcdir/cargo-home"
  export FUNES_SYSTEM_PACKAGE=1

  # The Linux inference backend is built from Rust sources (no ONNX runtime download).
  cargo build --release --frozen --no-default-features --features blas
}

check() {
  cd "$pkgname-$pkgver"
  export CARGO_HOME="$srcdir/cargo-home"
  export FUNES_SYSTEM_PACKAGE=1
  export FUNES_NO_TELEMETRY=1

  # The full integration suite downloads models and accesses the Hugging Face Hub.
  cargo test --release --frozen --no-default-features --features blas \
    --lib --test no_index --test ask_no_agent --test update_waits_for_older_writers
  test "$(target/release/funes --version)" = "funes $pkgver"
}

package() {
  cd "$pkgname-$pkgver"
  install -Dm755 target/release/funes "$pkgdir/usr/bin/funes"
  install -Dm644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
  cp -r docs "$pkgdir/usr/share/doc/$pkgname/"
}