# Contributor: Thomas Kienlen <kommander@laposte.net>
# Maintainer: Thomas Kienlen <kommander@laposte.net>
pkgname=certstrap
pkgver=1.3.0
pkgrel=24
pkgdesc="Tools to bootstrap CAs, certificate requests, and signed certificates"
url="https://github.com/square/certstrap"
arch="all"
license="Apache-2.0"
makedepends="go"
source="$pkgname-$pkgver.tar.gz::https://github.com/square/certstrap/archive/v$pkgver/v$pkgver.tar.gz
	update-go-deps.patch
	fix-test-parse-invalid-expiry.patch
	"
options="chmod-clean net" # go modules

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

build() {
	go build -trimpath
}

check() {
	# Fix GO 1.18 compatibility
	# https://github.com/golang/go/issues/41682
	# SHA1 support will be removed in GO 1.19
	export GODEBUG=x509sha1=1
	# Certificates have expired on 13 Mar 2024
	go test -v -skip 'TestCertificateAuthority|TestCertificateVerify' ./...
}

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

sha512sums="
f3ef9fb9e581acb028f447ac2e2b924a27d6c652d3be30a1df310f7bfde2c8cc40f5ad0fdba0396fbc6bb332c24853aeedee78a00d5217ca02007130e26c5455  certstrap-1.3.0.tar.gz
6f50f5796af73b8edc40f2305d9027cd15b0a6ef599f82682828a86174cc0cd50e432dffca15508f8f712ef677a71591fc96afcdf4ff3939e4efe678f67676d3  update-go-deps.patch
4eedd78abb9f2bac825f1ee5a81ef88be13195a78eceee459d7db832d14ef984e57bdfe44a352ee81836340cb059e5e873afdee164071de850093158a61543e2  fix-test-parse-invalid-expiry.patch
"
