#!/bin/bash
#
# This script can be copied 'as is' to any place and then
# the build commands from cmake_tdaq can be executed like this:
#
# curl -o bootstrap https://gitlab.cern.ch/atlas-tdaq-software/cmake_tdaq/raw/master/bin/bootstrap
#   or
# wget https://gitlab.cern.ch/atlas-tdaq-software/cmake_tdaq/raw/master/bin/bootstrap
# chmod a+x ./bootstrap
#
# [optional]
# export CHECKOUT_AREA=`pwd`/source
# export BUILD_AREA=`pwd`/build
#
# ./bootstrap build_stack --rpm tdaq-common-99-00-00 tdaq-99-00-00 x86_64-centos7-gcc7-opt
#

# Create scratch dir for bootstrapping cmake_tdaq
d=$(mktemp -d)
cleanup()
{
    rm -rf ${d}
}
trap cleanup EXIT

# Git repository is public
cd ${d} || exit 1
git clone https://:@gitlab.cern.ch:8443/atlas-tdaq-software/cmake_tdaq.git

export PATH=${d}/cmake_tdaq/bin:${PATH}
exec $@
