# Maintainer: Hound <support@houndav.com>
pkgname=hound
pkgver=0.1.0
pkgrel=1
pkgdesc="Endpoint and supply-chain protection for Linux"
arch=('x86_64' 'aarch64')
url="https://houndav.com"
license=('Apache-2.0')
depends=('systemd-libs')
optdepends=('clamav: the Windows-malware corpus, for the file-server carrier case'
            'clamav-daemon: needed only if you enable the optional clamd engine')
makedepends=('rust>=1.91' 'cargo')
backup=('etc/hound/hound.toml')
install=hound.install
source=("$pkgname-$pkgver.tar.gz::https://git.joelovestech.com/Hound/Antivirus/archive/v$pkgver.tar.gz")
sha256sums=('SKIP')

build() {
  cd "$srcdir/Antivirus"
  cargo build --release --locked -p houndd -p hound
}

check() {
  cd "$srcdir/Antivirus"
  # The goodware gate runs here too: a rule that fires on an Arch system
  # binary must fail the build on Arch, not only on Debian.
  cargo test --release --locked --workspace
}

package() {
  cd "$srcdir/Antivirus"
  install -Dm755 target/release/houndd "$pkgdir/usr/bin/houndd"
  install -Dm755 target/release/hound  "$pkgdir/usr/bin/hound"
  install -Dm644 packaging/systemd/houndd.service \
                 "$pkgdir/usr/lib/systemd/system/houndd.service"
  install -Dm644 crates/houndd/rules/hound-builtin.yar \
                 "$pkgdir/usr/share/hound/rules/hound-builtin.yar"
  install -dm755 "$pkgdir/var/lib/hound/rules"
  install -dm700 "$pkgdir/var/lib/hound/vault"
  for s in 16 22 24 32 48 64 128 256 512; do
    install -Dm644 "assets/icons/app-${s}.png" \
      "$pkgdir/usr/share/icons/hicolor/${s}x${s}/apps/hound.png"
  done
  install -Dm644 assets/icons/hound-app.svg \
    "$pkgdir/usr/share/icons/hicolor/scalable/apps/hound.svg"
  install -Dm644 README.md "$pkgdir/usr/share/doc/hound/README.md"
}
