#!/usr/bin/make -f

# This should match the commit currently used by the git submodule
PURL_SPEC_COMMIT=5d9516cc661e77a88cf33fadc057d18df963ff3c

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

execute_before_dh_auto_test:
	cp -r debian/missing-sources/purl-spec _build/src/github.com/package-url/packageurl-go/testdata/

# These testdata are not needed in built packages, removing them makes the build
# reproductible with the nocheck build profile.
execute_after_dh_auto_test:
	rm -r _build/src/github.com/package-url/packageurl-go/testdata/purl-spec

# Maintainers should call this target to update the missing-sources
update-missing-sources:
	mkdir -p debian/missing-sources/purl-spec
	wget https://github.com/package-url/purl-spec/archive/$(PURL_SPEC_COMMIT).tar.gz -O /tmp/purl-spec.tar.gz
	tar -C debian/missing-sources/purl-spec -xvf /tmp/purl-spec.tar.gz --strip-components=1 purl-spec-$(PURL_SPEC_COMMIT)/tests
	rm /tmp/purl-spec.tar.gz
