ea2231f4d3d7b6a02567fcdc2f98e916d7693b69
[pti/rtp.git] / scripts / build_oran.sh
1 #!/bin/bash
2
3 help_info () {
4 cat << ENDHELP
5 Usage:
6 $(basename $0) <-w WORKSPACE_DIR> [-n] [-h]
7 where:
8     -w WORKSPACE_DIR is the path for the project
9     -n dry-run only for bitbake
10     -h this help info
11 ENDHELP
12 }
13
14 echo_info () {
15     echo "INFO: $1"
16 }
17
18 echo_error () {
19     echo "ERROR: $1"
20 }
21
22 echo_cmd () {
23     echo
24     echo "$1"
25     echo "CMD: ${RUN_CMD}"
26 }
27
28 if [ $# -eq 0 ]; then
29     echo "Missing options!"
30     help_info
31     exit
32 fi
33
34 DRYRUN=""
35
36 SCRIPTS_DIR=`dirname $0`
37 SCRIPTS_DIR=`readlink -f $SCRIPTS_DIR`
38
39 while getopts "w:nh" OPTION; do
40     case ${OPTION} in
41         w)
42             WORKSPACE=`readlink -f ${OPTARG}`
43             ;;
44         n)
45             DRYRUN="-n"
46             ;;
47         h)
48             help_info
49             exit
50             ;;
51     esac
52 done
53
54 if [ -z ${WORKSPACE} ]; then
55     echo_info "No workspace specified, a directory 'workspace' will be created in current directory as the workspace"
56     WORKSPACE=`readlink -f workspace`
57 fi
58
59 SRC_WRL_DIR=${WORKSPACE}/src_wrl1018
60 SRC_ORAN_DIR=${WORKSPACE}/src_oran
61 PRJ_BUILD_DIR=${WORKSPACE}/prj_oran-inf
62
63 mkdir -p ${SRC_WRL_DIR} ${PRJ_BUILD_DIR} ${SRC_ORAN_DIR}
64
65 echo_info "The following directories are created in your workspace(${WORKSPACE}):"
66 echo_info "For wrlinux1018 source: ${SRC_WRL_DIR}"
67 echo_info "For oran layer source: ${SRC_ORAN_DIR}"
68 echo_info "For build project: ${PRJ_BUILD_DIR}"
69
70 # Clone the source of WRLinux BASE 10.18 from github and setup
71 RUN_CMD="git clone --branch WRLINUX_10_18_BASE git://github.com/WindRiver-Labs/wrlinux-x.git"
72 echo_cmd "Cloning wrlinux 1018 source from github:"
73 cd ${SRC_WRL_DIR}
74 ${RUN_CMD}
75
76 RUN_CMD="./wrlinux-x/setup.sh --machines intel-x86-64 --layers meta-cloud-services"
77 echo_cmd "Setup wrlinux build project:"
78 ${RUN_CMD}
79
80 # Clone extra layers
81 echo_info "Cloning oran layer:"
82
83 cd ${SRC_ORAN_DIR}
84 RUN_CMD="git clone https://gerrit.o-ran-sc.org/r/pti/rtp"
85 echo_cmd "Cloing with:"
86 ${RUN_CMD}
87
88 # Source the build env
89 cd ${SRC_WRL_DIR}
90 . ./environment-setup-x86_64-wrlinuxsdk-linux
91 set ${PRJ_BUILD_DIR}
92 . ./oe-init-build-env ${PRJ_BUILD_DIR}
93
94 # Add the meta-oran layer and required layers
95 cd ${PRJ_BUILD_DIR}
96 bitbake-layers add-layer ${SRC_ORAN_DIR}/rtp/meta-oran
97
98 # Add extra configs into local.conf
99 cat << EOF >> conf/local.conf
100 ########################
101 # Configs for oran-inf #
102 ########################
103 DISTRO = "oran-inf"
104 BB_NO_NETWORK = '0'
105 EOF
106
107 # Build the oran-inf-host image
108 mkdir -p logs
109 TIMESTAMP=`date +"%Y%m%d_%H%M%S"`
110 set -o pipefail
111 bitbake ${DRYRUN} oran-image-inf-host 2>&1|tee logs/bitbake_oran-image-inf-host_${TIMESTAMP}.log