__

#!/bin/sh
# 
# /home/cymbala/rays-filter.sh 

# Package Ray's Mail Filter for Debian and sendmail will be able to
# block spam email via milter.

# See also: http://www.debian.org/doc/manuals/maint-guide/index.html
# ..................................................................
# ..................................................................

# Exports...
DEBEMAIL=cymbala@lafn.org
export DEBEMAIL

# Not exported...
PACKAGE=rays-filter
VER=1.14
WHOAMI=/home/cymbala/${PACKAGE}.sh
AUTHOR="Ray"
AUTHOR_EMAIL=butlerra@sbu.ac.uk
WWW=www.sendmail-filter.sbu.ac.uk
PACK_VER=${PACKAGE}-${VER}
TGZ=${PACK_VER}.tar.gz

dh_testroot
if [ $? != 0 ] ; then exit 1 ; fi

# dh_make uses root's name...
grep '^root:x:0:0:root:' /etc/passwd
if [ $? == 0 ] ; then
    echo "root's name is root in /etc/passwd"
    exit 1 ; 
fi

cd ~
# wget -nc --recursive --no-parent --force-directories http://${WWW}/
# wget -nc --force-directories http://${WWW}/${TGZ}
#
# Shortcut:
mkdir ~/$WWW ; cp /home/cymbala/www.sendmail-filter.sbu.ac.uk/rays-filter-1.14.tar.gz ~/$WWW

cd ~/$WWW
tar -xvzf ${TGZ}

cd $PACK_VER
dh_make -f ../${TGZ}
cd debian

# Copyright
cat >so <<EOF
set extended
/<fill in ftp site>/s//
http:\/\/${WWW}\/${TGZ}/
/<put author\(s\) name and email here>/s//${AUTHOR} ( ${AUTHOR_EMAIL} )./
/<Must follow here>/s//Copyright on Ray's Mail Filter is held by 
South Bank University, London, UK ( http:\/\/www.sbu.ac.uk\/ ).

The software is distributed under the terms of the 
GNU General Public Licence ( http:\/\/www.fsf.org\/copyleft\/gpl.html ).
/
wq
EOF
ex -sc 'so so' copyright


# Delete unwanted files.
rm -f emacsen-*

# Maybe edit changelog...
#  * Initial Release.
#
#cat >changelog <<EOF
#EOF


# ........................................
#  Qs...
#  Q: prefix= or DESTDIR= with $(MAKE) ?
#  Q: debian/tmp or /debian/tmp/usr ?
# ........................................
#
# Some slight differences between
# debian/rules created by dh_make and debhelper/examples/rules...
#
# (1) < # GPL copyright 1997 to 1999 by Joey Hess.
#     < # This file copied from /usr/doc/debhelper/examples/rules
#     ---
#     > # GNU copyright 1997 to 1999 by Joey Hess.
#
# (2) < 	#-$(MAKE) clean
#     < 	#-$(MAKE) distclean
#     ---
#     > 	-$(MAKE) clean
#
# (3) < 	#$(MAKE) prefix=`pwd`/debian/tmp/usr install
#     ---
#     > 	$(MAKE) install DESTDIR=`pwd`/debian/tmp
#
# (4) 64c61
#     < 	dh_installchangelogs
#     ---
#     > 	dh_installchangelogs 
#
# (5) < #	dh_suidregister
#     ---
#     > 	dh_suidregister
#
#
#
cat >rules <<EOF
#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GPL copyright 1997 to 1999 by Joey Hess.
#
# This file copied from /usr/doc/debhelper/examples/rules.
#
# This file generated by ${WHOAMI} because debian/rules
#  created by dh_make differs from examples/rules in /usr/doc/debhelper.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# This is the debhelper compatability version to use.
export DH_COMPAT=1

build: build-stamp
build-stamp:
	dh_testdir

	# Add here commands to compile the package.
	#\$(MAKE)

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp

	# Add here commands to clean up after the build process.
	#-\$(MAKE) clean
	#-\$(MAKE) distclean

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# Add here commands to install the package into debian/tmp.
	#\$(MAKE) prefix=`pwd`/debian/tmp/usr install

# 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
	dh_installexamples
	dh_installmenu
#	dh_installemacsen
#	dh_installpam
#	dh_installmime
#	dh_installinit
	dh_installcron
	dh_installmanpages
	dh_installinfo
#	dh_undocumented
	dh_installchangelogs
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	# You may want to make some executables suid here.
#	dh_suidregister
#	dh_makeshlibs
	dh_installdeb
#	dh_perl
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install
EOF

cd ~/$WWW
find . -name '*~' -exec rm -f '{}' \;
###
#