# Template file for 'kubernetes-helm'
pkgname=kubernetes-helm
version=2.10.0
revision=2
hostmakedepends="go make git mercurial"
short_desc="The Kubernetes Package Manager"
maintainer="Kyle Nusbaum <knusbaum+void@sdf.org>"
license="Apache-2.0"
homepage="https://helm.sh/"
distfiles="https://github.com/helm/helm/archive/v${version}.tar.gz"
checksum=544511a814a0aefc4f74e196d96bea7930d83df059551d0b57c28439f6df4137
nopie=true
conflicts="helm"
wrksrc="helm-${version}"
_go_target_arch=$(source /void-packages/common/environment/build-style/go.sh; echo $GOARCH)

do_extract() {
	mkdir -p golib/src/k8s.io/helm
	tar -xvzf ${XBPS_SRCDISTDIR}/${pkgname}-${version}/v${version}.tar.gz \
		-C golib/src/k8s.io/helm \
		--strip-components 1 \
		helm-${version}
}

pre_build() {
	export GOPATH="$(pwd)/golib"

	## The current version of glide in the repository has
	## a bug that prevents building, so pull the current
	## version from git.
	CC=/bin/gcc go get github.com/Masterminds/glide
	CC=/bin/gcc go get github.com/mitchellh/gox
	CC=/bin/gcc go install github.com/Masterminds/glide
	CC=/bin/gcc go install github.com/mitchellh/gox
	PATH="$PATH:$(pwd)/golib/bin/"
	export PATH
}

do_build() {
	cd golib/src/k8s.io/helm
	TARGETS="linux/${_go_target_arch}" make bootstrap build-cross APP="..."
}

do_install() {
	vbin golib/src/k8s.io/helm/_dist/linux-${_go_target_arch}/helm
	vbin golib/src/k8s.io/helm/_dist/linux-${_go_target_arch}/rudder
	vbin golib/src/k8s.io/helm/_dist/linux-${_go_target_arch}/tiller
	vlicense golib/src/k8s.io/helm/LICENSE
}
