#!/usr/bin/env bash

# Copyright (c) 2018, University of Kaiserslautern
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions of source code must retain the above copyright notice,
#    this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
#    contributors may be used to endorse or promote products derived from
#    this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Author: Éder F. Zulian

distro=$(cat /etc/os-release | grep "^ID=" | sed 's/.*=//' | awk '{print tolower($0)}')
# Check distro. This script supports Debian/Ubuntu
if [ "$distro" != "debian" ] && [ "$distro" != "ubuntu" ]; then
	echo -e "Error unsupported distribution (${distro}). This script supports Debian/Ubuntu." 1>&2
	exit 1
fi
# Ensure the newest versions of all packages currently installed
sudo apt-get update
sudo apt-get upgrade
# Required dependencies and useful tools
deplist="
g++
libc6
libstdc++6
gitk
locate
synaptic
subversion
astyle
uncrustify
clang-format
python3
python3-dev
python3-matplotlib
sqlite3
sqlitebrowser
libsqlite3-dev
qt4-qmake
qt5-default
qttools5-dev
qtcreator
libqt4-dev
libqt4-svg
libqt5gui5
libqt5svg5
libqt5svg5-dev
libqt5sql5
libqt5widgets5
libqt5core5a
lsb-core
libqwt-qt5-dev
cmake
gedit
sublime-text
vim-gtk
kate
wget
gtkwave
openssh-server
nautilus
telnet
dpkg-dev
pkg-config
"
for d in $deplist; do
	sudo apt-get -y install $d
done
echo -e "Done."
