summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7bc094d92cf6c5035aece5b764e9624f52f04bda (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
# Maintainer: Haochen Tong <i at hexchain dot org>

pkgname=elvish
pkgver=0.15.0
pkgrel=1
pkgdesc="A friendly and expressive Unix shell."
arch=('i686' 'x86_64')
url="https://github.com/elves/elvish"
license=('custom:2-clause BSD')
provides=('elvish')
makedepends=('git' 'go' 'pandoc')
depends=('glibc')
source=("git+https://github.com/elves/elvish.git#tag=v$pkgver")
md5sums=('SKIP')
install=elvish.install

prepare() {
    mkdir -p "$srcdir/build"
    export GOPATH="$srcdir/build"
    export GOFLAGS="-buildmode=pie -trimpath -mod=vendor -modcacherw"
    cd "$srcdir/elvish"
    go mod vendor
}

build() {
    export GOPATH="$srcdir/build"
    export GOFLAGS="-buildmode=pie -trimpath -mod=vendor -modcacherw"
    export CGO_ENABLED=0
    cd "$srcdir/elvish"
    go build -v -ldflags="-X github.com/elves/elvish/pkg/buildinfo.Version=$pkgver" .

    cd website
    mkdir -p "$srcdir/doc"
    go build -v ./cmd/elvdoc/
    for file in builtin edit epm language math platform readline-binding re store str unix; do
        ./elvdoc -filter < "ref/$file.md" | pandoc \
            -s -f gfm -t man -V section:7 \
            -V header:"Miscellaneous Information Manual" \
            -V footer:"Elvish $pkgver" -M date:"$(date -u --date=@${SOURCE_DATE_EPOCH} "+%b %d, %Y")" \
            -M title:"elvish-$file" \
            -o "$srcdir/doc/elvish-$file.7"
    done
}

check() {
    export GOPATH="$srcdir/build"
    export GOFLAGS="-trimpath -mod=vendor -modcacherw"
    export CGO_ENABLED=1
    cd "$srcdir/elvish"
    make test
}

package() {
    install -Dm755 "$srcdir/elvish/elvish" -t "$pkgdir/usr/bin/"
    install -Dm644 "$srcdir/$pkgname/LICENSE" -t "$pkgdir/usr/share/licenses/$pkgname/"

    install -dm755 "$pkgdir/usr/share/man/man7"
    cp -rv --no-preserve=ownership "$srcdir/doc/"* "$pkgdir/usr/share/man/man7"
}