#!/usr/bin/make -f

# there's Go code in hack/ but nothing we should test/ship
# and the integration tests obviously fail during a normal build
export DH_GOPKG := github.com/docker/containerd
export DH_GOLANG_EXCLUDES := \
	github.com/docker/containerd/hack \
	github.com/docker/containerd/integration-test

%:
	dh $@ --buildsystem=golang --with=golang --builddirectory=_build

override_dh_auto_configure:
	dh_auto_configure
	## Sub-vendor runc vendors and our vendors:
	set -ex; for pkg in \
		github.com/docker/docker/pkg/listeners \
		github.com/docker/docker/pkg/term \
		github.com/opencontainers/runtime-spec \
	; do \
		mkdir -p "_build/src/$(DH_GOPKG)/vendor/$$pkg"; \
		parentDir="$$(dirname "_build/src/$(DH_GOPKG)/vendor/$$pkg")"; \
		if [ -d "vendor/src/$$pkg" ]; then \
			cp -vr "vendor/src/$$pkg" "$$parentDir"; \
		else \
			[ -d "/usr/share/gocode/src/github.com/opencontainers/runc/vendor/$$pkg" ]; \
			cp -vr "/usr/share/gocode/src/github.com/opencontainers/runc/vendor/$$pkg" "$$parentDir"; \
		fi; \
	done

override_dh_auto_build:
	# Regenerate proto files for each build
	make -C _build/src/github.com/docker/containerd -f '$(CURDIR)/Makefile' protoc
	dh_auto_build
