#!/usr/bin/make -f
export DH_OPTIONS
export DH_GOPKG:=github.com/kata-containers/proxy
export DEB_BUILD_OPTIONS=nocheck
export PATH:=/usr/src/packages/BUILD/local/go/bin:$(PATH)
export GOROOT:=/usr/src/packages/BUILD/local/go
export GOPATH=/usr/src/packages/BUILD/go

GO_VERSION=@GO_VERSION@

%:
	dh $@

override_dh_auto_build:
	mkdir -p /usr/src/packages/BUILD/local/
	mkdir -p /usr/src/packages/BUILD/go/src/github.com/kata-containers/
	tar xzf /usr/src/packages/SOURCES/go$(GO_VERSION).linux-@GO_ARCH@.tar.gz -C /usr/src/packages/BUILD/local/
	ln -s /usr/src/packages/BUILD/ /usr/src/packages/BUILD/go/src/github.com/kata-containers/proxy
	cd $(GOPATH)/src/github.com/kata-containers/proxy && make COMMIT=@HASH@

override_dh_auto_install:
	mkdir debian/kata-proxy
	make install DESTDIR=$(shell pwd)/debian/kata-proxy COMMIT=@HASH@
