X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=scripts%2Fbuild_oran.sh;h=2041b92ec77a49226cceeb6142db1f3a6a1fb718;hb=refs%2Fchanges%2F01%2F1401%2F1;hp=05192ecc7e6280f17248aa2ae4984ddb93019e75;hpb=477f99a2439564e6870b6498c3ace8b7d5e4ea98;p=pti%2Frtp.git diff --git a/scripts/build_oran.sh b/scripts/build_oran.sh index 05192ec..2041b92 100755 --- a/scripts/build_oran.sh +++ b/scripts/build_oran.sh @@ -1,11 +1,17 @@ -#!/bin/sh +#!/bin/bash + +# Ensure we fail the job if any steps fail. +set -e -o pipefail help_info () { cat << ENDHELP Usage: -$(basename $0) WORKSPACE_DIR +$(basename $0) <-w WORKSPACE_DIR> [-n] [-h] where: - WORKSPACE_DIR is the path for the project + -w WORKSPACE_DIR is the path for the project + -n dry-run only for bitbake + -h this help info + -e EXTRA_CONF is the pat for extra config file ENDHELP } @@ -19,19 +25,44 @@ echo_error () { echo_cmd () { echo - echo "$1" + echo_info "$1" echo "CMD: ${RUN_CMD}" } if [ $# -eq 0 ]; then + echo "Missing options!" help_info exit fi +DRYRUN="" +EXTRA_CONF="" + SCRIPTS_DIR=`dirname $0` SCRIPTS_DIR=`readlink -f $SCRIPTS_DIR` -WORKSPACE=`readlink -f $1` +while getopts "w:e:nh" OPTION; do + case ${OPTION} in + w) + WORKSPACE=`readlink -f ${OPTARG}` + ;; + e) + EXTRA_CONF=`readlink -f ${OPTARG}` + ;; + n) + DRYRUN="-n" + ;; + h) + help_info + exit + ;; + esac +done + +if [ -z ${WORKSPACE} ]; then + echo_info "No workspace specified, a directory 'workspace' will be created in current directory as the workspace" + WORKSPACE=`readlink -f workspace` +fi SRC_WRL_DIR=${WORKSPACE}/src_wrl1018 SRC_ORAN_DIR=${WORKSPACE}/src_oran @@ -54,13 +85,20 @@ RUN_CMD="./wrlinux-x/setup.sh --machines intel-x86-64 --layers meta-cloud-servic echo_cmd "Setup wrlinux build project:" ${RUN_CMD} -# Clone extra layers -echo_info "Cloning oran layer:" - -cd ${SRC_ORAN_DIR} -RUN_CMD="git clone https://gerrit.o-ran-sc.org/r/pti/rtp" -echo_cmd "Cloing with:" -${RUN_CMD} +# Clone the oran layer if it's not already cloned +# Check if the script is inside the repo +if cd ${SCRIPTS_DIR} && git rev-parse --is-inside-work-tree > /dev/null 2>&1; then + CLONED_ORAN_REPO=`dirname ${SCRIPTS_DIR}` + echo_info "Use the cloned oran repo: ${CLONED_ORAN_REPO}" + cd ${SRC_ORAN_DIR} + ln -sf ${CLONED_ORAN_REPO} rtp +else + echo_info "Cloning oran layer:" + cd ${SRC_ORAN_DIR} + RUN_CMD="git clone https://gerrit.o-ran-sc.org/r/pti/rtp" + echo_cmd "Cloing with:" + ${RUN_CMD} +fi # Source the build env cd ${SRC_WRL_DIR} @@ -68,9 +106,11 @@ cd ${SRC_WRL_DIR} set ${PRJ_BUILD_DIR} . ./oe-init-build-env ${PRJ_BUILD_DIR} -# Add the meta-oran layer and required layers +# Add the meta-oran layer cd ${PRJ_BUILD_DIR} -bitbake-layers add-layer ${SRC_ORAN_DIR}/rtp/meta-oran +RUN_CMD="bitbake-layers add-layer ${SRC_ORAN_DIR}/rtp/meta-oran" +echo_cmd "Add the meta-oran layer into the build project" +${RUN_CMD} # Add extra configs into local.conf cat << EOF >> conf/local.conf @@ -79,9 +119,18 @@ cat << EOF >> conf/local.conf ######################## DISTRO = "oran-inf" BB_NO_NETWORK = '0' +WRTEMPLATE += "feature/oran-host-rt-tune" EOF +if [ "${EXTRA_CONF}" != "" ] && [ -f "${EXTRA_CONF}" ]; then + cat ${EXTRA_CONF} >> conf/local.conf +fi + # Build the oran-inf-host image mkdir -p logs TIMESTAMP=`date +"%Y%m%d_%H%M%S"` -bitbake oran-image-inf-host 2>&1|tee logs/bitbake_oran-image-inf-host_${TIMESTAMP}.log +RUN_CMD="bitbake ${DRYRUN} oran-image-inf-host" +echo_cmd "Build the oran-image-inf-host image" +bitbake ${DRYRUN} oran-image-inf-host 2>&1|tee logs/bitbake_oran-image-inf-host_${TIMESTAMP}.log + +echo_info "Build succeeded, you can get the image in ${PRJ_BUILD_DIR}/tmp-glibc/deploy/images/intel-x86-64/oran-image-inf-host-intel-x86-64.iso"