summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7b3b641f6ca7b3cb0fd0c6b236cf1f82b6df3f5d (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
# Maintainer: Chocobo1 <chocobo1 AT archlinux DOT net>

pkgname=d2-git
pkgver=0.5.1.r147.gce9383577
pkgrel=1
pkgdesc="A modern diagram scripting language that turns text to diagrams"
arch=('i686' 'x86_64')
url="https://d2lang.com/"
license=('MPL2')
depends=('glibc')
makedepends=('git' 'go')
provides=("d2=$pkgver")
conflicts=('d2')
source=("git+https://github.com/terrastruct/d2.git")
sha256sums=('SKIP')


export CGO_CPPFLAGS="${CPPFLAGS}"
export CGO_CFLAGS="${CFLAGS}"
export CGO_CXXFLAGS="${CXXFLAGS}"
export CGO_LDFLAGS="${LDFLAGS}"
export GOFLAGS="-buildmode=pie -ldflags=-linkmode=external -trimpath -mod=readonly -modcacherw"

pkgver() {
  cd "d2"

  _tag=$(git tag -l --sort -v:refname | grep -E '^v?[0-9\.]+$' | head -n1)
  _rev=$(git rev-list --count $_tag..HEAD)
  _hash=$(git rev-parse --short HEAD)
  printf "%s.r%s.g%s" "$_tag" "$_rev" "$_hash" | sed 's/^v//'
}

build() {
  cd "d2"

  go build \
    ./...
}

check() {
  cd "d2"

  #go test \
  #  ./...
}

package() {
  cd "d2"

  GOBIN="$pkgdir/usr/bin" \
    go install ./

  install -Dm644 "README.md" -t "$pkgdir/usr/share/doc/d2"
  cp -r "docs" "$pkgdir/usr/share/doc/d2"

  install -Dm644 "ci/release/template/man/d2.1" -t "$pkgdir/usr/share/man/man1"
}