#!/bin/bash
# check if all directories are owned by a package

echo "... checking filelist"
TOPDIR=/usr/src/packages
test -d $BUILD_ROOT/.build.packages && TOPDIR=/.build.packages
ret=0

for pkg in `find $BUILD_ROOT$TOPDIR/RPMS -name "*.rpm" | LC_ALL=C sort`; do
	case "$pkg" in
		*-debuginfo-*|*-debugsource-*) continue ;;
	esac
	rpm -qlp $pkg | chroot $BUILD_ROOT /usr/lib/build/checks-data/checkdirs "${pkg##*/}"
	[ $? = 0 ] || ret=1
done

exit $ret
