Jackie Huang | b5105bb | 2019-10-16 14:53:59 +0800 | [diff] [blame] | 1 | #!/bin/bash |
Jackie Huang | 54049b4 | 2019-11-13 14:43:04 +0800 | [diff] [blame] | 2 | # |
| 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 Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 16 | |
Jackie Huang | ab45ef3 | 2019-11-07 11:49:57 +0800 | [diff] [blame] | 17 | # Ensure we fail the job if any steps fail. |
Jackie Huang | ba8ab24 | 2019-11-07 16:31:10 +0800 | [diff] [blame] | 18 | set -e -o pipefail |
Jackie Huang | ab45ef3 | 2019-11-07 11:49:57 +0800 | [diff] [blame] | 19 | |
Jackie Huang | aa94cc1 | 2020-03-02 19:29:01 +0800 | [diff] [blame] | 20 | SUPPORTED_BSP="intel-x86-64 nxp-lx2xxx" |
| 21 | WRTEMPLATE_COMMON="feature/oran-host-rt-tune feature/kubernetes feature/self-hosted" |
| 22 | WRTEMPLATE_X86="feature/hosts-ia feature/kvm feature/dpdk" |
| 23 | |
| 24 | SRC_ORAN_BRANCH="master" |
| 25 | SRC_WRL_BRANCH="WRLINUX_10_18_BASE" |
| 26 | SRC_WRL_URL="git://github.com/WindRiver-Labs/wrlinux-x.git" |
| 27 | |
| 28 | SCRIPTS_DIR=$(dirname $(readlink -f $0)) |
| 29 | |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 30 | help_info () { |
| 31 | cat << ENDHELP |
| 32 | Usage: |
Jackie Huang | aa94cc1 | 2020-03-02 19:29:01 +0800 | [diff] [blame] | 33 | $(basename $0) <-w WORKSPACE_DIR> [-b BSP] [-n] [-h] [-r] |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 34 | where: |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 35 | -w WORKSPACE_DIR is the path for the project |
Jackie Huang | aa94cc1 | 2020-03-02 19:29:01 +0800 | [diff] [blame] | 36 | -b BPS is one of supported BSP: "${SUPPORTED_BSP}" |
| 37 | (default is intel-x86-64 if not specified.) |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 38 | -n dry-run only for bitbake |
| 39 | -h this help info |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 40 | -e EXTRA_CONF is the pat for extra config file |
Jackie Huang | 45c7611 | 2019-12-09 17:39:02 +0800 | [diff] [blame] | 41 | -r whether to inherit rm_work (default is Yes) |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 42 | ENDHELP |
| 43 | } |
| 44 | |
| 45 | echo_info () { |
| 46 | echo "INFO: $1" |
| 47 | } |
| 48 | |
| 49 | echo_error () { |
| 50 | echo "ERROR: $1" |
| 51 | } |
| 52 | |
| 53 | echo_cmd () { |
| 54 | echo |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 55 | echo_info "$1" |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 56 | echo "CMD: ${RUN_CMD}" |
| 57 | } |
| 58 | |
| 59 | if [ $# -eq 0 ]; then |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 60 | echo "Missing options!" |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 61 | help_info |
| 62 | exit |
| 63 | fi |
| 64 | |
Jackie Huang | 45c7611 | 2019-12-09 17:39:02 +0800 | [diff] [blame] | 65 | check_yn_rm_work () { |
| 66 | yn="$1" |
| 67 | case ${yn} in |
| 68 | [Yy]|[Yy]es) |
| 69 | RM_WORK="Yes" |
| 70 | ;; |
| 71 | [Nn]|[Nn]o) |
| 72 | RM_WORK="No" |
| 73 | ;; |
| 74 | *) |
| 75 | echo "Invalid arg for -r option." |
| 76 | help_info |
| 77 | exit 1 |
| 78 | ;; |
| 79 | esac |
| 80 | } |
| 81 | |
Jackie Huang | aa94cc1 | 2020-03-02 19:29:01 +0800 | [diff] [blame] | 82 | check_valid_bsp () { |
| 83 | bsp="$1" |
| 84 | for b in ${SUPPORTED_BSP}; do |
| 85 | if [ "${bsp}" == "${b}" ]; then |
| 86 | BSP_VALID="${bsp}" |
| 87 | break |
| 88 | fi |
| 89 | done |
| 90 | if [ -z "${BSP_VALID}" ]; then |
| 91 | echo_error "${bsp} is not a supported BSP, the supported BSPs are: ${SUPPORTED_BSP}" |
| 92 | exit 1 |
| 93 | fi |
| 94 | } |
| 95 | |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 96 | DRYRUN="" |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 97 | EXTRA_CONF="" |
Jackie Huang | 45c7611 | 2019-12-09 17:39:02 +0800 | [diff] [blame] | 98 | RM_WORK="Yes" |
Jackie Huang | aa94cc1 | 2020-03-02 19:29:01 +0800 | [diff] [blame] | 99 | BSP="intel-x86-64" |
Jackie Huang | 9e0c38e | 2020-06-10 16:49:17 +0800 | [diff] [blame^] | 100 | IMAGE_TYPE="iso" |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 101 | |
Jackie Huang | aa94cc1 | 2020-03-02 19:29:01 +0800 | [diff] [blame] | 102 | while getopts "w:b:e:r:nh" OPTION; do |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 103 | case ${OPTION} in |
| 104 | w) |
| 105 | WORKSPACE=`readlink -f ${OPTARG}` |
| 106 | ;; |
Jackie Huang | aa94cc1 | 2020-03-02 19:29:01 +0800 | [diff] [blame] | 107 | b) |
| 108 | check_valid_bsp ${OPTARG} |
| 109 | ;; |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 110 | e) |
| 111 | EXTRA_CONF=`readlink -f ${OPTARG}` |
Jackie Huang | 45c7611 | 2019-12-09 17:39:02 +0800 | [diff] [blame] | 112 | ;; |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 113 | n) |
| 114 | DRYRUN="-n" |
| 115 | ;; |
Jackie Huang | 45c7611 | 2019-12-09 17:39:02 +0800 | [diff] [blame] | 116 | r) |
| 117 | check_yn_rm_work ${OPTARG} |
| 118 | ;; |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 119 | h) |
| 120 | help_info |
| 121 | exit |
| 122 | ;; |
| 123 | esac |
| 124 | done |
| 125 | |
Jackie Huang | aa94cc1 | 2020-03-02 19:29:01 +0800 | [diff] [blame] | 126 | if [ -z "${WORKSPACE}" ]; then |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 127 | echo_info "No workspace specified, a directory 'workspace' will be created in current directory as the workspace" |
| 128 | WORKSPACE=`readlink -f workspace` |
| 129 | fi |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 130 | |
Jackie Huang | aa94cc1 | 2020-03-02 19:29:01 +0800 | [diff] [blame] | 131 | if [ -n "${BSP_VALID}" ]; then |
| 132 | BSP="${BSP_VALID}" |
| 133 | fi |
| 134 | |
Jackie Huang | 9e0c38e | 2020-06-10 16:49:17 +0800 | [diff] [blame^] | 135 | # iso image is not supported by nxp-lx2xxx yet |
| 136 | if [ "${BSP}" == "nxp-lx2xxx" ]; then |
| 137 | IMAGE_TYPE="tar.bz2" |
| 138 | fi |
| 139 | |
Jackie Huang | aa94cc1 | 2020-03-02 19:29:01 +0800 | [diff] [blame] | 140 | SRC_WRL_DIR=${WORKSPACE}/src_wrlinux |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 141 | SRC_ORAN_DIR=${WORKSPACE}/src_oran |
| 142 | PRJ_BUILD_DIR=${WORKSPACE}/prj_oran-inf |
| 143 | |
| 144 | mkdir -p ${SRC_WRL_DIR} ${PRJ_BUILD_DIR} ${SRC_ORAN_DIR} |
| 145 | |
| 146 | echo_info "The following directories are created in your workspace(${WORKSPACE}):" |
Jackie Huang | aa94cc1 | 2020-03-02 19:29:01 +0800 | [diff] [blame] | 147 | echo_info "For wrlinux source: ${SRC_WRL_DIR}" |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 148 | echo_info "For oran layer source: ${SRC_ORAN_DIR}" |
| 149 | echo_info "For build project: ${PRJ_BUILD_DIR}" |
| 150 | |
Jackie Huang | aa94cc1 | 2020-03-02 19:29:01 +0800 | [diff] [blame] | 151 | # Clone the source of WRLinux from github and setup |
| 152 | RUN_CMD="git clone --branch ${SRC_WRL_BRANCH} ${SRC_WRL_URL}" |
| 153 | echo_cmd "Cloning wrlinux-x source from github:" |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 154 | cd ${SRC_WRL_DIR} |
| 155 | ${RUN_CMD} |
| 156 | |
Jackie Huang | aa94cc1 | 2020-03-02 19:29:01 +0800 | [diff] [blame] | 157 | RUN_CMD="./wrlinux-x/setup.sh --machines ${BSP} --layers meta-cloud-services" |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 158 | echo_cmd "Setup wrlinux build project:" |
| 159 | ${RUN_CMD} |
| 160 | |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 161 | # Clone the oran layer if it's not already cloned |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 162 | # Check if the script is inside the repo |
Jackie Huang | 1135be2 | 2019-11-05 15:39:00 +0800 | [diff] [blame] | 163 | if cd ${SCRIPTS_DIR} && git rev-parse --is-inside-work-tree > /dev/null 2>&1; then |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 164 | CLONED_ORAN_REPO=`dirname ${SCRIPTS_DIR}` |
| 165 | echo_info "Use the cloned oran repo: ${CLONED_ORAN_REPO}" |
Jackie Huang | b650389 | 2019-12-07 23:39:51 +0800 | [diff] [blame] | 166 | mkdir ${SRC_ORAN_DIR}/rtp |
| 167 | cd ${SRC_ORAN_DIR}/rtp |
| 168 | ln -sf ${CLONED_ORAN_REPO}/meta-oran meta-oran |
| 169 | ln -sf ${CLONED_ORAN_REPO}/scripts scripts |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 170 | else |
| 171 | echo_info "Cloning oran layer:" |
Jackie Huang | 1135be2 | 2019-11-05 15:39:00 +0800 | [diff] [blame] | 172 | cd ${SRC_ORAN_DIR} |
Jackie Huang | aa94cc1 | 2020-03-02 19:29:01 +0800 | [diff] [blame] | 173 | RUN_CMD="git clone --branch ${SRC_ORAN_BRANCH} https://gerrit.o-ran-sc.org/r/pti/rtp" |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 174 | echo_cmd "Cloing with:" |
| 175 | ${RUN_CMD} |
| 176 | fi |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 177 | |
Jackie Huang | aa94cc1 | 2020-03-02 19:29:01 +0800 | [diff] [blame] | 178 | # Apply meta patches for nxp-lx2xxx |
| 179 | if [ "${BSP}" == "nxp-lx2xxx" ]; then |
| 180 | cd ${SRC_WRL_DIR}/layers/nxp-lx2xxx/ |
| 181 | git am ${SRC_ORAN_DIR}/rtp/scripts/meta-patches/nxp-lx2xxx/0001-Revert-nxp-lx2xxx-remove-preempt-rt-related-file.patch |
| 182 | fi |
| 183 | |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 184 | # Source the build env |
| 185 | cd ${SRC_WRL_DIR} |
| 186 | . ./environment-setup-x86_64-wrlinuxsdk-linux |
| 187 | set ${PRJ_BUILD_DIR} |
| 188 | . ./oe-init-build-env ${PRJ_BUILD_DIR} |
| 189 | |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 190 | # Add the meta-oran layer |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 191 | cd ${PRJ_BUILD_DIR} |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 192 | RUN_CMD="bitbake-layers add-layer ${SRC_ORAN_DIR}/rtp/meta-oran" |
| 193 | echo_cmd "Add the meta-oran layer into the build project" |
| 194 | ${RUN_CMD} |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 195 | |
| 196 | # Add extra configs into local.conf |
| 197 | cat << EOF >> conf/local.conf |
| 198 | ######################## |
| 199 | # Configs for oran-inf # |
| 200 | ######################## |
| 201 | DISTRO = "oran-inf" |
| 202 | BB_NO_NETWORK = '0' |
Jackie Huang | b06a977 | 2019-12-03 17:13:24 +0800 | [diff] [blame] | 203 | |
| 204 | # Work around for CI build |
| 205 | IMAGE_INSTALL_remove = "ceph" |
Jackie Huang | aa94cc1 | 2020-03-02 19:29:01 +0800 | [diff] [blame] | 206 | |
| 207 | # For container image |
| 208 | WR_APP_CONTAINER_APP = "rt-tests" |
| 209 | |
| 210 | # Disable multilib fo nxp-lx2xxx |
| 211 | MULTILIBS_nxp-lx2xxx = "" |
| 212 | DEFAULTTUNE_virtclass-multilib-lib32_nxp-lx2xxx = "" |
| 213 | |
| 214 | # Add templates |
| 215 | WRTEMPLATE += "${WRTEMPLATE_COMMON}" |
| 216 | WRTEMPLATE_prepend_x86-64 += "${WRTEMPLATE_X86}" |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 217 | EOF |
| 218 | |
Jackie Huang | 45c7611 | 2019-12-09 17:39:02 +0800 | [diff] [blame] | 219 | if [ "${RM_WORK}" == "Yes" ]; then |
| 220 | echo "INHERIT += 'rm_work'" >> conf/local.conf |
| 221 | fi |
| 222 | |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 223 | if [ "${EXTRA_CONF}" != "" ] && [ -f "${EXTRA_CONF}" ]; then |
| 224 | cat ${EXTRA_CONF} >> conf/local.conf |
| 225 | fi |
| 226 | |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 227 | # Build the oran-inf-host image |
| 228 | mkdir -p logs |
| 229 | TIMESTAMP=`date +"%Y%m%d_%H%M%S"` |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 230 | RUN_CMD="bitbake ${DRYRUN} oran-image-inf-host" |
| 231 | echo_cmd "Build the oran-image-inf-host image" |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 232 | bitbake ${DRYRUN} oran-image-inf-host 2>&1|tee logs/bitbake_oran-image-inf-host_${TIMESTAMP}.log |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 233 | |
Jackie Huang | aa94cc1 | 2020-03-02 19:29:01 +0800 | [diff] [blame] | 234 | RUN_CMD="bitbake ${DRYRUN} wr-app-container" |
| 235 | echo_cmd "Build the wr-app-container image" |
| 236 | bitbake ${DRYRUN} wr-app-container 2>&1|tee logs/bitbake_wr-app-container_${TIMESTAMP}.log |
| 237 | |
Jackie Huang | 9e0c38e | 2020-06-10 16:49:17 +0800 | [diff] [blame^] | 238 | echo_info "Build succeeded, you can get the image in ${PRJ_BUILD_DIR}/tmp-glibc/deploy/images/${BSP}/oran-image-inf-host-${BSP}.${IMAGE_TYPE}" |