#!/usr/bin/make -f

# This include gives us DEB_VERSION
include /usr/share/dpkg/pkg-info.mk

%:
	dh $@

override_dh_auto_test:
	prove -r t/

override_dh_auto_install:
	mkdir -p usr/share/man/man1 usr/share/man/man8
	set -e; for script in `ls usr/bin` ; do			\
	    pod2man --release=$(DEB_VERSION) --section 1	\
		--center="stanford-server" usr/bin/$${script}	\
		> usr/share/man/man1/$${script}.1 ;		\
	done
	set -e; for script in `ls usr/sbin` ; do		\
	    if [ "$${script}" != "backup_directory_to_gcs" ]; then       \
	    echo $$script; pod2man --release=$(DEB_VERSION) --section 8		\
	  	  --center="stanford-server" usr/sbin/$${script}	\
		  > usr/share/man/man8/$${script}.8 ;		\
	    fi                                                  \
	done
	set -e; for script in `ls usr/lib/nagios/plugins` ; do		     \
	    pod2man --release=$(DEB_VERSION) --section 8		     \
		--center="stanford-server" usr/lib/nagios/plugins/$${script} \
		> usr/share/man/man8/$${script}.8 ;			     \
	done

override_dh_auto_clean:
	rm -rf usr/share

override_dh_installcron:
	dh_installcron -pstanford-server --name tripwire
	dh_installcron -pstanford-server --name remctl-acl
	dh_installcron -pstanford-server --name remctl-acl-onboot
	dh_installcron -pstanford-server --name wallet-rekey-periodic

override_dh_gencontrol:
	debian/dh_metapackage
	dh_gencontrol

override_dh_auto_build:
	pwd -P
#Dont go redhat in a debian build structure
	rm Makefile
	/bin/ls -alF
	dh_auto_build
