blob: 12dce7bc9dc521ec455d1ff3bd2f4933c69fc01c [file] [log] [blame]
Jackie Huangb5105bb2019-10-16 14:53:59 +08001#!/bin/bash
Jackie Huang54049b42019-11-13 14:43:04 +08002#
3# Copyright (C) 2019 Wind River Systems, Inc.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
Jackie Huang90b87ff2019-09-30 13:36:48 +080016
Jackie Huangab45ef32019-11-07 11:49:57 +080017# Ensure we fail the job if any steps fail.
Jackie Huangba8ab242019-11-07 16:31:10 +080018set -e -o pipefail
Jackie Huangab45ef32019-11-07 11:49:57 +080019
Jackie Huang90b87ff2019-09-30 13:36:48 +080020help_info () {
21cat << ENDHELP
22Usage:
Jackie Huangbe9f4e22019-10-16 10:02:00 +080023$(basename $0) <-w WORKSPACE_DIR> [-n] [-h]
Jackie Huang90b87ff2019-09-30 13:36:48 +080024where:
Jackie Huangbe9f4e22019-10-16 10:02:00 +080025 -w WORKSPACE_DIR is the path for the project
26 -n dry-run only for bitbake
27 -h this help info
Jackie Huang6d582c52019-11-01 15:28:47 +080028 -e EXTRA_CONF is the pat for extra config file
Jackie Huang45c76112019-12-09 17:39:02 +080029 -r whether to inherit rm_work (default is Yes)
Jackie Huang90b87ff2019-09-30 13:36:48 +080030ENDHELP
31}
32
33echo_info () {
34 echo "INFO: $1"
35}
36
37echo_error () {
38 echo "ERROR: $1"
39}
40
41echo_cmd () {
42 echo
Jackie Huang6d582c52019-11-01 15:28:47 +080043 echo_info "$1"
Jackie Huang90b87ff2019-09-30 13:36:48 +080044 echo "CMD: ${RUN_CMD}"
45}
46
47if [ $# -eq 0 ]; then
Jackie Huangbe9f4e22019-10-16 10:02:00 +080048 echo "Missing options!"
Jackie Huang90b87ff2019-09-30 13:36:48 +080049 help_info
50 exit
51fi
52
Jackie Huang45c76112019-12-09 17:39:02 +080053check_yn_rm_work () {
54 yn="$1"
55 case ${yn} in
56 [Yy]|[Yy]es)
57 RM_WORK="Yes"
58 ;;
59 [Nn]|[Nn]o)
60 RM_WORK="No"
61 ;;
62 *)
63 echo "Invalid arg for -r option."
64 help_info
65 exit 1
66 ;;
67 esac
68}
69
Jackie Huangbe9f4e22019-10-16 10:02:00 +080070DRYRUN=""
Jackie Huang6d582c52019-11-01 15:28:47 +080071EXTRA_CONF=""
Jackie Huang45c76112019-12-09 17:39:02 +080072RM_WORK="Yes"
Jackie Huangbe9f4e22019-10-16 10:02:00 +080073
Jackie Huang90b87ff2019-09-30 13:36:48 +080074SCRIPTS_DIR=`dirname $0`
75SCRIPTS_DIR=`readlink -f $SCRIPTS_DIR`
76
Jackie Huang45c76112019-12-09 17:39:02 +080077while getopts "w:e:r:nh" OPTION; do
Jackie Huangbe9f4e22019-10-16 10:02:00 +080078 case ${OPTION} in
79 w)
80 WORKSPACE=`readlink -f ${OPTARG}`
81 ;;
Jackie Huang6d582c52019-11-01 15:28:47 +080082 e)
83 EXTRA_CONF=`readlink -f ${OPTARG}`
Jackie Huang45c76112019-12-09 17:39:02 +080084 ;;
Jackie Huangbe9f4e22019-10-16 10:02:00 +080085 n)
86 DRYRUN="-n"
87 ;;
Jackie Huang45c76112019-12-09 17:39:02 +080088 r)
89 check_yn_rm_work ${OPTARG}
90 ;;
Jackie Huangbe9f4e22019-10-16 10:02:00 +080091 h)
92 help_info
93 exit
94 ;;
95 esac
96done
97
98if [ -z ${WORKSPACE} ]; then
99 echo_info "No workspace specified, a directory 'workspace' will be created in current directory as the workspace"
100 WORKSPACE=`readlink -f workspace`
101fi
Jackie Huang90b87ff2019-09-30 13:36:48 +0800102
103SRC_WRL_DIR=${WORKSPACE}/src_wrl1018
104SRC_ORAN_DIR=${WORKSPACE}/src_oran
105PRJ_BUILD_DIR=${WORKSPACE}/prj_oran-inf
106
107mkdir -p ${SRC_WRL_DIR} ${PRJ_BUILD_DIR} ${SRC_ORAN_DIR}
108
109echo_info "The following directories are created in your workspace(${WORKSPACE}):"
110echo_info "For wrlinux1018 source: ${SRC_WRL_DIR}"
111echo_info "For oran layer source: ${SRC_ORAN_DIR}"
112echo_info "For build project: ${PRJ_BUILD_DIR}"
113
114# Clone the source of WRLinux BASE 10.18 from github and setup
115RUN_CMD="git clone --branch WRLINUX_10_18_BASE git://github.com/WindRiver-Labs/wrlinux-x.git"
116echo_cmd "Cloning wrlinux 1018 source from github:"
117cd ${SRC_WRL_DIR}
118${RUN_CMD}
119
Jackie Huangda071f82019-09-30 14:33:27 +0800120RUN_CMD="./wrlinux-x/setup.sh --machines intel-x86-64 --layers meta-cloud-services"
Jackie Huang90b87ff2019-09-30 13:36:48 +0800121echo_cmd "Setup wrlinux build project:"
122${RUN_CMD}
123
Jackie Huang6d582c52019-11-01 15:28:47 +0800124# Clone the oran layer if it's not already cloned
Jackie Huang6d582c52019-11-01 15:28:47 +0800125# Check if the script is inside the repo
Jackie Huang1135be22019-11-05 15:39:00 +0800126if cd ${SCRIPTS_DIR} && git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
Jackie Huang6d582c52019-11-01 15:28:47 +0800127 CLONED_ORAN_REPO=`dirname ${SCRIPTS_DIR}`
128 echo_info "Use the cloned oran repo: ${CLONED_ORAN_REPO}"
Jackie Huangb6503892019-12-07 23:39:51 +0800129 mkdir ${SRC_ORAN_DIR}/rtp
130 cd ${SRC_ORAN_DIR}/rtp
131 ln -sf ${CLONED_ORAN_REPO}/meta-oran meta-oran
132 ln -sf ${CLONED_ORAN_REPO}/scripts scripts
Jackie Huang6d582c52019-11-01 15:28:47 +0800133else
134 echo_info "Cloning oran layer:"
Jackie Huang1135be22019-11-05 15:39:00 +0800135 cd ${SRC_ORAN_DIR}
Jackie Huang6d582c52019-11-01 15:28:47 +0800136 RUN_CMD="git clone https://gerrit.o-ran-sc.org/r/pti/rtp"
137 echo_cmd "Cloing with:"
138 ${RUN_CMD}
139fi
Jackie Huang90b87ff2019-09-30 13:36:48 +0800140
141# Source the build env
142cd ${SRC_WRL_DIR}
143. ./environment-setup-x86_64-wrlinuxsdk-linux
144set ${PRJ_BUILD_DIR}
145. ./oe-init-build-env ${PRJ_BUILD_DIR}
146
Jackie Huang6d582c52019-11-01 15:28:47 +0800147# Add the meta-oran layer
Jackie Huang90b87ff2019-09-30 13:36:48 +0800148cd ${PRJ_BUILD_DIR}
Jackie Huang6d582c52019-11-01 15:28:47 +0800149RUN_CMD="bitbake-layers add-layer ${SRC_ORAN_DIR}/rtp/meta-oran"
150echo_cmd "Add the meta-oran layer into the build project"
151${RUN_CMD}
Jackie Huang90b87ff2019-09-30 13:36:48 +0800152
153# Add extra configs into local.conf
154cat << EOF >> conf/local.conf
155########################
156# Configs for oran-inf #
157########################
158DISTRO = "oran-inf"
159BB_NO_NETWORK = '0'
Jackie Huang2d4dbbd2019-10-21 14:14:24 +0800160WRTEMPLATE += "feature/oran-host-rt-tune"
Jackie Huangb06a9772019-12-03 17:13:24 +0800161
162# Work around for CI build
163IMAGE_INSTALL_remove = "ceph"
Jackie Huang90b87ff2019-09-30 13:36:48 +0800164EOF
165
Jackie Huang45c76112019-12-09 17:39:02 +0800166if [ "${RM_WORK}" == "Yes" ]; then
167 echo "INHERIT += 'rm_work'" >> conf/local.conf
168fi
169
Jackie Huang6d582c52019-11-01 15:28:47 +0800170if [ "${EXTRA_CONF}" != "" ] && [ -f "${EXTRA_CONF}" ]; then
171 cat ${EXTRA_CONF} >> conf/local.conf
172fi
173
Jackie Huang90b87ff2019-09-30 13:36:48 +0800174# Build the oran-inf-host image
175mkdir -p logs
176TIMESTAMP=`date +"%Y%m%d_%H%M%S"`
Jackie Huang6d582c52019-11-01 15:28:47 +0800177RUN_CMD="bitbake ${DRYRUN} oran-image-inf-host"
178echo_cmd "Build the oran-image-inf-host image"
Jackie Huangbe9f4e22019-10-16 10:02:00 +0800179bitbake ${DRYRUN} oran-image-inf-host 2>&1|tee logs/bitbake_oran-image-inf-host_${TIMESTAMP}.log
Jackie Huang6d582c52019-11-01 15:28:47 +0800180
181echo_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"