#!/bin/bash COTS_DIR="`pwd`" buildCOTS() { COTS_WHAT=$1 COTS_CONFIGURE_OPTIONS=$2 COTS_MAKE_OPTIONS=$3 cd $COTS_DIR # extraction if [ ! -d ${COTS_WHAT} ]; then tar xfz "${COTS_WHAT}.tar.gz" if [ ${?} -ne 0 ]; then echo "Cannot extract COTS ${COTS_WHAT}" return 1 fi fi cd ${COTS_WHAT} # remove cache if [ -f config.cache ]; then rm config.cache fi # configuration ./configure ${COTS_CONFIGURE_OPTIONS} 2>&1 if [ ${?} -ne 0 ]; then echo "Error during the configuration of ${COTS_WHAT}." return 1 fi # clean old compilation make clean 2>&1 >/dev/null # compilation make ${COTS_MAKE_OPTIONS} 2>&1 if [ ${?} -ne 0 ]; then echo "Error during the compilation of ${COTS_WHAT}." return 1 fi # installation make install 2>&1 if [ ${?} -ne 0 ]; then echo "Error during the installation of ${COTS_WHAT}." return 1 fi return 0 } if [ -z "${TREPS_COTS_INSTALL_DIR}" ]; then echo "Environment variable TREPS_COTS_INSTALL_DIR not defined" exit 1 fi #Build COTS in relation to the validation process? if [ -z "${1}" ]; then TREPS_VALIDATION=0 else TREPS_VALIDATION=${1} fi; #generic options for COTS compilation MAKE_OPTIONS="" #Installation of 'Apache Portable Runtime' library - Dependency of log4cxx APR_NAME="apr-1.5.0" APR_DIR=${TREPS_COTS_INSTALL_DIR}/apr APR_CONF_OPT="--prefix=${APR_DIR}" buildCOTS ${APR_NAME} "${APR_CONF_OPT}" "${MAKE_OPTIONS}" [ ${?} -ne 0 ] && echo "Error detected." && exit 1 #Installation of 'Apache Portable Runtime Utility' library - Dependency of log4cxx APR_UTIL_NAME="apr-util-1.5.3" APR_UTIL_DIR=${TREPS_COTS_INSTALL_DIR}/apr-util APR_UTIL_CONF_OPT="--prefix=${APR_UTIL_DIR} --with-apr=${APR_DIR}" buildCOTS ${APR_UTIL_NAME} "${APR_UTIL_CONF_OPT}" "${MAKE_OPTIONS}" [ ${?} -ne 0 ] && echo "Error detected." && exit 1 #Installation of 'log4cxx' library - C++ logger used by TREPS LOG4CXX_NAME="apache-log4cxx-0.10.0" LOG4CXX_DIR=${TREPS_COTS_INSTALL_DIR}/log4cxx LOG4CXX_CONF_OPT="--prefix=${LOG4CXX_DIR} --with-apr=${APR_DIR} --with-apr-util=${APR_UTIL_DIR}" buildCOTS ${LOG4CXX_NAME} "${LOG4CXX_CONF_OPT}" "${MAKE_OPTIONS}" [ ${?} -ne 0 ] && echo "Error detected." && exit 1 #Installation of 'CPPUnit' library - C++ unit testing framework used by TREPS CPPUNIT_NAME="cppunit-1.12.1" CPPUNIT_DIR=${TREPS_COTS_INSTALL_DIR}/cppunit CPPUNIT_CONF_OPT="--prefix=${CPPUNIT_DIR}" buildCOTS ${CPPUNIT_NAME} "${CPPUNIT_CONF_OPT}" "${MAKE_OPTIONS}" [ ${?} -ne 0 ] && echo "Error detected." && exit 1 #Installation of 'file' library - Only used to get MIME type of a file by TREPS FILE_NAME="file-5.15" FILE_DIR=${TREPS_COTS_INSTALL_DIR}/file FILE_CONF_OPT="--prefix=${FILE_DIR}" buildCOTS ${FILE_NAME} "${FILE_CONF_OPT}" "${MAKE_OPTIONS}" [ ${?} -ne 0 ] && echo "Error detected." && exit 1 #Installation of 'gsoap' library - Used by TREPS to build a client to the 3DView Web Service GSOAP_NAME="gsoap-2.8.17" GSOAP_DIR=${TREPS_COTS_INSTALL_DIR}/gsoap GSOAP_CONF_OPT="--prefix=${GSOAP_DIR} --disable-ssl" buildCOTS ${GSOAP_NAME} "${GSOAP_CONF_OPT}" "${MAKE_OPTIONS}" [ ${?} -ne 0 ] && echo "Error detected." && exit 1 #Installation of 'netcdf library' - To allow TREPS to read and write netCDF files NETCDF_NAME="netcdf-4.3.0" NETCDF_DIR=${TREPS_COTS_INSTALL_DIR}/netcdf NETCDF_CONF_OPT="--prefix=${NETCDF_DIR} --disable-netcdf-4 --disable-dap" buildCOTS ${NETCDF_NAME} "${NETCDF_CONF_OPT}" "${MAKE_OPTIONS}" [ ${?} -ne 0 ] && echo "Error detected." && exit 1 #Installation of 'cdf library' - To allow TREPS to read and write CDF files CDF_NAME="cdf35_0-dist" CDF_DIR=${TREPS_COTS_INSTALL_DIR}/cdf cd $COTS_DIR if [ ! -d ${CDF_NAME} ]; then tar xfz "${CDF_NAME}-cdf.tar.gz" if [ ${?} -ne 0 ]; then echo "Cannot extract cdf archive" exit 1 fi fi cd ${CDF_NAME} make "OS=linux" "ENV=gnu" "CURSES=no" all [ ${?} -ne 0 ] && echo "Error detected." && exit 1 make "INSTALLDIR=${CDF_DIR}" install [ ${?} -ne 0 ] && echo "Error detected." && exit 1 if [ ${TREPS_VALIDATION} -eq 0 ]; then echo 'Do not install COTS in relation to validation process' exit 0 fi #================================================================= # COTS below this line is used for the validation process #================================================================= #Installation of 'Fitnesse', used for acceptance tests FITNESSE_DIR=${TREPS_COTS_INSTALL_DIR}/fitnesse FITNESSE_PORT=8081 if [ ! -d ${FITNESSE_DIR} ]; then mkdir -p ${FITNESSE_DIR} fi cp ${COTS_DIR}/fitnesse.jar ${FITNESSE_DIR} #Installation of 'CPPUTest' library - Dependency for CSlim CPPUTEST_NAME="cpputest-3.5" CPPUTEST_DIR=${FITNESSE_DIR}/cpputest CPPUTEST_CONF_OPT="--prefix=${CPPUTEST_DIR}" buildCOTS ${CPPUTEST_NAME} "${CPPUTEST_CONF_OPT}" "${MAKE_OPTIONS}" [ ${?} -ne 0 ] && echo "Error detected." && exit 1 export CPPUTEST_HOME=${COTS_DIR}/${CPPUTEST_NAME} #Installation of 'CSlim' library - Use by TREPS CSlimServer for validation test CSLIM_NAME="cslim" CSLIM_DIR=${FITNESSE_DIR}/cslim cd $COTS_DIR if [ ! -d ${CSLIM_NAME} ]; then tar xfz "${CSLIM_NAME}.tar.gz" if [ ${?} -ne 0 ]; then echo "Cannot extract CSLIM" exit 1 fi fi cd ${CSLIM_NAME} export CPPUTEST_HOME=${COTS_DIR}/${CPPUTEST_NAME} make if [ ! -d ${CSLIM_DIR}/include ]; then mkdir -p ${CSLIM_DIR}/include fi if [ ! -d ${CSLIM_DIR}/lib ]; then mkdir -p ${CSLIM_DIR}/lib fi cp -r include/Com/ ${CSLIM_DIR}/include/ cp -r include/CSlim/ ${CSLIM_DIR}/include/ cp -r lib/* ${CSLIM_DIR}/lib/ #Installation of Valgrind tool - Use to detect buffer overflow & memory leaks VALGRIND_NAME="valgrind-3.9.0" VALGRIND_DIR=${TREPS_COTS_INSTALL_DIR}/valgrind VALGRIND_CONF_OPT="--prefix=${VALGRIND_DIR}" buildCOTS ${VALGRIND_NAME} "${VALGRIND_CONF_OPT}" "${MAKE_OPTIONS}" [ ${?} -ne 0 ] && echo "Error detected." && exit 1 #Installation of cppcheck - Use for code analysis #Note - We just build cppcheck, without any dependencies CPPCHECK_NAME="cppcheck-1.63" CPPCHECK_DIR=${TREPS_COTS_INSTALL_DIR}/cppcheck cd ${COTS_DIR} tar xzf ${CPPCHECK_NAME}.tar.gz cd ${COTS_DIR}/${CPPCHECK_NAME} g++ -o cppcheck -Ilib -Iexternals/tinyxml cli/*.cpp lib/*.cpp externals/tinyxml/tinyxml2.cpp [ ${?} -ne 0 ] && echo "Error detected." && exit 1 if [ ! -d ${CPPCHECK_DIR} ]; then mkdir -p ${CPPCHECK_DIR} fi cp cppcheck ${CPPCHECK_DIR} cp -Rf cfg/ ${CPPCHECK_DIR} [ ${?} -ne 0 ] && echo "Error detected." && exit 1 #Installation of sonar - SONAR_NAME="sonarqube-4.0" SONAR_DIR=${TREPS_COTS_INSTALL_DIR}/sonar cd ${COTS_DIR} tar xzf ${SONAR_NAME}.tar.gz cp -r ${SONAR_NAME}/ ${SONAR_DIR}/ [ ${?} -ne 0 ] && echo "Error detected." && exit 1 #Installation of c++ pluggin for sonar SONAR_PLUGIN_DIR=${SONAR_DIR}/extensions/plugins SONAR_CPP_PLUGIN="sonar-cxx-plugin-0.9.jar" cd ${COTS_DIR} cp ${SONAR_CPP_PLUGIN} ${SONAR_PLUGIN_DIR} [ ${?} -ne 0 ] && echo "Error detected." && exit 1 chmod -Rf 775 ${SONAR_DIR} #Installion of sonar-runner SONARRUNNER_NAME="sonar-runner-2.3" SONARRUNNER_DIR=${TREPS_COTS_INSTALL_DIR}/sonar-runner cd ${COTS_DIR} tar xzf ${SONARRUNNER_NAME}.tar.gz cp -r ${SONARRUNNER_NAME}/ ${SONARRUNNER_DIR}/ [ ${?} -ne 0 ] && echo "Error detected." && exit 1 chmod -Rf 775 ${SONARRUNNER_DIR} exit 0