# Maintainer: Hao Long <imlonghao@archlinuxcn.org>

pkgname=shh
pkgver=2026.3.8
pkgrel=1
pkgdesc="Automatic systemd service hardening guided by strace profiling"
arch=("x86_64")
url="https://github.com/desbma/shh"
license=("GPL-3.0-or-later")
depends=("gcc-libs" "glibc" "strace")
makedepends=("cargo")
source=("${url}/archive/v${pkgver}/${pkgname}-v${pkgver}.tar.gz")
b2sums=('3640f99f69d1018b9490e2ee16189c8e636a911d9f419b6f2b000b40471abe4f0ee61c1ccdbaa5c75de04017e66747c57292af079e325e61a4c511f2ccd57c3d')

prepare() {
  cd "$pkgname-$pkgver"
  export RUSTUP_TOOLCHAIN=stable
  cargo fetch --locked --target "$(rustc -vV | sed -n "s/host: //p")"
}

build() {
  cd "$pkgname-$pkgver"
  export RUSTUP_TOOLCHAIN=stable
  export CARGO_TARGET_DIR=target
  export RUSTFLAGS='-C link-args=-Wl,-z,shstk'
  cargo build --frozen --release
}

check() {
  cd "$pkgname-$pkgver"
  export RUSTUP_TOOLCHAIN=stable
  cargo test --frozen --bins
}

package() {
  cd "$pkgname-$pkgver"
  install -Dm0755 -t "$pkgdir/usr/bin/" "target/release/$pkgname"
}
