#!/bin/sh

cdd=`grep "^Package:" debian/control.stub | sed "s/Package: \+//"`

rm -rf tmp
rm -f tasks/*~
# Usermenus are now autobuilded and thus the existence of menu directory not necessary
## [ -d menu ] && 
rm -f debian/"$cdd"-*.post{inst,rm}

# remove tasksel directory
[ -d tasksel ] && rm -f tasksel/"$cdd"-* && rmdir tasksel

# Move back special postinst files provided by the meta package maintainer
#for postinst in `ls debian/*.postinst.stub 2>/dev/null` ; do
#    mv "$postinst" debian/`basename "$postinst" .stub`
#done
rm -f debian/"$cdd"-common.{templates,config,install,links} debian/90"$cdd"-common
rm -rf debian/po

# Move back special po files provided by the meta package maintainer
# [ -d debian/po.stub ] && mv debian/po.stub debian.po


if [ -f debian/control ] ; then dh_clean ; fi

# Remove debian/control and link to stub
# This ensures that build process can be started
# Note that calling cdd-install-helper has to be called to fix
# the binary entry in *.dsc file!
rm -f debian/control
ln -s control.stub debian/control

rm -f debian-"$cdd"-task.desc

exit 0
