#!/bin/sh

# Script for installation of PRISM-games on a clean install of Ubuntu

set -e # Abort if one of the commands fails
set -x # Print commands as they are executed

# Avoid interruptions during install
if [ -e "/etc/needrestart/needrestart.conf" ]; then
  sudo sed -i "/#\$nrconf{restart} = 'i';/s/.*/\$nrconf{restart} = 'a';/" /etc/needrestart/needrestart.conf
fi

# Install dependencies: make/gcc/Java/git
sudo apt-get -y update
sudo apt -y install make gcc g++ default-jdk git

# Install Python (only needed for testing (prism-auto) currently)
sudo apt -y install python3

# Download the latest development version from GitHub
git clone https://github.com/prismmodelchecker/prism-games.git

# Compile PRISM-games and run a few tests (unless --nobuild passed)
# (should ultimately display: "Testing result: PASS")
if [ "$*" = "${*/--nobuild}" ]; then
  (cd prism-games/prism && make && make test testyices testz3 testppl)
fi
