summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 0415ce00534fc7e598471da9c6d78075f094a1c0 (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
# Maintainer: ChaseCares <aur at chasecares dot dev>
# Contributor: Thomas <thomas at 6f dot io>

pkgname=jujutsu-git
_pkgname=jj
pkgver=0.22.0.r109.gb795bf956
pkgrel=1
depends=(gcc-libs # libgcc_s.so
    glibc         # libc.so libm.so
    libgit2 libgit2.so
    libssh2 libssh2.so)
# openssh and git are needed for tests
makedepends=(openssh cargo git)
arch=(i686 x86_64 armv6h armv7h)
pkgdesc="Git-compatible VCS that is both simple and powerful"
url="https://github.com/martinvonz/jj"
license=(Apache-2.0)
source=("$pkgname::git+$url")
conflicts=('jj' 'jujutsu')
provides=('jj' 'jujutsu')
sha256sums=('SKIP')

pkgver() {
    cd "$pkgname"

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

prepare() {
    cd "$pkgname"

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

    mkdir -p completions
}

build() {
    cd "$pkgname"

    export LIBGIT2_NO_VENDOR=1
    export LIBSSH2_SYS_USE_PKG_CONFIG=1

    CFLAGS+=' -ffat-lto-objects'

    if [[ $(rustc -V) == *"nightly"* ]]; then
        _features+="backtrace,"
    fi

    cargo build --frozen --features "${_features:-}" --release --target-dir target

    "target/release/$_pkgname" util completion bash >"completions/$_pkgname.bash"
    "target/release/$_pkgname" util completion elvish >"completions/$_pkgname.elv"
    "target/release/$_pkgname" util completion fish >"completions/$_pkgname.fish"
    "target/release/$_pkgname" util completion nushell >"completions/$_pkgname.nu"
    "target/release/$_pkgname" util completion zsh >"completions/_$_pkgname"
}

check() {
    cd "$pkgname"

    cargo test --frozen --all-features
}

package() {
    cd "$pkgname"

    install -Dm755 -t "$pkgdir/usr/bin" "target/release/$_pkgname"

    install -Dm644 -t "$pkgdir/usr/share/doc/$pkgname" ./*.md
    cp --archive ./docs/* "$pkgdir/usr/share/doc/$pkgname"
    install -Dm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE

    install -Dm644 -t "$pkgdir/usr/share/bash-completion/completions" "completions/$_pkgname.bash"
    install -Dm644 -t "$pkgdir/usr/share/elvish/lib/" "completions/$_pkgname.elv"
    # TODO: Determine install location for nushell completions
    # install -Dm644 -t "$pkgdir/ ... " "completions/$_pkgname.nu"
    install -Dm644 -t "$pkgdir/usr/share/fish/vendor_completions.d" "completions/$_pkgname.fish"
    install -Dm644 -t "$pkgdir/usr/share/zsh/site-functions" "completions/_$_pkgname"
}