# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=docuum
pkgver=0.24.0
pkgrel=0
pkgdesc="Perform least recently used (LRU) eviction of Docker images"
url="https://github.com/stepchowfun/docuum"
# riscv64: rust is broken on this arch
# s390x: fails to build nix crate
arch="all !riscv64 !s390x"
license="MIT"
makedepends="cargo cargo-auditable"
install="$pkgname.pre-install"
subpackages="$pkgname-openrc"
source="https://github.com/stepchowfun/docuum/archive/v$pkgver/docuum-$pkgver.tar.gz
	$pkgname.initd
	$pkgname.confd
	$pkgname.logrotate
	update-rust-libc.patch
	"

prepare() {
	default_prepare

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

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

check() {
	# format::tests::code_str_display - broken test?
	cargo test --frozen -- \
		--skip format::tests::code_str_display
}

package() {
	install -D -m755 target/release/$pkgname -t "$pkgdir"/usr/bin/

	install -D -m755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -D -m644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
	install -D -m644 "$srcdir"/$pkgname.logrotate "$pkgdir"/etc/logrotate.d/$pkgname
}

sha512sums="
2a6ec536d8cea3efc88df5d9be4d0040d28fa1ac0bb8cc72143d27c51eeb6f31d9c6652b86bf895acc9128b27a5d73d99b43cde16fcbe33bb201e8ed0da6643c  docuum-0.24.0.tar.gz
1bbf4baba54b4c36d44c85fa0b898e9bf10ce52ce242cc47488e8d2eb4d0ba45c6560c2ee7025811721786021ed3f4149bb7423dd1e7c07ad79c0027a5ae334d  docuum.initd
3a021f6d9fef59e4dcec56e0c91816efa7b432e4eee066888dc4dc04f08f1433b72fb48a89bbd711c96d11fde1ad5c6233b0d943ca620337c9ac955d4f95d60d  docuum.confd
63d1d053f36bb475d6775cc5806ebb44e030245a776da98724d1ac2f36247447b8d65964a8ac40d881a8c78e4224aa5f1311666e616b303a9dd879694faa0c26  docuum.logrotate
d5886d7aacaa9b65a9323ab2bb38adc71c154fcbe19a5b2288fb7ebf7f5fb60bf68ce1206aca893933a5937c76995dc77862cc305f55e86150bbd2225c25d3b3  update-rust-libc.patch
"
