. 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 --product sites/$SITE > ../../base/$FILEORDER 2> /tmp/pkgorder.out
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
if [ -s ../../base/excludedrpms ] ; then
   GENHDLIST="$ANACONDADIR/genhdlist $1 --ignorefile ../../base/excludedrpms --ignorelog ../../base/excludedrpms.ignored "
else
   GENHDLIST=$ANACONDADIR/genhdlist $1 
fi
$GENHDLIST --fileorder ../../base/$FILEORDER --default $DEFAULT --site $SITE $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 --product sites/$SITE fermigenericdesktop > ../../base/$FILEORDER 2> /tmp/pkgorder.out
		echo "Running genhdlist again, since we just make a new ../../base/pkgorder"
		$GENHDLIST --fileorder ../../base/$FILEORDER --default $DEFAULT --site $SITE $TREE
	fi
	rm /tmp/genhdlist.out
fi

if [ -s ../../base/excludedrpms.ignored ] ; then
   rm /tmp/excluded 2>/dev/null
   rm /tmp/excluded.asked 2>/dev/null
   rm /tmp/excluded.found 2>/dev/null
   sort ../../base/excludedrpms | uniq >/tmp/excluded.asked 
   sort ../../base/excludedrpms.ignored | uniq > /tmp/excluded.found
   comm -3 /tmp/excluded.asked /tmp/excluded.found | grep -v "^#" > /tmp/excluded
   if [ -s /tmp/excluded ] ; then
     echo ""
     echo "These file entries from your excludedrpms file were not found"
     echo "-------------------------------------------------------------"
     cat /tmp/excluded
     echo "-------------------------------------------------------------"
   fi
fi
