From 75677401e350140a3b6c8a882c070f603509e073 Mon Sep 17 00:00:00 2001 From: Lionel Gauthier Date: Tue, 9 Dec 2014 18:24:08 +0000 Subject: [PATCH] git-svn-id: http://svn.eurecom.fr/openair4G/trunk@6219 818b1a75-f10b-46b9-bf7c-635c3b92a50f --- targets/build_helper.bash | 203 ++++++++++++++++++++------------------ targets/build_oai.bash | 128 ++++++++++++------------ 2 files changed, 168 insertions(+), 163 deletions(-) diff --git a/targets/build_helper.bash b/targets/build_helper.bash index dd8ec70442..b0b0f08740 100755 --- a/targets/build_helper.bash +++ b/targets/build_helper.bash @@ -57,11 +57,11 @@ check_for_root_rights() { # if [[ $EUID -ne $ROOT_EUID ]]; then if [ $USER != "root" ]; then SUDO="sudo -E " - echo "Run as a sudoers" - return 1 + echo "Run as a sudoers" + return 1 else - echo "Run as a root" - return 0 + echo "Run as a root" + return 0 fi } @@ -73,7 +73,7 @@ test_install_package() { echo "$1 is installed." } || { echo "$1 is not installed." - OAI_INSTALLED=0 + OAI_INSTALLED=0 $SUDO apt-get install -y $@ } fi @@ -83,8 +83,8 @@ test_uninstall_package() { if [ $# -eq 1 ]; then dpkg -s "$1" > /dev/null 2>&1 && { - $SUDO apt-get remove --assume-yes $1 - echo "$1 is uninstalled." + $SUDO apt-get remove --assume-yes $1 + echo "$1 is uninstalled." } || { echo "$1 is not installed." } @@ -100,13 +100,13 @@ test_command_install_script() { check_for_machine_type(){ MACHINE_TYPE=`uname -m` if [ ${MACHINE_TYPE} = "x86_64" ]; then - return 64 # 64-bit stuff here + return 64 # 64-bit stuff here else - if [ ${MACHINE_TYPE} = "i686" ]; then + if [ ${MACHINE_TYPE} = "i686" ]; then return 32 # 32-bit stuff here - else - return -1 - fi + else + return -1 + fi fi } @@ -143,8 +143,8 @@ make_certs(){ openssl ca -cert cacert.pem -keyfile cakey.pem -in hss.csr.pem -out hss.cert.pem -outdir . -batch if [ ! -d /usr/local/etc/freeDiameter ]; then - echo "Creating non existing directory: /usr/local/etc/freeDiameter/" - $SUDO mkdir /usr/local/etc/freeDiameter/ + echo "Creating non existing directory: /usr/local/etc/freeDiameter/" + $SUDO mkdir /usr/local/etc/freeDiameter/ fi echo "Copying *.pem to /usr/local/etc/freeDiameter/" @@ -322,16 +322,16 @@ check_s6a_certificate() { cd $OPENAIRCN_DIR/S6A/freediameter make_certs if [ $cnt = 0 ] ; then - cnt=1 - check_s6a_certificate + cnt=1 + check_s6a_certificate fi return 1 } check_install_usrp_uhd_driver(){ if [ ! -f /etc/apt/sources.list.d/ettus.list ] ; then - $SUDO bash -c 'echo "deb http://files.ettus.com/binaries/uhd/repo/uhd/ubuntu/`lsb_release -cs` `lsb_release -cs` main" >> /etc/apt/sources.list.d/ettus.list' - $SUDO apt-get update + $SUDO bash -c 'echo "deb http://files.ettus.com/binaries/uhd/repo/uhd/ubuntu/`lsb_release -cs` `lsb_release -cs` main" >> /etc/apt/sources.list.d/ettus.list' + $SUDO apt-get update fi $SUDO apt-get install -t $UBUNTU_REL_NAME uhd test_install_package python @@ -343,91 +343,91 @@ check_install_usrp_uhd_driver(){ check_install_oai_software() { if [ ! -f ./.lock_oaibuild ]; then - $SUDO apt-get update - if [ $UBUNTU_REL = "12.04" ]; then - test_uninstall_package nettle-dev - test_uninstall_package nettle-bin + $SUDO apt-get update + if [ $UBUNTU_REL = "12.04" ]; then + test_uninstall_package nettle-dev + test_uninstall_package nettle-bin else test_install_package nettle-dev test_install_package nettle-bin - fi - test_install_package autoconf - test_install_package automake - test_install_package bison - test_install_package build-essential - test_install_package flex - test_install_package gawk - test_install_package gcc - test_install_package gdb - test_install_package make - test_install_package cmake - test_install_package openssh-client - test_install_package openssh-server + fi + test_install_package autoconf + test_install_package automake + test_install_package bison + test_install_package build-essential + test_install_package flex + test_install_package gawk + test_install_package gcc + test_install_package gdb + test_install_package make + test_install_package cmake + test_install_package openssh-client + test_install_package openssh-server sudo service ssh start - test_install_package unzip - test_install_package autoconf - test_install_package automake - test_install_package bison - test_install_package build-essential - test_install_package check - test_install_package ethtool - test_install_package flex - test_install_package g++ - test_install_package gawk - test_install_package gcc - test_install_package gccxml - test_install_package gdb - test_install_package guile-2.0-dev - test_install_package iperf - test_install_package iproute - test_install_package iptables - test_install_package libatlas-base-dev - test_install_package libatlas-dev - test_install_package libblas3gf - test_install_package libblas-dev + test_install_package unzip + test_install_package autoconf + test_install_package automake + test_install_package bison + test_install_package build-essential + test_install_package check + test_install_package ethtool + test_install_package flex + test_install_package g++ + test_install_package gawk + test_install_package gcc + test_install_package gccxml + test_install_package gdb + test_install_package guile-2.0-dev + test_install_package iperf + test_install_package iproute + test_install_package iptables + test_install_package libatlas-base-dev + test_install_package libatlas-dev + test_install_package libblas3gf + test_install_package libblas-dev # if [ $MACHINE_ARCH = 64 ]; then test_install_package libconfig8-dev # else # test_install_package libconfig-dev # fi - test_install_package libforms-bin - test_install_package libforms-dev - test_install_package libgcrypt11-dev - test_install_package libgmp-dev - test_install_package libgtk-3-dev - test_install_package libidn11-dev - test_install_package libidn2-0-dev - test_install_package libpgm-dev - test_install_package libpgm-5.1-0 - test_install_package libpthread-stubs0-dev - test_install_package libsctp1 - test_install_package libsctp-dev - test_install_package libtasn1-3-dev - test_install_package libxml2 - test_install_package libxml2-dev -# test_install_package linux-headers-`uname -r` - test_install_package openssl - test_install_package libssl-dev - test_install_package pkg-config - test_install_package python-dev - test_install_package python-pexpect - test_install_package sshfs - test_install_package subversion - test_install_package valgrind - test_install_package doxygen - test_install_package graphviz + test_install_package libforms-bin + test_install_package libforms-dev + test_install_package libgcrypt11-dev + test_install_package libgmp-dev + test_install_package libgtk-3-dev + test_install_package libidn11-dev + test_install_package libidn2-0-dev + test_install_package libpgm-dev + test_install_package libpgm-5.1-0 + test_install_package libpthread-stubs0-dev + test_install_package libsctp1 + test_install_package libsctp-dev + test_install_package libtasn1-3-dev + test_install_package libxml2 + test_install_package libxml2-dev +# test_install_package linux-headers-`uname -r` + test_install_package openssl + test_install_package libssl-dev + test_install_package pkg-config + test_install_package python-dev + test_install_package python-pexpect + test_install_package sshfs + test_install_package subversion + test_install_package valgrind + test_install_package doxygen + test_install_package graphviz # TODO: install the USRP UHD packages -# if [ $1 = "USRP" ] ; then +# if [ $1 = "USRP" ] ; then -# test_install_package libboost-all-dev +# test_install_package libboost-all-dev - if [ $OAI_INSTALLED = 1 ]; then - touch ./.lock_oaibuild - fi + if [ $OAI_INSTALLED = 1 ]; then + touch ./.lock_oaibuild + fi else - echo_info "All the required packages installed: skip" + echo_info "All the required packages installed: skip" fi } @@ -700,18 +700,25 @@ compile_exmimo2_driver() { compile_ltesoftmodem() { cd $OPENAIR_TARGETS/RT/USER if [ -f Makefile ]; then - echo "Compiling directives: $SOFTMODEM_DIRECTIVES" - make cleanall > /dev/null 2>&1 - make $SOFTMODEM_DIRECTIVES - make -j $NUM_CPU $SOFTMODEM_DIRECTIVES + echo "LTE softmodem compiling directives: $SOFTMODEM_DIRECTIVES" + echo "OAI_CLEAN: $OAI_CLEAN" + if [ $OAI_CLEAN -ne 0 ]; then + echo "Cleaning LTE softmodem" + make cleanall > /dev/null 2>&1 + fi + make -j $NUM_CPU $SOFTMODEM_DIRECTIVES + if [ $? -ne 0 ]; then + # to locate easily compilation error in log file + make $SOFTMODEM_DIRECTIVES + fi if [ $? -ne 0 ]; then if [ ! -f ./lte-softmodem ]; then - echo_error "Build lte-softmodem failed, returning" - return 1 - else - cp -f ./lte-softmodem $OPENAIR_TARGETS/bin - return 0 - fi + echo_error "Build lte-softmodem failed, returning" + return 1 + else + cp -f ./lte-softmodem $OPENAIR_TARGETS/bin + return 0 + fi else cp -f ./lte-softmodem $OPENAIR_TARGETS/bin return 0 diff --git a/targets/build_oai.bash b/targets/build_oai.bash index eb8e7ab520..2ceb883350 100755 --- a/targets/build_oai.bash +++ b/targets/build_oai.bash @@ -59,6 +59,7 @@ declare CONFIG_FILE="" declare EXE_ARGUMENTS="" declare RUN_GDB=0 declare DISABLE_CHECK_INSTALLED_SOFTWARE=0 +declare OAI_CLEAN=0 declare OAI_TEST=0 declare XFORMS=0 @@ -91,8 +92,8 @@ fi # case $i in - -while true; do + until [ -z "$1" ] + do case "$1" in -a | --doxygen) DOXYGEN=1 @@ -128,7 +129,7 @@ while true; do shift; ;; -e | --realtime) - RT="$2" + RT=$2 echo "setting realtime flag to: $RT" shift 2 ; ;; @@ -146,7 +147,7 @@ while true; do shift 2; ;; -l | --build-target) - BUILD_LTE="$2" + BUILD_LTE=$2 echo "setting top-level build target to: $2" shift 2; ;; @@ -161,7 +162,7 @@ while true; do shift; ;; -r | --3gpp-release) - REL="$2" + REL=$2 echo "setting release to: $REL" shift 2 ; ;; @@ -171,8 +172,8 @@ while true; do shift; ;; -t | --enb-build-target) - TARGET="$2" - echo "setting target to: $TARGET" + TARGET=$2 + echo "setting enb build target to: $TARGET" shift 2; ;; -V | --vcd) @@ -205,9 +206,6 @@ while true; do OAI_TEST=0 shift ; ;; - ' ') - shift ; - ;; *) echo "Unknown option $1" break ; @@ -284,67 +282,67 @@ build_enb(){ SOFTMODEM_DIRECTIVES="DEBUG=$DEBUG XFORMS=$XFORMS " OAISIM_DIRECTIVES="DEBUG=$DEBUG XFORMS=$XFORMS " - if [ $ENB_S1 = 1 ]; then - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES USE_MME=R10 ENABLE_ITTI=1 LINK_PDCP_TO_GTPV1U=1 SECU=1 " - OAISIM_DIRECTIVES="$OAISIM_DIRECTIVES USE_MME=R10 ENABLE_ITTI=1 LINK_PDCP_TO_GTPV1U=1 SECU=1 " + if [ $ENB_S1 -eq 1 ]; then + SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES USE_MME=R10 ENABLE_ITTI=1 LINK_PDCP_TO_GTPV1U=1 SECU=1 " + OAISIM_DIRECTIVES="$OAISIM_DIRECTIVES USE_MME=R10 ENABLE_ITTI=1 LINK_PDCP_TO_GTPV1U=1 SECU=1 " fi - if [ $DEBUG = 0 ]; then - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES DISABLE_XER_PRINT=1 " - OAISIM_DIRECTIVES="$OAISIM_DIRECTIVES DISABLE_XER_PRINT=1 " + if [ $DEBUG -eq 0 ]; then + SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES DISABLE_XER_PRINT=1 " + OAISIM_DIRECTIVES="$OAISIM_DIRECTIVES DISABLE_XER_PRINT=1 " fi if [ $HW = "USRP" ]; then - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES USRP=1 " + SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES USRP=1 " fi if [ $HW = "EXMIMO" ]; then - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES EXMIMO=1 " + SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES EXMIMO=1 " fi if [ $HW = "ETHERNET" ]; then - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES ETHERNET=1 " + SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES ETHERNET=1 " fi if [ $ENB_S1 -eq 0 ]; then - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES NAS=1 " - OAISIM_DIRECTIVES="$OAISIM_DIRECTIVES NAS=1 " + SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES NAS=1 " + OAISIM_DIRECTIVES="$OAISIM_DIRECTIVES NAS=1 " fi if [ $REL = "REL8" ]; then - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES Rel8=1 " - OAISIM_DIRECTIVES="$OAISIM_DIRECTIVES Rel8=1 " + SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES Rel8=1 " + OAISIM_DIRECTIVES="$OAISIM_DIRECTIVES Rel8=1 " else - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES Rel10=1 " - OAISIM_DIRECTIVES="$OAISIM_DIRECTIVES Rel10=1 " + SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES Rel10=1 " + OAISIM_DIRECTIVES="$OAISIM_DIRECTIVES Rel10=1 " fi if [ $RT = "RTAI" ]; then - if [ ! -f /usr/realtime/modules/rtai_hal.ko ]; then - echo_warning "RTAI doesn't seem to be installed" - RT="NONE" - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES RTAI=0 " - else - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES HARD_RT=1 " - fi + if [ ! -f /usr/realtime/modules/rtai_hal.ko ]; then + echo_warning "RTAI doesn't seem to be installed" + RT="NONE" + SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES RTAI=0 " + else + SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES HARD_RT=1 " + fi else - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES RTAI=0 " - RT="NONE" + SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES RTAI=0 " + RT="NONE" fi if [ $TARGET != "ALL" ]; then - if [ $TARGET != "SOFTMODEM" ]; then - HW="NONE" - fi + if [ $TARGET != "SOFTMODEM" ]; then + HW="NONE" + fi fi if [ $UBUNTU_REL = "12.04" ]; then - output=$(check_for_machine_type 2>&1) - MACHINE_ARCH=$? - if [ $MACHINE_ARCH -eq 64 ]; then - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES LIBCONFIG_LONG=1 " - OAISIM_DIRECTIVES="$OASIM_DIRECTIVES LIBCONFIG_LONG=1 " - fi + output=$(check_for_machine_type 2>&1) + MACHINE_ARCH=$? + if [ $MACHINE_ARCH -eq 64 ]; then + SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES LIBCONFIG_LONG=1 " + OAISIM_DIRECTIVES="$OASIM_DIRECTIVES LIBCONFIG_LONG=1 " + fi fi echo_success "SOFTMODEM Compilation directives: $SOFTMODEM_DIRECTIVES" @@ -368,6 +366,7 @@ build_enb(){ check_install_nettle else echo_info "6. Not checking the required softwares/packages ..." + touch ./.lock_oaibuild fi ############################################ @@ -407,15 +406,14 @@ build_enb(){ else - - if [ $TARGET = "SOFTMODEM" ]; then + if [ $TARGET == "SOFTMODEM" ]; then echo "############# compile_ltesoftmodem #############" >> bin/install_log.txt output=$(compile_ltesoftmodem >> bin/install_log.txt 2>&1 ) softmodem_compiled=$? check_for_ltesoftmodem_executable echo_info "7.1 finished ltesoftmodem target: check the installation log file bin/install_log.txt" - if [ $HW = "EXMIMO" ]; then + if [ $HW == "EXMIMO" ]; then compile_exmimo2_driver fi fi @@ -449,17 +447,17 @@ build_enb(){ echo_info "8. Installing ..." - if [ $softmodem_compiled = 0 ]; then + if [ $softmodem_compiled -eq 0 ]; then echo_success "target lte-softmodem built and installed in the bin directory" echo "target lte-softmodem built and installed in the bin directory" >> bin/${oai_build_date} output=$(install_ltesoftmodem $RT $HW $ENB_S1 ) fi - if [ $oaisim_compiled = 0 ]; then + if [ $oaisim_compiled -eq 0 ]; then echo_success "target oaisim built and installed in the bin directory" echo "target oaisim built and installed in the bin directory" >> bin/${oai_build_date} output=$(install_oaisim $ENB_S1 ) fi - if [ $unisim_compiled = 0 ]; then + if [ $unisim_compiled -eq 0 ]; then echo_success "target unisim built and installed in the bin directory" echo "target unisim built and installed in the bin directory" >> bin/${oai_build_date} fi @@ -485,11 +483,11 @@ build_epc(){ check_install_asn1c - if [ $OAI_CLEAN = 1 ]; then - check_install_freediamter + if [ $OAI_CLEAN -eq 1 ]; then + check_install_freediamter else if [ ! -d /usr/local/etc/freeDiameter ]; then - check_install_freediamter + check_install_freediamter fi fi check_s6a_certificate @@ -512,7 +510,7 @@ build_epc(){ echo_info "6. install the binary file" - if [ $epc_compiled = 0 ]; then + if [ $epc_compiled -eq 0 ]; then echo_success "target epc built and installed in the bin directory" echo "target epc built and installed in the bin directory" >> bin/${oai_build_date} cp -f $OPENAIR_TARGETS/PROJECTS/GENERIC-LTE-EPC/CONF/epc.generic.conf $OPENAIR_TARGETS/bin @@ -542,12 +540,12 @@ build_hss(){ check_install_hss_software - if [ $OAI_CLEAN = 1 ]; then - check_install_freediamter + if [ $OAI_CLEAN -eq 1 ]; then + check_install_freediamter else - if [ ! -d /usr/local/etc/freeDiameter ]; then - check_install_freediamter - fi + if [ ! -d /usr/local/etc/freeDiameter ]; then + check_install_freediamter + fi fi $(make_certs >> bin/install_log.txt 2>&1) output=$(check_s6a_certificate >> bin/install_log.txt 2>&1) @@ -580,11 +578,11 @@ build_hss(){ ###################################### echo_info "7. install the binary file" - if [ $hss_compiled = 0 ]; then - echo_success "target hss built, DB created and installed in the bin directory" - echo "target hss built, DB created, and installed in the bin directory" >> bin/${oai_build_date} + if [ $hss_compiled -eq 0 ]; then + echo_success "target hss built, DB created and installed in the bin directory" + echo "target hss built, DB created, and installed in the bin directory" >> bin/${oai_build_date} cp -rf $OPENAIRCN_DIR/OPENAIRHSS/conf $OPENAIR_TARGETS/bin - $SUDO cp $OPENAIR_TARGETS/bin/conf/hss_fd.local.conf /etc/openair-hss + $SUDO cp $OPENAIR_TARGETS/bin/conf/hss_fd.local.conf /etc/openair-hss fi ###################################### @@ -641,7 +639,7 @@ esac # testing ############################################ - if [ $OAI_TEST = 1 ]; then + if [ $OAI_TEST -eq 1 ]; then echo_info "10. Testing ..." python $OPENAIR_TARGETS/TEST/OAI/test01.py else @@ -652,8 +650,8 @@ esac # run ############################################ echo_info "11. Running ... To be done" - if [ $TARGET = "SOFTMODEM" ]; then - if [ $HW = "EXMIMO" ]; then + if [ $TARGET == "SOFTMODEM" ]; then + if [ $HW == "EXMIMO" ]; then bash $OPENAIR_TARGETS/RT/USER/init_exmimo2.sh fi echo "############# running ltesoftmodem #############"