pkgname=eza
pkgver=0.23.4
pkgdesc="A modern replacement for ls (community fork of exa)"
homepage="https://github.com/eza-community/eza"
arch=(x86_64)
license=(EUPL-1.2)
depends=(gcc-libs # libgcc_s.so
         glibc # libc.so libm.so
         libgit2)
makedepends=(cargo)
sources=("${pkgname}-${pkgver}.tar.gz")
urls=("${homepage}/archive/v${pkgver}/${sources[0]}")
md5sums=("361cee7e9c281b9bb4236e465e0a5ad7")

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
  cargo fetch --locked --target "$(rustc --print host-tuple)"
}

src_build() {
  export LIBGIT2_NO_VENDOR=1
  CFLAGS+=' -ffat-lto-objects'
  cargo build --frozen --release
}

src_check() {
  cargo test --frozen
  target/release/eza -la
}

src_install() {
  install -Dm755 "target/release/${pkgname}" "${pkgdir}/usr/bin/${pkgname}"
  ln -s eza "${pkgdir}/usr/bin/exa"

  install -Dm644 "completions/bash/${pkgname}" -t "${pkgdir}/usr/share/bash-completion/completions"
  install -Dm644 "completions/zsh/_${pkgname}" -t "${pkgdir}/usr/share/zsh/site-functions/"
  install -Dm644 "completions/fish/${pkgname}.fish" -t "${pkgdir}/usr/share/fish/vendor_completions.d"
}


# vim:ft=sh syn=sh et sw=2:
