blob: 3a61f550880a51d1e3ff51d2ac7a8b99c6f03dd9 [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 Huang90b87ff2019-09-30 13:36:48 +080029ENDHELP
30}
31
32echo_info () {
33 echo "INFO: $1"
34}
35
36echo_error () {
37 echo "ERROR: $1"
38}
39
40echo_cmd () {
41 echo
Jackie Huang6d582c52019-11-01 15:28:47 +080042 echo_info "$1"
Jackie Huang90b87ff2019-09-30 13:36:48 +080043 echo "CMD: ${RUN_CMD}"
44}
45
46if [ $# -eq 0 ]; then
Jackie Huangbe9f4e22019-10-16 10:02:00 +080047 echo "Missing options!"
Jackie Huang90b87ff2019-09-30 13:36:48 +080048 help_info
49 exit
50fi
51
Jackie Huangbe9f4e22019-10-16 10:02:00 +080052DRYRUN=""
Jackie Huang6d582c52019-11-01 15:28:47 +080053EXTRA_CONF=""
Jackie Huangbe9f4e22019-10-16 10:02:00 +080054
Jackie Huang90b87ff2019-09-30 13:36:48 +080055SCRIPTS_DIR=`dirname $0`
56SCRIPTS_DIR=`readlink -f $SCRIPTS_DIR`
57
Jackie Huang6d582c52019-11-01 15:28:47 +080058while getopts "w:e:nh" OPTION; do
Jackie Huangbe9f4e22019-10-16 10:02:00 +080059 case ${OPTION} in
60 w)
61 WORKSPACE=`readlink -f ${OPTARG}`
62 ;;
Jackie Huang6d582c52019-11-01 15:28:47 +080063 e)
64 EXTRA_CONF=`readlink -f ${OPTARG}`
65 ;;
Jackie Huangbe9f4e22019-10-16 10:02:00 +080066 n)
67 DRYRUN="-n"
68 ;;
69 h)
70 help_info
71 exit
72 ;;
73 esac
74done
75
76if [ -z ${WORKSPACE} ]; then
77 echo_info "No workspace specified, a directory 'workspace' will be created in current directory as the workspace"
78 WORKSPACE=`readlink -f workspace`
79fi
Jackie Huang90b87ff2019-09-30 13:36:48 +080080
81SRC_WRL_DIR=${WORKSPACE}/src_wrl1018
82SRC_ORAN_DIR=${WORKSPACE}/src_oran
83PRJ_BUILD_DIR=${WORKSPACE}/prj_oran-inf
84
85mkdir -p ${SRC_WRL_DIR} ${PRJ_BUILD_DIR} ${SRC_ORAN_DIR}
86
87echo_info "The following directories are created in your workspace(${WORKSPACE}):"
88echo_info "For wrlinux1018 source: ${SRC_WRL_DIR}"
89echo_info "For oran layer source: ${SRC_ORAN_DIR}"
90echo_info "For build project: ${PRJ_BUILD_DIR}"
91
92# Clone the source of WRLinux BASE 10.18 from github and setup
93RUN_CMD="git clone --branch WRLINUX_10_18_BASE git://github.com/WindRiver-Labs/wrlinux-x.git"
94echo_cmd "Cloning wrlinux 1018 source from github:"
95cd ${SRC_WRL_DIR}
96${RUN_CMD}
97
Jackie Huangda071f82019-09-30 14:33:27 +080098RUN_CMD="./wrlinux-x/setup.sh --machines intel-x86-64 --layers meta-cloud-services"
Jackie Huang90b87ff2019-09-30 13:36:48 +080099echo_cmd "Setup wrlinux build project:"
100${RUN_CMD}
101
Jackie Huang6d582c52019-11-01 15:28:47 +0800102# Clone the oran layer if it's not already cloned
Jackie Huang6d582c52019-11-01 15:28:47 +0800103# Check if the script is inside the repo
Jackie Huang1135be22019-11-05 15:39:00 +0800104if cd ${SCRIPTS_DIR} && git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
Jackie Huang6d582c52019-11-01 15:28:47 +0800105 CLONED_ORAN_REPO=`dirname ${SCRIPTS_DIR}`
106 echo_info "Use the cloned oran repo: ${CLONED_ORAN_REPO}"
Jackie Huangb6503892019-12-07 23:39:51 +0800107 mkdir ${SRC_ORAN_DIR}/rtp
108 cd ${SRC_ORAN_DIR}/rtp
109 ln -sf ${CLONED_ORAN_REPO}/meta-oran meta-oran
110 ln -sf ${CLONED_ORAN_REPO}/scripts scripts
Jackie Huang6d582c52019-11-01 15:28:47 +0800111else
112 echo_info "Cloning oran layer:"
Jackie Huang1135be22019-11-05 15:39:00 +0800113 cd ${SRC_ORAN_DIR}
Jackie Huang6d582c52019-11-01 15:28:47 +0800114 RUN_CMD="git clone https://gerrit.o-ran-sc.org/r/pti/rtp"
115 echo_cmd "Cloing with:"
116 ${RUN_CMD}
117fi
Jackie Huang90b87ff2019-09-30 13:36:48 +0800118
119# Source the build env
120cd ${SRC_WRL_DIR}
121. ./environment-setup-x86_64-wrlinuxsdk-linux
122set ${PRJ_BUILD_DIR}
123. ./oe-init-build-env ${PRJ_BUILD_DIR}
124
Jackie Huang6d582c52019-11-01 15:28:47 +0800125# Add the meta-oran layer
Jackie Huang90b87ff2019-09-30 13:36:48 +0800126cd ${PRJ_BUILD_DIR}
Jackie Huang6d582c52019-11-01 15:28:47 +0800127RUN_CMD="bitbake-layers add-layer ${SRC_ORAN_DIR}/rtp/meta-oran"
128echo_cmd "Add the meta-oran layer into the build project"
129${RUN_CMD}
Jackie Huang90b87ff2019-09-30 13:36:48 +0800130
131# Add extra configs into local.conf
132cat << EOF >> conf/local.conf
133########################
134# Configs for oran-inf #
135########################
136DISTRO = "oran-inf"
137BB_NO_NETWORK = '0'
Jackie Huang2d4dbbd2019-10-21 14:14:24 +0800138WRTEMPLATE += "feature/oran-host-rt-tune"
Jackie Huangb06a9772019-12-03 17:13:24 +0800139
140# Work around for CI build
141IMAGE_INSTALL_remove = "ceph"
Jackie Huang90b87ff2019-09-30 13:36:48 +0800142EOF
143
Jackie Huang6d582c52019-11-01 15:28:47 +0800144if [ "${EXTRA_CONF}" != "" ] && [ -f "${EXTRA_CONF}" ]; then
145 cat ${EXTRA_CONF} >> conf/local.conf
146fi
147
Jackie Huang90b87ff2019-09-30 13:36:48 +0800148# Build the oran-inf-host image
149mkdir -p logs
150TIMESTAMP=`date +"%Y%m%d_%H%M%S"`
Jackie Huang6d582c52019-11-01 15:28:47 +0800151RUN_CMD="bitbake ${DRYRUN} oran-image-inf-host"
152echo_cmd "Build the oran-image-inf-host image"
Jackie Huangbe9f4e22019-10-16 10:02:00 +0800153bitbake ${DRYRUN} oran-image-inf-host 2>&1|tee logs/bitbake_oran-image-inf-host_${TIMESTAMP}.log
Jackie Huang6d582c52019-11-01 15:28:47 +0800154
155echo_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"