. locations.include

if [ ! -s ../../base/$FILEORDER ] ; then
   echo "You do not have ../../base/$FILEORDER so am running pkgorder to make one"
   echo "This will take quite a long time"
   $ANACONDADIR/pkgorder $TREE $ARCH $DEFAULT sites/$SITE > ../../base/$FILEORDER
fi
echo "Running genhdlist now"
echo "You may see messages about duplicate packages.  You should verify "
echo "that these packages are really ones you have replaced compared "
echo "to $TREE/$DEFAULT/RPMS"
if [ -s /tmp/genhdlist.out ] ; then
  rm /tmp/genhdlist.out
fi
$ANACONDADIR/genhdlist $1 --fileorder ../../base/$FILEORDER --default $DEFAULT --site $SITEDIR $TREE 2> /tmp/genhdlist.out
if [ -s /tmp/genhdlist.out ] ; then
	grep -v "ordering not found" /tmp/genhdlist.out
	grep -q "ordering not found" /tmp/genhdlist.out
        if [ $? = 0 ] ; then
   		echo "Your ../../base/pkgorder is out of date, making a new one"
   		echo "This will take quite a long time"
   		$ANACONDADIR/pkgorder $TREE $ARCH $DEFAULT sites/$SITE > ../../base/$FILEORDER
		echo "Running genhdlist again, since we just make a new ../../base/pkgorder"
		$ANACONDADIR/genhdlist $1 --fileorder ../../base/$FILEORDER --default $DEFAULT --site $SITEDIR $TREE
	fi
	rm /tmp/genhdlist.out
fi
