#!/usr/bin/make -f

# -w: "disable DWARF generation" for slightly smaller binaries (since we're skipping stripping; see below)
export GOFLAGS := -ldflags=-w

override_dh_auto_test:
	dh_auto_test
	
	# the autopkgtest makes sure the package functions properly, but here we can at least make sure the binary runs successfully
	debian/.build/bin/gosu --version
	debian/.build/bin/gosu --help
	# (the full upstream test suite is necessarily involved and not something we can easily run either here *or* in autopkgtest)

override_dh_auto_install:
	dh_auto_install -- --no-source
	
	# the binary needs to go into sbin, not bin
	test -d debian/gosu/usr/bin -a ! -d debian/gosu/usr/sbin
	mv debian/gosu/usr/bin debian/gosu/usr/sbin

override_dh_strip:
	: # stripping Go binaries prevents govulncheck from working, which is a disservice to the community

%:
	dh $@ --builddirectory=debian/.build --buildsystem=golang --with=golang
