# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=nsh
pkgver=0.4.2
pkgrel=1
pkgdesc="A command-line shell like fish, but POSIX compatible"
url="https://github.com/nuta/nsh"
arch="aarch64 armhf armv7 ppc64le x86 x86_64"  # limited by rust/cargo
license="CC0-1.0 OR MIT"
# bash is needed for completion
depends="bash"
checkdepends="python3 py3-termcolor"
makedepends="cargo cargo-auditable"
install="$pkgname.post-install $pkgname.pre-deinstall"
subpackages="$pkgname-dbg"
source="https://github.com/nuta/nsh/archive/v$pkgver/nsh-$pkgver.tar.gz"


prepare() {
	default_prepare

	# Optimize for size (1.9 -> 1.4 MiB).
	sed -i 's/^opt-level\s*=.*/opt-level = "z"/' Cargo.toml

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

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

check() {
	# Disabled due to: "`![feature]` may not be used on the stable release channel`"
	#cargo test --frozen

	# Integration tests
	./test.py
}

package() {
	cargo auditable install --locked --offline --path . --root="$pkgdir/usr"
	rm "$pkgdir"/usr/.crates*
}

sha512sums="
5b8e4b27526c567c12e79b1583b5036a2c28aca4bb58256f2d66714c37d4b89cfb77ec1c8124602b2786fbd05c52f01a12d10f7de18c548e88fe96dbbf5d7615  nsh-0.4.2.tar.gz
"
