#!/bin/sh -e

prefclean() {

	test -x /usr/share/apt-listbugs/aptcleanup || return 0
	test -x /usr/sbin/apt-listbugs || return 0
	test -f /etc/apt/preferences || return 0

	tmp=$(tempfile)

	/usr/share/apt-listbugs/aptcleanup > $tmp
	if ! diff -B $tmp /etc/apt/preferences > /dev/null; then
		if test -f "/var/backups/apt-listbugs.preferences"; then
			savelog /var/backups/apt-listbugs.preferences
		fi
		cp -aH /etc/apt/preferences /var/backups/apt-listbugs.preferences
		cp $tmp /etc/apt/preferences
  	fi
  	/bin/rm -f $tmp

}

prefclean

