#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

#DH_VERBOSE=1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

PKGDIR=debian/singularity-container
export SINGULARITY_CACHEDIR=$(PKGDIR)/var/lib/singularity/cache

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- --localstatedir=/var/lib

override_dh_auto_install:
	dh_auto_install
	: # move bash completions into now new standard location
	mv $(PKGDIR)/etc/bash_completion.d $(PKGDIR)/usr/share/bash-completion/completions

override_dh_installman:
	: # Very sloppy man pages for now
	debian/generate_manpages $(PKGDIR) $(DEB_VERSION)
	dh_installman

override_dh_installdocs:
	dh_installdocs README.md CONTRIBUTORS.md

# The test suite needs a user with sudo permission (but refuses to run as root)
# and docker.
override_dh_auto_test:

override_dh_fixperms:
	dh_fixperms
	chown root.root $(PKGDIR)/usr/lib/*/singularity/bin/*
	chmod 4755 $(PKGDIR)/usr/lib/*/singularity/bin/*-suid
