#!/bin/bash -e

# check the package list in a chroot against a reference.

if [ $(id -u) != 0 ]; then
	echo "You must be root to run this script, sorry."
	exit 1
fi

USAGE_STRING="${0##*/} <chroot>"
. /usr/share/sbuild/common_functions
parse_arg $1

tfile=$(tempfile)

# NOTE: v. 1.10.x "dpkg --root" is broken, so use grep-status
#COLUMNS=200 dpkg 2>/dev/null --list | grep ^ii | awk '{print $2}' >$tfile

grep-status -F Status -s Package ' installed' $CHROOT/var/lib/dpkg/status | awk '{print $2}' | sort >$tfile

echo "DELETE             ADD"
echo "============================"
diff -u $tfile $CHROOT/../ref-$DIST |
	tail -n +3 |
	grep ^[+-] |
	sed -e 's/^-//' -e "s/^+/                   /" |
	sort

rm -f $tfile

