summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 2047ab4da240cec201ac3a68b6858efaf1ef20b0 (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
# Maintainer: Mario Finelli <mario at finel dot li>

pkgname=newrelic-cli
pkgver=0.39.1
pkgrel=1
pkgdesc="The New Relic Command Line Interface"
arch=(x86_64)
url=https://github.com/newrelic/newrelic-cli
license=(Apache)
depends=(glibc)
makedepends=(go git)
source=(git+https://github.com/newrelic/${pkgname}.git?tag=v${pkgver})
sha256sums=('SKIP')

prepare() {
  cd newrelic-cli
  export GOPATH="${srcdir}/gopath"
  go mod vendor
}

build() {
  cd newrelic-cli

  export CGO_LDFLAGS="$LDFLAGS"
  export CGO_CFLAGS="$CFLAGS"
  export CGO_CPPFLAGS="$CPPFLAGS"
  export CGO_CXXFLAGS="$CXXFLAGS"

  export GOPATH="${srcdir}/gopath"

  go build \
    -o bin/newrelic \
    -trimpath \
    -buildmode=pie \
    -mod=readonly \
    -ldflags "-s -w -linkmode external -extldflags \"${LDFLAGS}\" -X main.appName=newrelic-cli -X main.version=v${pkgver} -X github.com/newrelic/newrelic-cli/internal/client.version=v${pkgver}" \
    cmd/newrelic/*
}

package() {
  cd newrelic-cli
  install -Dm0755 bin/newrelic "$pkgdir/usr/bin/newrelic"

  "${pkgdir}/usr/bin/newrelic" completion --shell bash | install -Dm0644 \
    /dev/stdin "${pkgdir}/usr/share/bash-completion/completions/newrelic"
  "${pkgdir}/usr/bin/newrelic" completion --shell zsh | install -Dm0644 \
    /dev/stdin "${pkgdir}/usr/share/zsh/site-functions/_newrelic"
}

# vim: set ts=2 sw=2 et: