#!/usr/bin/make -f

export DH_GOLANG_INSTALL_EXTRA := pkg/tuf/repository
export DH_GOLANG_EXCLUDES := kms/hashivault kms/gcp kms/azure test/fuzz

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

execute_before_dh_auto_build:
	cd _build/src/github.com/sigstore/sigstore/pkg; \
	 rgrep -q "github.com/theupdateframework/go-tuf/v0" tuf fulcioroots \
	 || find tuf fulcioroots -type f -print0 | xargs -0 \
	  perl -pi -e 's,github.com/theupdateframework/go-tuf,github.com/theupdateframework/go-tuf/v0,'

override_dh_auto_test:
# disable tests for now
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	# make test binaries available where the tests expect them
	mkdir -p -m700 $(CURDIR)/debian/tmp-home/
	env \
	  HOME=$(CURDIR)/debian/tmp-home/.cache \
	  DH_GOLANG_EXCLUDES="$${DH_GOLANG_EXCLUDES}" \
	dh_auto_test -v --max-parallel=2 -- -tags "$(BUILDTAGS)"
	rm -rf $(CURDIR)/debian/tmp-home
endif
