summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 1274fcd89e5c62376e1b4d8e0bc76f6cd45fd688 (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
# Maintainer: Mario Finelli <mario at finel dot li>
# Contributor: David Birks <david at birks dot dev>

pkgname=pluto
pkgver=5.20.3
pkgrel=1
pkgdesc="A cli tool to help discover deprecated apiVersions in Kubernetes"
arch=(x86_64)
url=https://github.com/FairwindsOps/pluto
license=(Apache-2.0)
depends=(glibc)
makedepends=(go)
source=("$pkgname-$pkgver.tar.gz::https://github.com/FairwindsOps/pluto/archive/v$pkgver.tar.gz")
sha256sums=('0e3991a8fd5e655953b1330a852a450dc26107ff77d1ceb20bd7464b86bd9e12')

prepare() {
  cd $pkgname-$pkgver
  export GOPATH="$srcdir/gopath"
  go mod download
}

check() {
  cd $pkgname-$pkgver
  export GOPATH="$srcdir/gopath"
  go test -mod=readonly -v ./...
}

build() {
  cd $pkgname-$pkgver

  export GOPATH="$srcdir/gopath"
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"

  go build -o pluto \
    -buildmode=pie \
    -trimpath \
    -mod=readonly \
    -modcacherw \
    -ldflags "-linkmode external -extldflags \"${LDFLAGS}\" -X main.version=${pkgver}" \
    cmd/pluto/main.go
}

package() {
  cd $pkgname-$pkgver

  install -Dm0755 $pkgname "$pkgdir/usr/bin/$pkgname"
  install -Dm0644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
  install -Dm0644 docs/*.md -t "$pkgdir/usr/share/doc/$pkgname"

  # redirect stderr to supress fairwinds ads during package
  ./pluto completion bash 2>/dev/null | install -Dm0644 /dev/stdin \
    "$pkgdir/usr/share/bash-completion/completions/pluto"
  ./pluto completion zsh 2>/dev/null | install -Dm0644 /dev/stdin \
    "$pkgdir/usr/share/zsh/site-functions/_pluto"
  ./pluto completion fish 2>/dev/null | install -Dm0644 /dev/stdin \
    "$pkgdir/usr/share/fish/vendor_completions.d/pluto.fish"
}

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