summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: ac87b670f20f34e6c51a51e90a1f0ee07ed31613 (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
# Maintainer: txtsd <aur.archlinux@ihavea.quest>
# Maintainer: zefr0x < Matrix: "@zer0-x:kde.org" >

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

prepare() {
    cd "${pkgname}"

    cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

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 CFLAGS="${CFLAGS} -ffat-lto-objects"

    cargo build --frozen --release

    # Build man pages
    mkdir -p target/man 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" "libz.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 "LICENCE" "${pkgdir}/usr/share/licenses/${_pkgname}/LICENSE-MIT"
}