Jackie Huang | b5105bb | 2019-10-16 14:53:59 +0800 | [diff] [blame^] | 1 | #!/bin/bash |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 2 | |
| 3 | help_info () { |
| 4 | cat << ENDHELP |
| 5 | Usage: |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 6 | $(basename $0) <-w WORKSPACE_DIR> [-n] [-h] |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 7 | where: |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 8 | -w WORKSPACE_DIR is the path for the project |
| 9 | -n dry-run only for bitbake |
| 10 | -h this help info |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 11 | ENDHELP |
| 12 | } |
| 13 | |
| 14 | echo_info () { |
| 15 | echo "INFO: $1" |
| 16 | } |
| 17 | |
| 18 | echo_error () { |
| 19 | echo "ERROR: $1" |
| 20 | } |
| 21 | |
| 22 | echo_cmd () { |
| 23 | echo |
| 24 | echo "$1" |
| 25 | echo "CMD: ${RUN_CMD}" |
| 26 | } |
| 27 | |
| 28 | if [ $# -eq 0 ]; then |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 29 | echo "Missing options!" |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 30 | help_info |
| 31 | exit |
| 32 | fi |
| 33 | |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 34 | DRYRUN="" |
| 35 | |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 36 | SCRIPTS_DIR=`dirname $0` |
| 37 | SCRIPTS_DIR=`readlink -f $SCRIPTS_DIR` |
| 38 | |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 39 | while getopts "w:nh" OPTION; do |
| 40 | case ${OPTION} in |
| 41 | w) |
| 42 | WORKSPACE=`readlink -f ${OPTARG}` |
| 43 | ;; |
| 44 | n) |
| 45 | DRYRUN="-n" |
| 46 | ;; |
| 47 | h) |
| 48 | help_info |
| 49 | exit |
| 50 | ;; |
| 51 | esac |
| 52 | done |
| 53 | |
| 54 | if [ -z ${WORKSPACE} ]; then |
| 55 | echo_info "No workspace specified, a directory 'workspace' will be created in current directory as the workspace" |
| 56 | WORKSPACE=`readlink -f workspace` |
| 57 | fi |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 58 | |
| 59 | SRC_WRL_DIR=${WORKSPACE}/src_wrl1018 |
| 60 | SRC_ORAN_DIR=${WORKSPACE}/src_oran |
| 61 | PRJ_BUILD_DIR=${WORKSPACE}/prj_oran-inf |
| 62 | |
| 63 | mkdir -p ${SRC_WRL_DIR} ${PRJ_BUILD_DIR} ${SRC_ORAN_DIR} |
| 64 | |
| 65 | echo_info "The following directories are created in your workspace(${WORKSPACE}):" |
| 66 | echo_info "For wrlinux1018 source: ${SRC_WRL_DIR}" |
| 67 | echo_info "For oran layer source: ${SRC_ORAN_DIR}" |
| 68 | echo_info "For build project: ${PRJ_BUILD_DIR}" |
| 69 | |
| 70 | # Clone the source of WRLinux BASE 10.18 from github and setup |
| 71 | RUN_CMD="git clone --branch WRLINUX_10_18_BASE git://github.com/WindRiver-Labs/wrlinux-x.git" |
| 72 | echo_cmd "Cloning wrlinux 1018 source from github:" |
| 73 | cd ${SRC_WRL_DIR} |
| 74 | ${RUN_CMD} |
| 75 | |
Jackie Huang | da071f8 | 2019-09-30 14:33:27 +0800 | [diff] [blame] | 76 | 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] | 77 | echo_cmd "Setup wrlinux build project:" |
| 78 | ${RUN_CMD} |
| 79 | |
| 80 | # Clone extra layers |
| 81 | echo_info "Cloning oran layer:" |
| 82 | |
| 83 | cd ${SRC_ORAN_DIR} |
Jackie Huang | 477f99a | 2019-10-09 20:52:26 +0800 | [diff] [blame] | 84 | RUN_CMD="git clone https://gerrit.o-ran-sc.org/r/pti/rtp" |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 85 | echo_cmd "Cloing with:" |
| 86 | ${RUN_CMD} |
| 87 | |
| 88 | # Source the build env |
| 89 | cd ${SRC_WRL_DIR} |
| 90 | . ./environment-setup-x86_64-wrlinuxsdk-linux |
| 91 | set ${PRJ_BUILD_DIR} |
| 92 | . ./oe-init-build-env ${PRJ_BUILD_DIR} |
| 93 | |
| 94 | # Add the meta-oran layer and required layers |
| 95 | cd ${PRJ_BUILD_DIR} |
Jackie Huang | 477f99a | 2019-10-09 20:52:26 +0800 | [diff] [blame] | 96 | bitbake-layers add-layer ${SRC_ORAN_DIR}/rtp/meta-oran |
Jackie Huang | 90b87ff | 2019-09-30 13:36:48 +0800 | [diff] [blame] | 97 | |
| 98 | # Add extra configs into local.conf |
| 99 | cat << EOF >> conf/local.conf |
| 100 | ######################## |
| 101 | # Configs for oran-inf # |
| 102 | ######################## |
| 103 | DISTRO = "oran-inf" |
| 104 | BB_NO_NETWORK = '0' |
| 105 | EOF |
| 106 | |
| 107 | # Build the oran-inf-host image |
| 108 | mkdir -p logs |
| 109 | TIMESTAMP=`date +"%Y%m%d_%H%M%S"` |
Jackie Huang | b5105bb | 2019-10-16 14:53:59 +0800 | [diff] [blame^] | 110 | set -o pipefail |
Jackie Huang | be9f4e2 | 2019-10-16 10:02:00 +0800 | [diff] [blame] | 111 | bitbake ${DRYRUN} oran-image-inf-host 2>&1|tee logs/bitbake_oran-image-inf-host_${TIMESTAMP}.log |