#These need to be done each time you want to make new install images
. locations.include
if [ $ARCH != `uname -i` ] ; then
  echo "You seem to be trying to build arch $ARCH , on a `uname -i` system"
  echo "exiting"
  exit 1
fi
if [ ! -x /usr/bin/genbasedir ] ; then
  echo "You need to install the apt package before you run this script"
  echo "Try \"yum install apt\" "
else
  echo "Do you want to build new install images? y or n"
  read answer
  echo "Do you want to build cd iso images? y or n"
  read cdiso
  if [ $answer = "y" ] ; then
	echo "You indicated you wanted to make new install images, making them now."
	echo "Your new install images will be in ../../../images/$DEFAULT"
        echo "Creating hdlist now "
        ./build.hdlist.sh
	./build.release.sh
	./make.updates.img.sh
        if [ $? -eq 1 ] ; then
           echo "make.updates.img.sh failed"
           exit 2
        fi
	./make.products.img.sh
  fi
  # These should be done just before rsyncing up
  echo "---------------------------------------------------------------"
  echo "Creating hdlist now"
  echo "---------------------------------------------------------------"
  ./build.hdlist.sh
  echo "---------------------------------------------------------------"
  echo "Creating rpmdb rpm now"
  echo "---------------------------------------------------------------"
  ./make.rpmdb-sl.sh
  echo "---------------------------------------------------------------"
  echo "Creating comps.rpm now"
  echo "---------------------------------------------------------------"
  cd ../../base/
  ./scripts/make.comps.rpm.sh
  cd -
  echo "---------------------------------------------------------------"
  echo "NEED TO SIGN RPMS NOW"
  echo "---------------------------------------------------------------"
  echo "You need to sign the rpmdb and comps rpms,  I will wait here until you get back"
  echo "rpm is at $RELEASEDIR/$ARCH/SL/RPMS/rpmdb-SL*rpm"
  echo "rpm is at $RELEASEDIR/$ARCH/SL/RPMS/comps-4*rpm"
  read me
  echo "---------------------------------------------------------------"
  echo "Creating the apt area now"
  echo "---------------------------------------------------------------"
  ./makeapt.sl.sh
  echo "---------------------------------------------------------------"
  echo "Creating the yum headers now"
  echo "---------------------------------------------------------------"
  ./makeyum.sl.sh
  cd $RELEASEDIR/$ARCH/SL/RPMS
  repoview -f -t "Scientific Linux Base $VERSION $ARCH" .
  cd $RELEASEDIR/$ARCH/errata/SL/RPMS
  repoview -f -t "Scientific Linux Errata $VERSION $ARCH" .
  cd $RELEASEDIR/$ARCH/SL/build/scripts
fi
if [ "$cdiso" = "y" ] ; then
	echo "making the cd isos"
	cd buildisoimages
	sh make.cdisos.sh
else
	echo "skipping the making of the cd isos"
fi
