# Contributor: Patrycja Rosa <alpine@ptrcnull.me>
# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=conduit
pkgver=0.8.0
pkgrel=4
pkgdesc="Simple, fast and reliable chat server powered by Matrix"
url="https://conduit.rs/"
arch="all"
license="Apache-2.0"
makedepends="cargo sqlite-dev cargo-auditable clang17-libclang rocksdb-dev snappy-dev"
install="$pkgname.pre-install"
subpackages="$pkgname-openrc"
source="https://gitlab.com/famedly/conduit/-/archive/v$pkgver/conduit-v$pkgver.tar.gz
	system-sqlite.patch

	conduit.toml
	conduit.initd
	conduit.confd
	"
builddir="$srcdir/conduit-v$pkgver"
options="net"

_features="--no-default-features --features=conduit_bin,backend_sqlite,backend_rocksdb"

export ROCKSDB_LIB_DIR="/usr/lib/"
export SNAPPY_LIB_DIR="/usr/lib/"

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen $_features
}

check() {
	cargo test --frozen $_features
}

package() {
	install -Dm755 target/release/conduit -t "$pkgdir"/usr/bin
	install -Dm755 "$srcdir"/conduit.initd "$pkgdir"/etc/init.d/conduit
	install -Dm644 "$srcdir"/conduit.confd "$pkgdir"/etc/conf.d/conduit
	install -Dm644 "$srcdir"/conduit.toml "$pkgdir"/etc/conduit/conduit.toml
}

sha512sums="
afb9cfe5ef51e7b74c264a02b8985933043f8ebf0028d02d7fbb2c1c072c1b73c4a5acce477197d86bd279f37fd7e94344fbe700de58d591244512bf29b64d69  conduit-v0.8.0.tar.gz
036421da4eab0cacd289868f0125221aa49c3c6f7515b211e35bb1410b695d976d6209cdf00dbc32572b4ba7171650864b12cb41819a90754097da4863aa0d34  system-sqlite.patch
35600dd6a6c3700c6de44a3f364b08873f660c4798bff1241feeca70f7d63d5b36c0697b103e380ff0d1d8e26caf3464ad2c71902cfde465e5a128bf8cff2179  conduit.toml
be411bc3447d684c546249e6fe6573d1c7798c7dfc148564b00b60026592eafa66dec4289a2d336656291ba1b915dd8b1e4df632de44a0ec0b3ad7d971ab062f  conduit.initd
8769e2feb4e0db08d7c6861a9d9110db8b846a496086f697080fda7270c97b506cbb10326cf708cdeab5eda68ec93a5ad86db4db5b9b0ebc189e6a5cefacf3a1  conduit.confd
"
