# eza - A modern ls
# 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=eza
version=0.23.5
release=1
desc="A modern ls"
url="https://eza.rocks/"
license="MIT"
depend="glibc"
makedepend="rust cargo"
source="https://github.com/eza-community/eza/archive/refs/tags/v0.23.5.tar.gz"
sha256="SKIP"

build() {
	cd "eza-0.23.5"
	# --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/scraplinux-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.
	# libgit2-sys's build.rs prefers a system libgit2 over vendoring/building
	# its own when it finds one via pkg-config - the sandbox bind-mounts the
	# whole host filesystem read-only, and the build host has its own real
	# libgit2 sitting at /usr/lib64/libgit2.so.1.9.4 (Gentoo's own package,
	# nothing ScrapLinux ships). Without this, the resulting eza binary links
	# against that exact host copy (readelf -d showed NEEDED
	# libgit2.so.1.9), which does not exist on any real install - it only
	# ever worked here by accident, on this one build host. Forces
	# libgit2-sys to build its own vendored copy and link it statically
	# instead.
	export LIBGIT2_SYS_USE_PKG_CONFIG=0
	cargo build --release --locked
}

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