# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=sops
pkgver=3.9.1
pkgrel=5
pkgdesc="Simple and flexible tool for managing secrets"
url="https://github.com/getsops/sops"
license="MPL-2.0"
arch="all"
makedepends="go"
checkdepends="gpg gpg-agent"
source="https://github.com/getsops/sops/archive/v$pkgver/sops-$pkgver.tar.gz
	fix-tests.patch
	"
options="net" # for downloading Go modules

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -v ./cmd/sops
}

check() {
	# remove -trimpath. PGP tests tries to access a local PGP key.
	# kms and hcvault tests attempt to spawn a docker container.
	# shellcheck disable=2046
	GOFLAGS="${GOFLAGS/-trimpath/}" go test \
		-skip TestPGP \
		$(go list ./... | grep -v -e '/kms$' -e '/hcvault$')
}

package() {
	install -Dm755 sops -t "$pkgdir"/usr/bin/
}

sha512sums="
2a62a4f9387761cc1d283da4526f92bf77b85950a20966b5d59e2054fe3c6759b179cb49a788d722f509cb6efdb5bbfe6b122beec78241ed08993fe1c834064e  sops-3.9.1.tar.gz
b1abca2e59f0cb704b69b675e65b99133b85f597b75a2164395144c8d724c9512e9a90d11e66218039b6542d09d1b8b1323d944977254473a8143c635722940f  fix-tests.patch
"
