# bat - cat with syntax highlighting
# Generated from manifest.tsv by gen-ports.py. Edit the manifest, not this file,
# unless the package needs something the template cannot express - in which case
# drop a `recipe.local` beside it and it will be preserved.
name=bat
version=0.26.0
release=1
desc="cat with syntax highlighting"
url="https://github.com/sharkdp/bat"
license="MIT Apache-2.0"
depend="glibc"
makedepend="rust cargo"
source="https://github.com/sharkdp/bat/archive/refs/tags/v0.26.0.tar.gz"
sha256="SKIP"

build() {
	cd "bat-0.26.0"
	# --offline needs a vendored dependency tree that nothing here produces -
	# every crate the recipe does not vendor itself fails with "no matching
	# package found" before a single line of Rust compiles. The build
	# sandbox already reaches the network to fetch the source tarball
	# itself; letting cargo reach crates.io the same way is the same trust
	# boundary, not a new one.
	#
	# CARGO_HOME defaults to ~/.cargo - under the sandbox's read-only host
	# bind when building as root, so cargo's own registry cache had nowhere
	# to write and every download failed with "Read-only file system".
	export CARGO_HOME="${CARGO_HOME:-/tmp/arctic-cargo-home}"
	# Not clang/lld - nothing else in this tree builds with them (every other
	# recipe just uses cc, which is gcc here), and forcing a linker that is
	# not actually installed failed every single Rust package the same way.
	cargo build --release --locked
}

package() {
	cd "bat-0.26.0"
	install -Dm755 "target/release/bat" "$pkgdir/usr/bin/bat"
	for d in README.md README LICENSE; do
		[ -f "$d" ] && install -Dm644 "$d" "$pkgdir/usr/share/doc/bat/$d"
	done
	true
}
