# Maintainer: Hristiyan Ivanov <hristiyan.d.ivanov@gmail.com>
pkgname=regclient
pkgver=0.7.1
pkgrel=0
pkgdesc="Docker and OCI registry client"
url="https://github.com/regclient/regclient"
arch="all !loongarch64"
license="Apache-2.0"
makedepends="go"
source="$pkgname-$pkgver.tar.gz::https://github.com/regclient/regclient/archive/refs/tags/v$pkgver.tar.gz"

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

case "$CARCH" in
s390x|x86|riscv64|ppc64le)
	options="$options !check" # some tests are designed only for specific architectures
	;;
esac

prepare() {
	default_prepare
	go mod download
}

build() {
	for package in regctl regsync regbot; do
		go build \
			-ldflags "-X github.com/regclient/regclient/internal/version.vcsTag=v$pkgver" \
			-tags nolegacy \
			-o bin/$package ./cmd/$package
	done
}

check() {
	go test ./...
}

package() {
	for package in regctl regsync regbot; do
		install -Dm0755 bin/$package -t "$pkgdir"/usr/bin/
	done
}
sha512sums="
e596596de88c56f586ae164c503fa30ef177a215aa7b56112f524d8820a08dff126b03e8b6b582625188fe4c256cfb3dc6e03019afc598b693bd13ab26068b48  regclient-0.7.1.tar.gz
"
