summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 752fe54e7d7f471e7c5154c49ec31eb42b0c71bf (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
# Maintainer: ml <ml@visu.li>
pkgname=helm-diff
pkgver=3.1.1
pkgrel=1
pkgdesc='Helm plugin that shows a diff explaining what a helm upgrade would change'
arch=('x86_64')
url='https://github.com/databus23/helm-diff'
license=('Apache')
install=helm-diff.install
depends=('glibc')
# `go mod init` wants git
makedepends=('git' 'go')
source=("${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz")
sha256sums=('3a077e964ba9b06e3489875f76491bbe4bb53c1131c19d49b8d9cfd7b5aa8606')

prepare() {
  cd "${pkgname}-${pkgver}"
  # fails when go.mod present from previous run
  [[ ! -f go.mod ]] && go mod init github.com/databus23/helm-diff
  # go mod init didn't catch stretchr/testify
  go mod edit -require github.com/stretchr/testify@v1.5.1
  # `go mod download` fails to get all required modules and `go build -mod=readonly` fails
  go mod tidy
  sed -i '/^hooks:$/Q' plugin.yaml
}

build() {
  cd "${pkgname}-${pkgver}"
  export CGO_LDFLAGS="$LDFLAGS"
  export CGO_CFLAGS="$CFLAGS"
  export CGO_CPPFLAGS="$CPPFLAGS"
  export CGO_CXXFLAGS="$CXXFLAGS"
  export GOFLAGS='-buildmode=pie -trimpath -modcacherw -mod=readonly'
  go build -o bin/diff -ldflags "-X github.com/databus23/helm-diff/cmd.Version=${pkgver}"
}

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

package() {
  cd "${pkgname}-${pkgver}"
  install -Dm755 bin/diff -t "${pkgdir}/usr/lib/helm/plugins/helm-diff/bin"
  install -m644 plugin.yaml -t "${pkgdir}/usr/lib/helm/plugins/helm-diff"
}