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 | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 29 | ENDHELP |
| 30 | } |
| 31 | |
| 32 | echo_info () { |
| 33 | echo "INFO: $1" |
| 34 | } |
| 35 | |
| 36 | echo_error () { |
| 37 | echo "ERROR: $1" |
| 38 | } |
| 39 | |
| 40 | echo_cmd () { |
| 41 | echo |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 42 | echo_info "$1" |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 43 | echo "CMD: ${RUN_CMD}" |
| 44 | } |
| 45 | |
| 46 | if [ $# -eq 0 ]; then |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 47 | echo "Missing options!" |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 48 | help_info |
| 49 | exit |
| 50 | fi |
| 51 | |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 52 | DRYRUN="" |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 53 | EXTRA_CONF="" |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 54 | |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 55 | SCRIPTS_DIR=`dirname $0` |
| 56 | SCRIPTS_DIR=`readlink -f $SCRIPTS_DIR` |
| 57 | |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 58 | while getopts "w:e:nh" OPTION; do |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 59 | case ${OPTION} in |
| 60 | w) |
| 61 | WORKSPACE=`readlink -f ${OPTARG}` |
| 62 | ;; |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 63 | e) |
| 64 | EXTRA_CONF=`readlink -f ${OPTARG}` |
| 65 | ;; |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 66 | n) |
| 67 | DRYRUN="-n" |
| 68 | ;; |
| 69 | h) |
| 70 | help_info |
| 71 | exit |
| 72 | ;; |
| 73 | esac |
| 74 | done |
| 75 | |
| 76 | if [ -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` |
| 79 | fi |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 80 | |
| 81 | SRC_WRL_DIR=${WORKSPACE}/src_wrl1018 |
| 82 | SRC_ORAN_DIR=${WORKSPACE}/src_oran |
| 83 | PRJ_BUILD_DIR=${WORKSPACE}/prj_oran-inf |
| 84 | |
| 85 | mkdir -p ${SRC_WRL_DIR} ${PRJ_BUILD_DIR} ${SRC_ORAN_DIR} |
| 86 | |
| 87 | echo_info "The following directories are created in your workspace(${WORKSPACE}):" |
| 88 | echo_info "For wrlinux1018 source: ${SRC_WRL_DIR}" |
| 89 | echo_info "For oran layer source: ${SRC_ORAN_DIR}" |
| 90 | echo_info "For build project: ${PRJ_BUILD_DIR}" |
| 91 | |
| 92 | # Clone the source of WRLinux BASE 10.18 from github and setup |
| 93 | RUN_CMD="git clone --branch WRLINUX_10_18_BASE git://github.com/WindRiver-Labs/wrlinux-x.git" |
| 94 | echo_cmd "Cloning wrlinux 1018 source from github:" |
| 95 | cd ${SRC_WRL_DIR} |
| 96 | ${RUN_CMD} |
| 97 | |
Jackie Huang | da071f8 | 2019-09-30 14:33:27 +0800 | [diff] [blame] | 98 | 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] | 99 | echo_cmd "Setup wrlinux build project:" |
| 100 | ${RUN_CMD} |
| 101 | |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 102 | # Clone the oran layer if it's not already cloned |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 103 | # Check if the script is inside the repo |
Jackie Huang | 1135be2 | 2019-11-05 15:39:00 +0800 | [diff] [blame] | 104 | 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] | 105 | CLONED_ORAN_REPO=`dirname ${SCRIPTS_DIR}` |
| 106 | echo_info "Use the cloned oran repo: ${CLONED_ORAN_REPO}" |
Jackie Huang | b650389 | 2019-12-07 23:39:51 +0800 | [diff] [blame^] | 107 | 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 Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 111 | else |
| 112 | echo_info "Cloning oran layer:" |
Jackie Huang | 1135be2 | 2019-11-05 15:39:00 +0800 | [diff] [blame] | 113 | cd ${SRC_ORAN_DIR} |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 114 | RUN_CMD="git clone https://gerrit.o-ran-sc.org/r/pti/rtp" |
| 115 | echo_cmd "Cloing with:" |
| 116 | ${RUN_CMD} |
| 117 | fi |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 118 | |
| 119 | # Source the build env |
| 120 | cd ${SRC_WRL_DIR} |
| 121 | . ./environment-setup-x86_64-wrlinuxsdk-linux |
| 122 | set ${PRJ_BUILD_DIR} |
| 123 | . ./oe-init-build-env ${PRJ_BUILD_DIR} |
| 124 | |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 125 | # Add the meta-oran layer |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 126 | cd ${PRJ_BUILD_DIR} |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 127 | RUN_CMD="bitbake-layers add-layer ${SRC_ORAN_DIR}/rtp/meta-oran" |
| 128 | echo_cmd "Add the meta-oran layer into the build project" |
| 129 | ${RUN_CMD} |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 130 | |
| 131 | # Add extra configs into local.conf |
| 132 | cat << EOF >> conf/local.conf |
| 133 | ######################## |
| 134 | # Configs for oran-inf # |
| 135 | ######################## |
| 136 | DISTRO = "oran-inf" |
| 137 | BB_NO_NETWORK = '0' |
Jackie Huang | 2d4dbbd | 2019-10-21 14:14:24 +0800 | [diff] [blame] | 138 | WRTEMPLATE += "feature/oran-host-rt-tune" |
Jackie Huang | b06a977 | 2019-12-03 17:13:24 +0800 | [diff] [blame] | 139 | |
| 140 | # Work around for CI build |
| 141 | IMAGE_INSTALL_remove = "ceph" |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 142 | EOF |
| 143 | |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 144 | if [ "${EXTRA_CONF}" != "" ] && [ -f "${EXTRA_CONF}" ]; then |
| 145 | cat ${EXTRA_CONF} >> conf/local.conf |
| 146 | fi |
| 147 | |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 148 | # Build the oran-inf-host image |
| 149 | mkdir -p logs |
| 150 | TIMESTAMP=`date +"%Y%m%d_%H%M%S"` |
Jackie Huang | 6d582c5 | 2019-11-01 15:28:47 +0800 | [diff] [blame] | 151 | RUN_CMD="bitbake ${DRYRUN} oran-image-inf-host" |
| 152 | echo_cmd "Build the oran-image-inf-host image" |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 153 | 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] | 154 | |
| 155 | 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" |