#!/usr/bin/make -f

TMP:=debian/$(shell dh_listpackages)/
%:
	dh $@

override_dh_fixperms:
	dh_fixperms
	chmod 0755 $(TMP)/usr/bin/01-normal-script
	chmod 0644 $(TMP)/usr/bin/02-no-exec-script
	rm -f $(TMP)/usr/bin/03-hardlink-script
	ln $(TMP)/usr/bin/01-normal-script $(TMP)/usr/bin/03-hardlink-script
	chmod 0755 $(TMP)/usr/bin/04-not-a-script

override_dh_auto_build:
	mkdir man
	for FILE in *-script ; do \
		sed s/@SCRIPT@/$$FILE/g script.pod | \
			pod2man --name="$$(echo "$$FILE" | tr a-z A-Z )" \
                             --section=1 > man/$$FILE.1 ; \
	done

