pkgname=httm
pkgver=0.33.0
pkgrel=1
pkgdesc="Prints the size, date and locations of available unique versions (deduplicated by modify time and size) of files residing on ZFS or BTRFS snapshots."
arch=('x86_64')
url="https://github.com/kimono-koans/httm/blob/master/README.md"
license=('MPL-2.0')
groups=('utility')
options=('!strip' '!emptydirs')
makedepends=('cargo')
source=("${pkgname}-${pkgver}.tar.gz::https://static.crates.io/crates/$pkgname/$pkgname-$pkgver.crate")
sha512sums=('b0fe3955f3b3ce489b34c904bf0ad82149b2d81f1ad97428226b9f7f41e066f0cbe3050f63ad6d7f1f6ba52ac932e5e61a90ef72b6d2c5655011e548e6aedb20')

prepare() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
	cd -
}

build(){
	export RUSTUP_TOOLCHAIN=stable
	export CARGO_TARGET_DIR=target
	# use cargo to build from a tagged release
	cd "${srcdir}/${pkgname}-${pkgver}"
	cargo build --frozen --release --all-features
	cd -
}

package(){
	# install executable
	install -Dm755 "${srcdir}/${pkgname}-${pkgver}/target/release/${pkgname}" "${pkgdir}/usr/bin/${pkgname}"

	# install bowie script
	install -Dm755 "${srcdir}/${pkgname}-${pkgver}/scripts/bowie.bash" "${pkgdir}/usr/bin/bowie"

	# install ounce script
	install -Dm755 "${srcdir}/${pkgname}-${pkgver}/scripts/ounce.bash" "${pkgdir}/usr/bin/ounce"

	# install nicotine script
	install -Dm755 "${srcdir}/${pkgname}-${pkgver}/scripts/nicotine.bash" "${pkgdir}/usr/bin/nicotine"

	# install equine script
	install -Dm755 "${srcdir}/${pkgname}-${pkgver}/scripts/equine.bash" "${pkgdir}/usr/bin/equine"

	# install man page
	install -Dm644 "${srcdir}/${pkgname}-${pkgver}/${pkgname}.1" "${pkgdir}/usr/share/man/man1/${pkgname}.1"

	# install README.md
	install -Dm644 "${srcdir}/${pkgname}-${pkgver}/README.md" "${pkgdir}/usr/share/doc/${pkgname}/README.md"

	# install LICENSE
	install -Dm644 "${srcdir}/${pkgname}-$pkgver/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}