#!/bin/sh
# In corekeeper, this is the only file outside /etc on all arches.
# So this is the only file available to detect a purged package.
if [ ! -e /usr/share/lintian/overrides/corekeeper ] ; then
	exit 0
fi
cd /var/cache/corekeeper/
find /var/crash -name '*.core' \( \( -mtime +7 -delete -fprint /dev/stderr \) -o \( -print \) \) > next 2> deleted
sort current current next | uniq -u > new
sort deleted deleted new new next | uniq -u > old

if [ -s new ] ; then
	echo 'New core file(s):'
	echo
	cat new
	echo
fi

if [ -s deleted ] ; then
	echo 'Deleted core file(s):'
	echo
	sort deleted
	echo
fi

if [ -s old ] ; then
	echo 'Old core file(s):'
	echo
	cat old
	echo
fi

rm -f deleted old new
mv -f next current
