#! /bin/sh
# (re)generate diff for debian manpage naming
# should be run after applying all previous debian patches!
set -e

inf=conf/postfix-files
patch=debian/patches/05_debian_manpage_differences.diff

sed -r \
	-e 's|(manpage_directory/man[15]/[^:]+\.[15]):|\1.gz:|' \
	-e 's|(manpage_directory/man8/[^:]+\.8):|\1postfix.gz:|' \
	$inf > $inf.tmp
cat >$patch.tmp <<EOF
From: Michael Tokarev <mjt@tls.msk.ru>
Subject: update postfix-files for debian manpage naming
Forwarded: not-needed
Debian-Specific: yes

Auto-generated by ${0#./}

--- a/$inf
+++ b/$inf
EOF

diff -U1 $inf $inf.tmp | sed '1,2d' >> $patch.tmp

if cmp -s $patch.tmp $patch; then
	rm -f $patch.tmp
else
	mv -f $patch.tmp $patch
	echo "$patch updated"
fi
rm -f $inf.tmp
