#!/usr/bin/env bash
set -e
ROOT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "Running qgis-deps installer"
echo "----------------------"
if [ -f $ROOT_PATH/qt-5.14.2.tar.gz ] && [ ! -d ${QGIS_DEPS_PREFIX}/opt/Qt//5.14.2/clang_64 ]; then
  echo "Installing QT 5.14.2 to ${QGIS_DEPS_PREFIX}/opt/Qt//5.14.2/clang_64"
  mkdir -p ${QGIS_DEPS_PREFIX}/opt/Qt//5.14.2/clang_64
  cd ${QGIS_DEPS_PREFIX}/opt/Qt//5.14.2/clang_64
  tar -xvzf $ROOT_PATH/qt-5.14.2.tar.gz
else 
  echo "Skipped installation of QT 5.14.2 to ${QGIS_DEPS_PREFIX}/opt/Qt//5.14.2/clang_64"
fi
echo "----------------------"
if [ -f $ROOT_PATH/qgis-deps-0.5.5.tar.gz ] && [ ! -d ${QGIS_DEPS_PREFIX}/opt/QGIS/qgis-deps-0.5.5/stage/ ]; then
  echo "Installing QGIS_deps 0.5.5 to ${QGIS_DEPS_PREFIX}/opt/QGIS/qgis-deps-0.5.5/stage/"
  mkdir -p ${QGIS_DEPS_PREFIX}/opt/QGIS/qgis-deps-0.5.5/stage/
  cd ${QGIS_DEPS_PREFIX}/opt/QGIS/qgis-deps-0.5.5/stage/
  tar -xvzf $ROOT_PATH/qgis-deps-0.5.5.tar.gz
else 
  echo "Skipped installation of QGIS_deps 0.5.5 to ${QGIS_DEPS_PREFIX}/opt/QGIS/qgis-deps-0.5.5/stage/"
fi
echo "----------------------"
echo "QT installed ${QGIS_DEPS_PREFIX}/opt/Qt//5.14.2/clang_64"
echo "QGIS deps installed ${QGIS_DEPS_PREFIX}/opt/QGIS/qgis-deps-0.5.5/stage/"
