compilAndInstall.sh 4.05 KB
#!/bin/bash

createDir() {
	WHAT=$1
	if [ ! -d ${WHAT} ]; then
		echo "Create ${WHAT}"
		mkdir -p ${WHAT}
		chmod -Rf 775 ${WHAT}
	fi
}

# to change before installation
export TREPS_INSTALL_DIR="/home/mbouchemit/TREPS" # treps install dir

export TREPS_BUILD_DEBUG=0 # 1 to compile the treps kernel in Debug mode
export TREPS_VALIDATION=0  # 1 to install validation platform (Fitnesse & Sonar)

# treps package structure
export TREPS_PACKAGE_DIR="`pwd`"
export TREPS_IHM_PACKAGE_DIR=${TREPS_PACKAGE_DIR}/ihm
export TREPS_SERVER_PACKAGE_DIR=${TREPS_PACKAGE_DIR}/server
export TREPS_PHP_PACKAGE_DIR=${TREPS_SERVER_PACKAGE_DIR}/php
export TREPS_KERNEL_PACKAGE_DIR=${TREPS_SERVER_PACKAGE_DIR}/kernel
export TREPS_COTS_PACKAGE_DIR=${TREPS_PACKAGE_DIR}/COTS

export TREPS_EXTJS_PACKAGE_NAME="ext-4.2.1-gpl.tar.gz"
export TREPS_SAMPJS_PACKAGE_NAME="sampjs.tar.gz"

# treps installation dir structure
export TREPS_WWW_INSTALL_DIR=${TREPS_INSTALL_DIR}/www
export TREPS_WWW_LIB_INSTALL_DIR=${TREPS_WWW_INSTALL_DIR}/lib
export TREPS_WWW_PHP_INSTALL_DIR=${TREPS_WWW_INSTALL_DIR}/php
export TREPS_BIN_INSTALL_DIR=${TREPS_INSTALL_DIR}/bin
export TREPS_KERNEL_INSTALL_DIR=${TREPS_BIN_INSTALL_DIR}/kernel
export TREPS_COTS_INSTALL_DIR=${TREPS_BIN_INSTALL_DIR}/COTS
if [ ${TREPS_VALIDATION} -ne 0 ]; then
  export TREPS_TEST_INSTALL_DIR=${TREPS_INSTALL_DIR}/test
  export TREPS_FITNESSE_INSTALL_DIR=${TREPS_TEST_INSTALL_DIR}/Fitnesse
  export TREPS_SONAR_INSTALL_DIR=${TREPS_TEST_INSTALL_DIR}/Sonar
fi

# create install dirs
createDir ${TREPS_INSTALL_DIR}
createDir ${TREPS_WWW_INSTALL_DIR}
createDir ${TREPS_WWW_LIB_INSTALL_DIR}
createDir ${TREPS_WWW_PHP_INSTALL_DIR}
createDir ${TREPS_BIN_INSTALL_DIR}
createDir ${TREPS_KERNEL_INSTALL_DIR}
createDir ${TREPS_COTS_INSTALL_DIR}
if [ ${TREPS_VALIDATION} -ne 0 ]; then
  createDir ${TREPS_TEST_INSTALL_DIR}
  createDir ${TREPS_FITNESSE_INSTALL_DIR}
  createDir ${TREPS_SONAR_INSTALL_DIR}
fi

# install ihm
cp -Rf ${TREPS_IHM_PACKAGE_DIR}/* ${TREPS_WWW_INSTALL_DIR}

cp ${TREPS_COTS_PACKAGE_DIR}/${TREPS_EXTJS_PACKAGE_NAME} ${TREPS_WWW_LIB_INSTALL_DIR}
cp ${TREPS_COTS_PACKAGE_DIR}/${TREPS_SAMPJS_PACKAGE_NAME} ${TREPS_WWW_LIB_INSTALL_DIR}

cd ${TREPS_WWW_LIB_INSTALL_DIR}
tar xzf ${TREPS_EXTJS_PACKAGE_NAME}
tar xzf ${TREPS_SAMPJS_PACKAGE_NAME}
rm ${TREPS_EXTJS_PACKAGE_NAME} ${TREPS_SAMPJS_PACKAGE_NAME}

# install server php
cp -Rf ${TREPS_PHP_PACKAGE_DIR}/* ${TREPS_WWW_PHP_INSTALL_DIR}

chmod 775 ${TREPS_WWW_PHP_INSTALL_DIR}/data

# compil and install kernel COTS
cd ${TREPS_COTS_PACKAGE_DIR}
chmod 775 build_cots.sh
./build_cots.sh ${TREPS_VALIDATION}

if [ $? -eq 0 ]; then
  echo "COTS compilation OK"
else
  echo "COTS compilation ERROR - $?"
  exit 1
fi

# compil and install kernel
cd ${TREPS_KERNEL_PACKAGE_DIR}

chmod 775 scripts/generate3DViewSOAPClient.sh

TREPS_CMAKE_GENERATOR="Unix Makefiles"
if [ ${TREPS_BUILD_DEBUG} -eq 0 ]; then
  echo "TREPS kernel compilation in Release mode"
  TREPS_CMAKE_BUILD_TYPE=Release
else
  echo "TREPS kernel compilation in Debug mode"
  TREPS_CMAKE_BUILD_TYPE=Debug
fi

cmake -G"${TREPS_CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=${TREPS_CMAKE_BUILD_TYPE}

if [ ${?} -eq 0 ]; then
  echo "cmake TREPS kernel OK"
else
  echo "cmake TREPS kernel ERROR"
  exit 1
fi

make

if [ ${?} -ne 0 ]; then
  echo "Error during the compilation of TREPS Kernel."
  exit 1
fi

make install CMAKE_INSTALL_ALWAYS=1

if [ ${?} -ne 0 ]; then
  echo "Error during the installation of TREPS Kernel."
  exit 1
fi

chmod 775 ${TREPS_KERNEL_INSTALL_DIR}

if [ ${TREPS_VALIDATION} -eq 0 ]; then
  echo "Compilation & Installation without validation OK"
  exit 0
fi

# compil and install CSlimServer
cd ${TREPS_KERNEL_PACKAGE_DIR}/test/Fitnesse/CSlimServer
cmake -G"${TREPS_CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=${TREPS_CMAKE_BUILD_TYPE}

if [ ${?} -eq 0 ]; then
  echo "cmake TREPS CSlimServer OK"
else
  echo "cmake TREPS CSlimServer ERROR"
  exit 1
fi

make

if [ ${?} -ne 0 ]; then
  echo "Error during the compilation of TREPS CSlimServer."
  exit 1
fi

make install CMAKE_INSTALL_ALWAYS=1

if [ ${?} -ne 0 ]; then
  echo "Error during the installation of TREPS CSlimServer."
  exit 1
fi

exit 0