#!/bin/bash

#set -e
set -vx

BASE_PATH=`pwd`

git checkout devel
git submodule update --init --recursive --remote

if [ ! -d ./titan-test-system-framework ]
then
    git clone --recurse-submodules --branch devel https://labs.etsi.org/rep/cti-tools/titan-test-system-framework.git
    cd ./titan-test-system-framework
else
    cd ./titan-test-system-framework
    git checkout devel
fi
# TODO later
#cd ./ttcn/LibHttp
#ln -sf module_5GNGAP.mk module.mk

cd $BASE_PATH
ln -f ./ttcn/patch_lib_common_titan/module.mk ./ttcn/LibCommon/
# TODO Add other patch

cd ./ttcn/modules/titan.TestPorts.Common_Components.Abstract_Socket/module/src
git apply ../../../../patch_abstract_socket/Abstract_Socket.hh.patch
git apply ../../../../patch_abstract_socket/Abstract_Socket.cc.patch
cd $BASE_PATH

exit 0
