# Template file for 'librespeed-cli'
pkgname=librespeed-cli
version=1.0.10
revision=2
build_style=go
go_import_path="github.com/librespeed/speedtest-cli"
go_ldflags="-X librespeed-cli/defs.ProgName=${pkgname} -X librespeed-cli/defs.ProgVersion=${version}"
short_desc="LibreSpeed command line tool"
maintainer="Massimo Manzato <massimo.manzato@gmail.com>"
license="GPL-3.0-or-later"
homepage="https://github.com/librespeed/speedtest-cli"
distfiles="https://github.com/librespeed/speedtest-cli/archive/refs/tags/v${version}.tar.gz"
checksum=904ec84f41714d5a7ab778534d332219cd254fdd0f97cc33ebb3540d31fb802c

pre_build() {
	local _date
	if [ "$SOURCE_DATE_EPOCH" ]; then
		_date="$(date --utc --date "@$SOURCE_DATE_EPOCH" "+%Y-%m-%d")"
		go_ldflags+=" -X librespeed-cli/defs.BuildDate=${_date}"
	fi
}

post_install() {
	# Rename the executable due to conflic with PKG speedtest-cli
	mv "${DESTDIR}"/usr/bin/{speedtest,librespeed}-cli
}
