#!/usr/bin/make -f

include /usr/share/dpkg/default.mk

# Uncomment this to turn on verbose mode.
# export DH_VERBOSE=1

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

execute_after_dh_auto_configure:
	# dh_auto_configure first copies source files to the build root, then
	# symlinks libraries from /usr/share/gocode/src.
	# The dependency symlink will NOT occur when the library package uses the
	# same XS-Go-Import-Path (DH_GOPKG) as the source package and ship files
	# under the same GOPATH, causing problems in dh_auto_build due to lack of
	# installed libraries.
	# dh_auto_configure: warning: "sigs.k8s.io/kustomize" is already installed.
	# https://salsa.debian.org/go-team/packages/dh-golang/-/blob/81892fe8d3a51a22c910a649052669dd9f18837e/lib/Debian/Debhelper/Buildsystem/golang.pm#L495
	ln -vs /usr/share/gocode/src/sigs.k8s.io/kustomize/kyaml $(CURDIR)/_build/src/sigs.k8s.io/kustomize/kyaml

execute_before_dh_auto_test:
	# Remove test files that depends on docker
	find _build/src/sigs.k8s.io/kustomize/cmd/config/internal/commands/e2e -name "e2e_test.go" -delete
	find _build/src/sigs.k8s.io/kustomize/cmd/config/internal/commands/e2e -name "test_util_test.go" -delete

override_dh_auto_install:
	dh_auto_install -- --no-binaries