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 | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 20 | help_info () { |
| 21 | cat << ENDHELP |
| 22 | Usage: |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 23 | $(basename $0) <-w WORKSPACE_DIR> [-n] [-h] |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 24 | where: |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 25 | -w WORKSPACE_DIR is the path for the project |
| 26 | -n dry-run only for bitbake |
| 27 | -h this help info |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 28 | -e EXTRA_CONF is the pat for extra config file |
Jackie Huang | 45c7611 | 2019-12-09 17:39:02 +0800 | [diff] [blame^] | 29 | -r whether to inherit rm_work (default is Yes) |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 30 | ENDHELP |
| 31 | } |
| 32 | |
| 33 | echo_info () { |
| 34 | echo "INFO: $1" |
| 35 | } |
| 36 | |
| 37 | echo_error () { |
| 38 | echo "ERROR: $1" |
| 39 | } |
| 40 | |
| 41 | echo_cmd () { |
| 42 | echo |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 43 | echo_info "$1" |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 44 | echo "CMD: ${RUN_CMD}" |
| 45 | } |
| 46 | |
| 47 | if [ $# -eq 0 ]; then |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 48 | echo "Missing options!" |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 49 | help_info |
| 50 | exit |
| 51 | fi |
| 52 | |
Jackie Huang | 45c7611 | 2019-12-09 17:39:02 +0800 | [diff] [blame^] | 53 | check_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 Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 70 | DRYRUN="" |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 71 | EXTRA_CONF="" |
Jackie Huang | 45c7611 | 2019-12-09 17:39:02 +0800 | [diff] [blame^] | 72 | RM_WORK="Yes" |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 73 | |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 74 | SCRIPTS_DIR=`dirname $0` |
| 75 | SCRIPTS_DIR=`readlink -f $SCRIPTS_DIR` |
| 76 | |
Jackie Huang | 45c7611 | 2019-12-09 17:39:02 +0800 | [diff] [blame^] | 77 | while getopts "w:e:r:nh" OPTION; do |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 78 | case ${OPTION} in |
| 79 | w) |
| 80 | WORKSPACE=`readlink -f ${OPTARG}` |
| 81 | ;; |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 82 | e) |
| 83 | EXTRA_CONF=`readlink -f ${OPTARG}` |
Jackie Huang | 45c7611 | 2019-12-09 17:39:02 +0800 | [diff] [blame^] | 84 | ;; |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 85 | n) |
| 86 | DRYRUN="-n" |
| 87 | ;; |
Jackie Huang | 45c7611 | 2019-12-09 17:39:02 +0800 | [diff] [blame^] | 88 | r) |
| 89 | check_yn_rm_work ${OPTARG} |
| 90 | ;; |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 91 | h) |
| 92 | help_info |
| 93 | exit |
| 94 | ;; |
| 95 | esac |
| 96 | done |
| 97 | |
| 98 | if [ -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` |
| 101 | fi |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 102 | |
| 103 | SRC_WRL_DIR=${WORKSPACE}/src_wrl1018 |
| 104 | SRC_ORAN_DIR=${WORKSPACE}/src_oran |
| 105 | PRJ_BUILD_DIR=${WORKSPACE}/prj_oran-inf |
| 106 | |
| 107 | mkdir -p ${SRC_WRL_DIR} ${PRJ_BUILD_DIR} ${SRC_ORAN_DIR} |
| 108 | |
| 109 | echo_info "The following directories are created in your workspace(${WORKSPACE}):" |
| 110 | echo_info "For wrlinux1018 source: ${SRC_WRL_DIR}" |
| 111 | echo_info "For oran layer source: ${SRC_ORAN_DIR}" |
| 112 | echo_info "For build project: ${PRJ_BUILD_DIR}" |
| 113 | |
| 114 | # Clone the source of WRLinux BASE 10.18 from github and setup |
| 115 | RUN_CMD="git clone --branch WRLINUX_10_18_BASE git://github.com/WindRiver-Labs/wrlinux-x.git" |
| 116 | echo_cmd "Cloning wrlinux 1018 source from github:" |
| 117 | cd ${SRC_WRL_DIR} |
| 118 | ${RUN_CMD} |
| 119 | |
Jackie Huang | da071f8 | 2019-09-30 14:33:27 +0800 | [diff] [blame] | 120 | RUN_CMD="./wrlinux-x/setup.sh --machines intel-x86-64 --layers meta-cloud-services" |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 121 | echo_cmd "Setup wrlinux build project:" |
| 122 | ${RUN_CMD} |
| 123 | |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 124 | # Clone the oran layer if it's not already cloned |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 125 | # Check if the script is inside the repo |
Jackie Huang | 1135be2 | 2019-11-05 15:39:00 +0800 | [diff] [blame] | 126 | 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] | 127 | CLONED_ORAN_REPO=`dirname ${SCRIPTS_DIR}` |
| 128 | echo_info "Use the cloned oran repo: ${CLONED_ORAN_REPO}" |
Jackie Huang | b650389 | 2019-12-07 23:39:51 +0800 | [diff] [blame] | 129 | 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 Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 133 | else |
| 134 | echo_info "Cloning oran layer:" |
Jackie Huang | 1135be2 | 2019-11-05 15:39:00 +0800 | [diff] [blame] | 135 | cd ${SRC_ORAN_DIR} |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 136 | RUN_CMD="git clone https://gerrit.o-ran-sc.org/r/pti/rtp" |
| 137 | echo_cmd "Cloing with:" |
| 138 | ${RUN_CMD} |
| 139 | fi |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 140 | |
| 141 | # Source the build env |
| 142 | cd ${SRC_WRL_DIR} |
| 143 | . ./environment-setup-x86_64-wrlinuxsdk-linux |
| 144 | set ${PRJ_BUILD_DIR} |
| 145 | . ./oe-init-build-env ${PRJ_BUILD_DIR} |
| 146 | |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 147 | # Add the meta-oran layer |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 148 | cd ${PRJ_BUILD_DIR} |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 149 | RUN_CMD="bitbake-layers add-layer ${SRC_ORAN_DIR}/rtp/meta-oran" |
| 150 | echo_cmd "Add the meta-oran layer into the build project" |
| 151 | ${RUN_CMD} |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 152 | |
| 153 | # Add extra configs into local.conf |
| 154 | cat << EOF >> conf/local.conf |
| 155 | ######################## |
| 156 | # Configs for oran-inf # |
| 157 | ######################## |
| 158 | DISTRO = "oran-inf" |
| 159 | BB_NO_NETWORK = '0' |
Jackie Huang | 2d4dbbd | 2019-10-21 14:14:24 +0800 | [diff] [blame] | 160 | WRTEMPLATE += "feature/oran-host-rt-tune" |
Jackie Huang | b06a977 | 2019-12-03 17:13:24 +0800 | [diff] [blame] | 161 | |
| 162 | # Work around for CI build |
| 163 | IMAGE_INSTALL_remove = "ceph" |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 164 | EOF |
| 165 | |
Jackie Huang | 45c7611 | 2019-12-09 17:39:02 +0800 | [diff] [blame^] | 166 | if [ "${RM_WORK}" == "Yes" ]; then |
| 167 | echo "INHERIT += 'rm_work'" >> conf/local.conf |
| 168 | fi |
| 169 | |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 170 | if [ "${EXTRA_CONF}" != "" ] && [ -f "${EXTRA_CONF}" ]; then |
| 171 | cat ${EXTRA_CONF} >> conf/local.conf |
| 172 | fi |
| 173 | |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 174 | # Build the oran-inf-host image |
| 175 | mkdir -p logs |
| 176 | TIMESTAMP=`date +"%Y%m%d_%H%M%S"` |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 177 | RUN_CMD="bitbake ${DRYRUN} oran-image-inf-host" |
| 178 | echo_cmd "Build the oran-image-inf-host image" |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 179 | 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] | 180 | |
| 181 | echo_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" |