cedaprereq


#!/bin/bash

# Script arguments:
# $1: 'noprompt' if no prompts should be issued by apt-get

if [ "$1" = 'noprompt' ]; then
    # -y allows for unattended install (yes is used for all prompts by apt-get)
    APT_UNATTENDED=-y
else
    APT_UNATTENDED=
fi

echo "========================================================================="
echo "Setting up prerequisites for building ceda..."

sudo apt-get $APT_UNATTENDED update
sudo apt-get $APT_UNATTENDED --with-new-pkgs upgrade

sudo apt-get $APT_UNATTENDED install make

echo "==================== gcc g++ ====================================================================="
currentver="$(gcc -dumpversion)"
requiredver="4.8.0"
if [ "$(printf "$requiredver\n$currentver" | sort -V | head -n1)" == "$currentver" ] && [ "$currentver" != "$requiredver" ]; then
    echo "Upgrading gcc/g++ from ${currentver} to ${requiredver}..."
    sudo apt-get $APT_UNATTENDED install g++
    sudo add-apt-repository $APT_UNATTENDED ppa:ubuntu-toolchain-r/test
    sudo apt-get $APT_UNATTENDED update
    sudo apt-get $APT_UNATTENDED install gcc-${GCCVER} g++-${GCCVER}

    sudo update-alternatives --remove-all gcc
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCCVER} 100 --slave /usr/bin/g++ g++ /usr/bin/g++-${GCCVER}
    sudo update-alternatives --set gcc /usr/bin/gcc-${GCCVER}
else
    echo "gcc at version ${currentver}"
fi

echo "==================== ncurses ====================================================================="
if [ -f /usr/include/curses.h ]; then
    echo libncurses5-dev already installed
else
    echo Installing libncurses5-dev
    sudo apt-get $APT_UNATTENDED install libncurses5-dev
fi

echo "==================== Python ======================================================================"
if [ -f /usr/include/python2.7/Python.h ]; then
    echo Python2.7 already installed
else
    echo Installing python
    #sudo apt-get $APT_UNATTENDED install python-dev
    sudo apt-get $APT_UNATTENDED install libpython2.7-dev
fi

echo "==================== OpenSSL ===================================================================="
if [ -d /usr/include/openssl ]; then
    echo OpenSSL already installed
else
    echo Installing OpenSSL
    sudo apt-get $APT_UNATTENDED install libssl1.0.0
    sudo apt-get $APT_UNATTENDED install libssl-dev
fi

echo "==================== libFFI ===================================================================="
if dpkg -l libffi-dev; then
    echo libFFI already installed
else
    echo Installing libFFI
    sudo apt-get $APT_UNATTENDED install libffi-dev
fi

echo "==================== Subversion ================================================================="
#sudo apt-get $APT_UNATTENDED install svn
sudo apt-get $APT_UNATTENDED install subversion

echo "=================================================================================================="
echo "Setup of prerequisites for building ceda completed"
echo "=================================================================================================="