# Scilab provides binary builds that are very compatible,
# so we use those binaries and encapsulate them in an AppImage

wget -q https://github.com/probonopd/AppImages/raw/master/functions.sh -O ./functions.sh
. ./functions.sh

APP=Scilab
mkdir -p $APP/$APP.AppDir/usr
cd $APP/

URL=$(wget -q "http://www.scilab.org/download/latest" -O - | grep -e  "http://www.scilab.org/download/.*linux-x86_64.tar.gz" | cut -d '"' -f 2)
VERSION=$(echo $URL | cut -d "-" -f 2 | sed -e 's|.bin.linux||g')

wget -c "$URL"
tar xf scilab-*.tar.gz

cd $APP.AppDir

mv ../scilab-*/* usr/

# Copy in the indirect dependencies
copy_deps

cp ./usr/share/applications/scilab.desktop .
cp ./usr/share/icons/hicolor/256x256/apps/scilab.png .

get_apprun

delete_blacklisted

echo $VERSION

get_desktopintegration scilab

# Go out of AppImage
cd ..

generate_appimage
