# Contributor: Marvin Preuss <marvin@xsteadfastx.org>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=ali
pkgver=0.7.5
# this is used for the help command to print the commit.
# needs to be changed on every release.
_rev=c0aa677
pkgrel=30
pkgdesc="Generate HTTP load and plot the results in real-time"
url="https://github.com/nakabonne/ali"
arch="all"
license="MIT"
options="chmod-clean"
makedepends="go"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/nakabonne/ali/archive/refs/tags/v$pkgver.tar.gz
	upgrade-gomod.patch
	"

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

build() {
	go build \
		-ldflags "
		-X \"main.version=$pkgver\" \
		-X \"main.date=$(date -u "+%Y-%m-%dT%TZ" ${SOURCE_DATE_EPOCH:+-d @$SOURCE_DATE_EPOCH})\" \
		-X \"main.commit=$_rev\" \
		"
}

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

package() {
	install -Dvm755 ali -t "$pkgdir"/usr/bin/

	install -Dvm644 README.md -t "$pkgdir"/usr/share/doc/$pkgname/
	install -Dvm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}

sha512sums="
6ae745556bec663abcb2a8d6c5e090fdd5e6b5a8bb889f85c528f749de79eb0e33d794265a801983f8de81629e19a1a38fe147e5095108310b1a353766866ff3  ali-0.7.5.tar.gz
cf0155e69fc8557669691761683bbf2ff159f16ca50c7b7a54978aa94bbdcb67788fe7db7f83ba8878def192e20fbf2ef3896169ee89d7a6b9cb698ece90d03f  upgrade-gomod.patch
"
