#!/bin/sh

version=$(grep -i 'ebe - version' html/about.html | cut -d ' ' -f 5)
file=~/sf/qtebe/Linux/fedora.ebe.${version}.sh

if [ -e $file ]
then
    echo "Version $version has already been used.  Bump it?"
    exit 1
fi

name=$(uname)

cat > $file << EOF1
#!/bin/sh

if [ \$UID != 0 ]
then
    echo 'This script must be run as root'
    exit 1
fi

dir=\$(pwd)

cd /usr/bin

echo "---------"
echo " "
echo Installing required tools and libraries
echo " "
echo "---------"

yum install gdb g++ astyle gcc-gfortran yasm qt5-qtbase qt5-qtwebkit

echo "---------"
echo " "
echo "Copying ebe and its language files (*.qm) to /usr/bin"
echo " "
echo "---------"

sed -n '/^PAYLOAD:/,$ {
           /^PAYLOAD:/ n
           p
        } ' < \$dir/\$0 | tar xvzf -

chmod a+rx ebe
chmod a+r *.qm

exit 0
PAYLOAD:
EOF1

tar cvzf - ebe *.qm >> $file
