#!/bin/bash
#
# small but nasty script to build a new YAP release from the current
# directory: it first builds a new tar file, next creates
# rpms, and last creates a new web page directory.
#

YAP_DIR=`pwd`
PAGE_DIR=~vitor/lpublic_html/Yap/Yap4.3
OWNER=vitor
parent=$(cd ..;pwd)
version=${PWD##$parent/}

splat() {
  rm -f core
  for i in *.tex; do
    rm -f ${i%.tex}.aux
    rm -f ${i%.tex}.log
    rm -f ${i%.tex}.dvi
    rm -f ${i%.tex}.bbl
    rm -f ${i%.tex}.blg 
# get rid of outputs from original file.
    rm -f ${i%.tex}.ps
  done
  rm -f *~
  rm -f *.BAK
  rm -f \#*\#
}

. distribute --small
cp $YAP_DIR/../"$version".tar.gz $PAGE_DIR/"$version"-small.tar.gz
cd /usr/src/RPM/SPECS
cp $YAP_DIR/misc/Yap.spec .
mv $YAP_DIR/../"$version".tar.gz ../SOURCES
rpm -ba Yap.spec
cd /usr/src/RPM
mv SRPMS/Yap* $PAGE_DIR
mv RPMS/*/Yap* $PAGE_DIR
rm -rf BUILD/Yap*
rm -rf SOURCES/Yap*
rm -rf SPECS/Yap*
cd $YAP_DIR
# get rid of silly $1
shift
. distribute
mv -f $YAP_DIR/../"$version".tar.gz $PAGE_DIR
cp -f $YAP_DIR/changes4.3.html $PAGE_DIR
cd $YAP_DIR/docs
make html
cd $YAP_DIR
cp -f $YAP_DIR/docs/*.html $PAGE_DIR
chown $OWNER $PAGE_DIR/*
chmod 666 $PAGE_DIR/*

