Index: trunk/rules.deb.in
===================================================================
--- trunk/rules.deb.in	(revision 531)
+++ trunk/rules.deb.in	(revision 549)
@@ -8,23 +8,18 @@
 #
 
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
+%:
+	dh $@ --with-autoreconf
 
-# This is the debhelper compatability version to use.
-export DH_COMPAT=9
+override_dh_clean:
+	[ ! -f Makefile ] || $(MAKE) distclean
+	-rm -f samhainrc.install
+	-rm -f build-stamp build-server-stamp build-client-stamp
+	dh_clean
 
-package=@install_name@
+override_dh_auto_configure:
+	@top_srcdir@/configure @mydefargs@
 
-# CAVEAT: including the --enable-base= option is for packages to be
-#         distributed INTERNALLY on your network, NOT for packages
-#         to be distributed to THIRD PARTIES
-
-build: build-stamp
-build-stamp:
-	dh_testdir
-	@top_srcdir@/configure @mydefargs@
-	$(MAKE) 
-	echo '#!/bin/sh' > ./sstrip
-	echo 'echo "*** SSTRIP DISABLED ***"' >> ./sstrip
+override_dh_auto_build:
+	dh_auto_build
 	if ! test x$(PASSWORD) = x; then \
 		if test -f samhain_setpwd; then \
@@ -34,101 +29,38 @@
 		fi; \
 	fi
-	touch build-stamp
 
-clean:
-	dh_testdir
-	dh_testroot
-	rm -f build-stamp
-	-[ -f Makefile ] && $(MAKE) distclean
-	dh_clean
-
-install: build
-	dh_testdir
-	dh_testroot
-	dh_clean -k
-	dh_installdirs
-
-	# Fix the permissions
-	#chmod o-rX `pwd`/debian/tmp/var/log/samhain \
-	#	`pwd`/debian/tmp/var/run/samhain \
-	#	`pwd`/debian/tmp/var/lib/samhain \
-	#	`pwd`/debian/tmp/etc/samhain
-
-	# $(MAKE) install install-boot DESTDIR=`pwd`/debian/tmp
+override_dh_auto_install:
 	$(MAKE) install install-boot DESTDIR=`pwd`/debian/@install_name@
 
+override_dh_install:
 	# However, remove the rc.d links
-	-rm -rf `pwd`/debian/tmp/etc/rc?.d
+	-rm -rf `pwd`/debian/@install_name@/etc/rc?.d
 
-	# install -m 755 encode `pwd`/debian/tmp/usr/bin/samhain_encode
-
-	# install -m 644 profiles/debianlinux_i386/samhainrc `pwd`/debian/tmp@myconffile@
-	# install -m 644 debian/samhain.logrotate `pwd`/debian/tmp/etc/logrotate.d/samhain
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-
-# Build architecture-dependent files here.
-binary-arch: build install
-#	dh_testversion
-	dh_testdir
-	dh_testroot
-	dh_installdebconf	
-	dh_installdocs 
+override_dh_installdocs:
+	dh_installdocs
 	[ -f debian/@install_name@/usr/share/doc/@install_name@/MANUAL-2_4.html.tar ] && \
 		cd debian/@install_name@/usr/share/doc/@install_name@ && \
 		tar xf MANUAL-2_4.html.tar && mv MANUAL-2_4 manual.html && \
-		rm -f MANUAL-2_4.html.tar && \
+		rm -f MANUAL-2_4.html.tar
+	[ -f debian/@install_name@/usr/share/doc/@install_name@/MANUAL-2_4.pdf ] && \
+		cd debian/@install_name@/usr/share/doc/@install_name@ && \
 		mv MANUAL-2_4.pdf manual.pdf
-	dh_installexamples @top_srcdir@/scripts/example_pager.pl \
-		@top_srcdir@/scripts/example_sms.pl \
-		@top_srcdir@/scripts/concat.pl \
-		@top_srcdir@/scripts/samhain.logrotator \
-		@top_srcdir@/scripts/samhainadmin.pl \
-		@top_srcdir@/scripts/check_samhain.pl \
-		@top_srcdir@/yulerc.template \
-		@top_srcdir@/samhainrc.linux
-	dh_installmenu
-	dh_installinit -- defaults 19
-	[ -f debian/@install_name@.postinst.debhelper ] && \
-	        cd debian && \
-		cat @install_name@.postinst.debhelper | \
-		    sed 's%/etc/init.d/@install_name@ start%:%' > postinst.tmp && \
-		    mv postinst.tmp @install_name@.postinst.debhelper
-	[ -f debian/@install_name@.postinst.debhelper ] && \
-	        cd debian && \
-		cat @install_name@.postinst.debhelper | \
-		    sed 's%invoke-rc.d @install_name@ start%:%' > postinst.tmp && \
-		    mv postinst.tmp @install_name@.postinst.debhelper
-	[ -f debian/@install_name@.prerm.debhelper ] && \
-		cd debian && \
-		cat @install_name@.prerm.debhelper | \
-		    sed 's%/etc/init.d/@install_name@ stop%/etc/init.d/@install_name@ stop || echo service @install_name@ already stopped%' > prerm.tmp && \
-		    mv prerm.tmp @install_name@.prerm.debhelper
-	[ -f debian/@install_name@.prerm.debhelper ] && \
-		cd debian && \
-		cat @install_name@.prerm.debhelper | \
-		    sed 's%invoke-rc.d @install_name@ stop%invoke-rc.d @install_name@ stop || echo service @install_name@ already stopped%' > prerm.tmp && \
-		    mv prerm.tmp @install_name@.prerm.debhelper
-	# dh_installmanpages
-	dh_installchangelogs @top_srcdir@/docs/Changelog
-	dh_link
-	dh_strip
-	dh_compress
+
+override_dh_installchangelogs:
+	dh_installchangelogs docs/Changelog
+
+override_dh_installinit:
+	dh_installinit --no-start -- defaults 19
+
+override_dh_usrlocal:
+	# do nothing
+
+override_dh_fixperms:
 	dh_fixperms
-	dh_installdeb
-	dh_shlibdeps
-	dh_gencontrol
-	dh_md5sums
-	dh_builddeb
+	# Fix the permissions
+	chmod o-rX `pwd`/debian/@install_name@/@mydataroot@ \
+		`pwd`/debian/@install_name@/@myconffile@
+	if ! test "x@mylogdir@" = "x/var/log"; then \
+		chmod o-rX `pwd`/debian/@install_name@/@mylogdir@; \
+	fi
 
-
-define checkdir
-	test -f debian/rules
-endef
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install
-
