summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: acd8299ad02133f34d19a7f0a2fec69bb1ea47d7 (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
# Maintainer: Frederik Holm Strøm <aur@frederikstroem.com>

_pkgname="psource"
pkgname="${_pkgname}-git"
pkgver=0.4.3.f2eae02 # This will be dynamically replaced by the pkgver() function
pkgrel=1
pkgdesc="CLI tool to pretty print source code to stdout or directly to the clipboard."
arch=('x86_64')
url="https://github.com/frederikstroem/psource"
source=("${pkgname}::git+${url}.git")
license=('MIT')
depends=("libgit2.so")
makedepends=('git' 'cargo')
checkdepends=("cargo")
options=(!lto)
provides=("${_pkgname}")
conflicts=("${_pkgname}")
sha256sums=('SKIP')

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

pkgver() {
    cd "${pkgname}"

    # Get the latest tag without the "v" prefix, then append the short commit hash
    local _tag=$(git describe --tags $(git rev-list --tags --max-count=1) | sed 's/^v//')
    local _commit=$(git rev-parse --short HEAD)
    echo "${_tag}.${_commit}"
}

build() {
    cd "${pkgname}"
    export RUSTUP_TOOLCHAIN=stable
    export CARGO_TARGET_DIR=target

    cargo build --frozen --release --all-features
}

check() {
    cd "${pkgname}"
    export RUSTUP_TOOLCHAIN=stable
    export CARGO_TARGET_DIR=target

    cargo test --frozen --all-features
}

package() {
    cd "${pkgname}"

    # Install binary
    install -Dm755 "target/release/${_pkgname}" "${pkgdir}/usr/bin/${_pkgname}"

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

    # Install license
    install -Dm644 "LICENSE" "${pkgdir}/usr/share/licenses/${_pkgname}/LICENSE"
}