summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7f6f36ed6f215bf272fd64f1652a05b454108815 (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
# Maintainer: George Rawlinson <grawlinson@archlinux.org>

pkgname=gokart
pkgver=0.5.1
pkgrel=1
pkgdesc='Static analysis tool for securing Go code'
arch=('x86_64')
url='https://github.com/praetorian-inc/gokart'
license=('Apache')
depends=('glibc')
makedepends=('git' 'go')
options=('!lto')
_commit='3d38a9ae72f7d67d5c13f83ec5669630868e409e'
source=("$pkgname::git+$url.git#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

prepare() {
  cd "$pkgname"

  # create directory for build output
  mkdir build

  # download dependencies
  go mod vendor
}

build() {
  cd "$pkgname"
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"

  go build -v \
    -trimpath \
    -buildmode=pie \
    -mod=vendor \
    -modcacherw \
    -ldflags "-linkmode external -extldflags ${LDFLAGS}" \
    -o build .
}

check() {
  cd "$pkgname"
  go test -v ./...
}

package() {
  cd "$pkgname"

  # binary
  install -vDm755 -t "$pkgdir/usr/bin" "build/$pkgname"

  # documentation
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" *.md
}