summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: ee7c3ec4d9307f2de6390c69d1022b0cba885b23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Maintainer: txtsd <aur.archlinux@ihavea.quest>
# Maintainer: zefr0x < Matrix: "@zer0-x:kde.org" >

pkgname=eza-git
_pkgname="${pkgname%-git}"
pkgver=0.20.7.r0.g29afcb5
pkgrel=1
pkgdesc='A modern replacement for ls (community fork of exa)'
arch=(x86_64)
url='https://github.com/eza-community/eza'
license=('EUPL-1.2')
depends=(
  gcc-libs
  glibc
  libgit2
)
makedepends=(
  cargo
  git
  pandoc
)
checkdepends=(cargo)
provides=("${_pkgname}" exa)
conflicts=("${_pkgname}" exa)
replaces=(exa)
source=("${pkgname}::git+${url}#branch=main")
sha256sums=('SKIP')

prepare() {
  cd "${pkgname}"

  cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
}

pkgver() {
  cd "${pkgname}"

  git describe --long --tags --abbrev=7 | sed 's/\([^-]*-g\)/r\1/;s/-/./g;s/^v//'
}

build() {
  cd "${pkgname}"

  export RUSTUP_TOOLCHAIN=stable
  export CARGO_TARGET_DIR=target
  export LIBGIT2_NO_VENDOR=1
  export CFLAGS="${CFLAGS} -ffat-lto-objects"
  cargo build --frozen --release

  # Build man pages
  mkdir -p target/man
  for manpage in eza.1 eza_colors.5 eza_colors-explanation.5; do
    pandoc --standalone -f markdown -t man "man/${manpage}.md" > "target/man/${manpage}"
  done
}

check() {
  cd "${pkgname}"

  export RUSTUP_TOOLCHAIN=stable
  export CARGO_TARGET_DIR=target
  export CFLAGS="${CFLAGS} -ffat-lto-objects"
  cargo test --frozen --release
}

package() {
  depends+=("libgit2.so")

  cd "${pkgname}"

  install -Dm755 "target/release/${_pkgname}" "${pkgdir}/usr/bin/${_pkgname}"
  ln -s eza "${pkgdir}/usr/bin/exa"

  # Install shell completions.
  install -Dm644 "completions/zsh/_${_pkgname}" "${pkgdir}/usr/share/zsh/site-functions/_${_pkgname}"
  install -Dm644 "completions/bash/${_pkgname}" "${pkgdir}/usr/share/bash-completion/completions/${_pkgname}"
  install -Dm644 "completions/fish/${_pkgname}.fish" "${pkgdir}/usr/share/fish/vendor_completions.d/${_pkgname}.fish"

  # Install man pages
  install -Dm644 target/man/*.1 -t "${pkgdir}/usr/share/man/man1"
  install -Dm644 target/man/*.5 -t "${pkgdir}/usr/share/man/man5"

  install -Dm644 "README.md" "${pkgdir}/usr/share/doc/${_pkgname}/README.md"

  install -Dm644 -t "${pkgdir}/usr/share/licenses/${pkgname}/" "LICENSE.txt"
}