summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 25d922f5aa8c4338dc83441208efad356d0df687 (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: Mark Wells <contact@markwells.dev>
pkgname=anneal-git
pkgver=0.1.0
pkgrel=1
pkgdesc="Proactive AUR rebuild management for Arch Linux (git version)"
arch=('x86_64')
url="https://github.com/MarkWells-Dev/Anneal"
license=('GPL-3.0-or-later')
depends=('pacman' 'sqlite')
makedepends=('cargo' 'git')
optdepends=(
    'paru: AUR helper for rebuilding packages'
    'yay: AUR helper for rebuilding packages'
    'pikaur: AUR helper for rebuilding packages'
    'aura: AUR helper for rebuilding packages'
    'trizen: AUR helper for rebuilding packages'
    'rebuild-detector: detect packages needing rebuild via checkrebuild'
)
provides=('anneal')
conflicts=('anneal')
source=("git+$url.git")
sha256sums=('SKIP')

pkgver() {
    cd Anneal
    git describe --long --tags --abbrev=7 2>/dev/null | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)"
}

prepare() {
    cd Anneal
    export RUSTUP_TOOLCHAIN=stable
    cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
}

build() {
    cd Anneal
    export RUSTUP_TOOLCHAIN=stable
    export CARGO_TARGET_DIR=target
    cargo build --frozen --release
}

check() {
    cd Anneal
    export RUSTUP_TOOLCHAIN=stable
    export CARGO_TARGET_DIR=target
    cargo test --frozen
}

package() {
    cd Anneal

    # Binary
    install -Dm755 target/release/anneal "$pkgdir/usr/bin/anneal"

    # Pacman hook
    install -Dm644 contrib/anneal-trigger.hook \
        "$pkgdir/usr/share/libalpm/hooks/anneal-trigger.hook"

    # Shell completions
    install -dm755 "$pkgdir/usr/share/bash-completion/completions"
    install -dm755 "$pkgdir/usr/share/zsh/site-functions"
    install -dm755 "$pkgdir/usr/share/fish/vendor_completions.d"

    target/release/anneal completions bash > "$pkgdir/usr/share/bash-completion/completions/anneal"
    target/release/anneal completions zsh > "$pkgdir/usr/share/zsh/site-functions/_anneal"
    target/release/anneal completions fish > "$pkgdir/usr/share/fish/vendor_completions.d/anneal.fish"

    # Config directory structure
    install -dm755 "$pkgdir/etc/anneal/triggers"
    install -dm755 "$pkgdir/etc/anneal/packages"

    # Documentation
    install -Dm644 README.md "$pkgdir/usr/share/doc/${pkgname%-git}/README.md"
    install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}