build_oran.sh: ensure we fail the job if any steps fail
[pti/rtp.git] / scripts / build_oran.sh
index 39600c3..fceb8fa 100755 (executable)
@@ -1,5 +1,8 @@
 #!/bin/bash
 
+# Ensure we fail the job if any steps fail.
+set -eu -o pipefail
+
 help_info () {
 cat << ENDHELP
 Usage:
@@ -83,14 +86,15 @@ echo_cmd "Setup wrlinux build project:"
 ${RUN_CMD}
 
 # Clone the oran layer if it's not already cloned
-cd ${SRC_ORAN_DIR}
 # Check if the script is inside the repo
-if git -C ${SCRIPTS_DIR} rev-parse --is-inside-work-tree > /dev/null 2>&1; then
+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}"
-    ln -sf ${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}
@@ -125,7 +129,6 @@ fi
 # Build the oran-inf-host image
 mkdir -p logs
 TIMESTAMP=`date +"%Y%m%d_%H%M%S"`
-set -o pipefail
 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