# Contributor: Marc Vertes <mvertes@free.fr>
# Maintainer: Mikael Jenkler <mikael@jenkler.com>
pkgname=mongodb-tools
pkgver=100.9.4
pkgrel=5
pkgdesc="The MongoDB tools provide import, export, and diagnostic capabilities."
url="https://github.com/mongodb/mongo-tools"
arch="all !s390x !riscv64" # rv64 hangs
license="Apache-2.0"
makedepends="
	go
	krb5-dev
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/mongodb/mongo-tools/archive/$pkgver.tar.gz"
builddir="$srcdir/mongo-tools-$pkgver"
options="!check"

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

build() {
	mkdir -p bin
	local bins="
		bsondump
		mongodump
		mongoexport
		mongofiles
		mongoimport
		mongorestore
		mongostat
		mongotop
		"
	for bin in $bins; do
		go build -o bin/$bin \
			-ldflags="-X main.VersionStr=$pkgver -X main.GitCommit=alpine" \
			-tags "ssl sasl gssapi failpoints" \
			$bin/main/$bin.go
	done
}

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

sha512sums="
3c857da4587d4c473b495d5bf9b5ce2e64b7fd8c831baa89b462e93f1090d297069e6be18514412c233f2dab6ed024c7db5523c1e623513734cdd0d8d6f7167f  mongodb-tools-100.9.4.tar.gz
"
