# Template file for 'kapacitor'
pkgname=kapacitor
version=1.3.3
revision=1
_branch=v1.3
_commit=ce586f3
build_style="go"
go_import_path="github.com/influxdata/${pkgname}"
build_wrksrc="go/src/${go_import_path}"
system_accounts="_kapacitor"
_kapacitor_homedir="/var/lib/kapacitor"
make_dirs="/var/lib/kapacitor 0755 _kapacitor _kapacitor"
conf_files="/etc/${pkgname}/${pkgname}.conf"
short_desc="Open source framework for alerting on time series data"
maintainer="Nicklaus McClendon <nicklaus@kulinacs.com>"
license="MIT"
homepage="https://www.influxdata.com/time-series-platform/kapacitor/"
distfiles="https://github.com/influxdata/${pkgname}/archive/v${version}.tar.gz"
checksum=605699bf5c7dd0bff11b4bd36f9cd481e76b2af22b18468b81c82aeab45818cf

do_extract() {
	mkdir -p ${wrksrc}/${build_wrksrc}
	tar xfz ${XBPS_SRCDISTDIR}/${pkgname}-${version}/*.tar.gz --strip-components=1 -C ${wrksrc}/${build_wrksrc}
}

do_build() {
	export GOPATH="/builddir/${pkgname}-${version}/go/"
	go build -ldflags="-X main.version=${version} -X main.branch=${_branch} -X main.commit=${_commit}" ./cmd/kapacitor
	go build -ldflags="-X main.version=${version} -X main.branch=${_branch} -X main.commit=${_commit}" ./cmd/kapacitord
}

do_install() {
	vbin kapacitor
	vbin kapacitord
}

post_install() {
	vsv kapacitor
	vmkdir etc/kapacitor/
	vmkdir usr/share/bash-completion/completions
	vlicense LICENSE
	vcopy etc/kapacitor/kapacitor.conf etc/kapacitor/kapacitor.conf
	vcopy usr/share/bash-completion/completions/kapacitor usr/share/bash-completion/completions/kapacitor
}
