3 # Copyright (C) 2019 Wind River Systems, Inc.
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 # Ensure we fail the job if any steps fail.
20 #########################################################################
22 #########################################################################
24 # Only one bsp is supported now, there will be more in the future
25 SUPPORTED_BSP="intel-corei7-64 "
27 SRC_ORAN_BRANCH="master"
28 SRC_STX_BRANCH="master"
29 SRC_YP_BRANCH="warrior"
31 SRC_ORAN_URL="https://gerrit.o-ran-sc.org/r/pti/rtp"
34 git://git.yoctoproject.org/poky \
35 git://git.openembedded.org/meta-openembedded \
36 git://git.yoctoproject.org/meta-virtualization \
37 git://git.yoctoproject.org/meta-cloud-services \
38 git://git.yoctoproject.org/meta-security \
39 git://git.yoctoproject.org/meta-intel \
40 git://git.yoctoproject.org/meta-selinux \
41 https://github.com/intel-iot-devkit/meta-iot-cloud \
42 git://git.openembedded.org/meta-python2 \
43 https://git.yoctoproject.org/git/meta-dpdk \
44 git://git.yoctoproject.org/meta-anaconda \
59 SUB_LAYER_META_CLOUD_SERVICES="meta-openstack"
60 SUB_LAYER_META_SECURITY="meta-security-compliance"
63 SUB_LAYER_META_OE_ANACONDA="\
72 SCRIPTS_DIR=$(dirname $(readlink -f $0))
73 TIMESTAMP=`date +"%Y%m%d_%H%M%S"`
75 #########################################################################
77 #########################################################################
82 $(basename $0) [-w WORKSPACE_DIR] [-b BSP] [-n] [-h] [-r Yes|No] [-s] [-e EXTRA_CONF]
84 -w WORKSPACE_DIR is the path for the project
85 -b BPS is one of supported BSP: "${SUPPORTED_BSP}"
86 (default is intel-corei7-64 if not specified.)
87 -n dry-run only for bitbake
89 -e EXTRA_CONF is the pat for extra config file
90 -r whether to inherit rm_work (default is Yes)
91 -s whether to skip update the repo if already exists
94 $0 -w workspace_1234 -r no -e /path/to/extra_local.conf
99 [ -n "$1" ] && msg_step=$1
100 echo "#########################################################################################"
101 echo "## STEP START: ${msg_step}"
102 echo "#########################################################################################"
106 [ -n "$1" ] && msg_step=$1
107 echo "#########################################################################################"
108 echo "## STEP END: ${msg_step}"
109 echo "#########################################################################################"
124 echo "CMD: ${RUN_CMD}"
127 check_yn_rm_work () {
137 echo "Invalid arg for -r option."
146 for b in ${SUPPORTED_BSP}; do
147 if [ "${bsp}" == "${b}" ]; then
152 if [ -z "${BSP_VALID}" ]; then
153 echo_error "${bsp} is not a supported BSP, the supported BSPs are: ${SUPPORTED_BSP}"
159 clone_update_repo () {
164 if [ -d ${REPO_NAME}/.git ]; then
165 if [ "${SKIP_UPDATE}" == "Yes" ]; then
166 echo_info "The repo ${REPO_NAME} exists, skip updating for the branch ${REPO_BRANCH}"
168 echo_info "The repo ${REPO_NAME} exists, updating for the branch ${REPO_BRANCH}"
170 git checkout ${REPO_BRANCH}
175 RUN_CMD="git clone --branch ${REPO_BRANCH} ${REPO_URL} ${REPO_NAME}"
176 echo_cmd "Cloning the source of repo '${REPO_NAME}':"
183 cd ${SRC_LAYER_DIR}/poky
185 source ./oe-init-build-env ${build_dir}
188 #########################################################################
190 #########################################################################
196 BSP="intel-corei7-64"
198 while getopts "w:b:e:r:nsh" OPTION; do
201 WORKSPACE=`readlink -f ${OPTARG}`
204 check_valid_bsp ${OPTARG}
207 EXTRA_CONF=`readlink -f ${OPTARG}`
216 check_yn_rm_work ${OPTARG}
225 if [ -z ${WORKSPACE} ]; then
226 echo_info "No workspace specified, a directory 'workspace' will be created in current directory as the workspace"
227 WORKSPACE=`readlink -f workspace`
230 if [ -n "${BSP_VALID}" ]; then
234 #########################################################################
235 # Functions for each step
236 #########################################################################
237 SRC_LAYER_DIR=${WORKSPACE}/src_layers
238 SRC_ORAN_DIR=${SRC_LAYER_DIR}/oran
239 PRJ_BUILD_DIR=${WORKSPACE}/prj_oran_stx
240 PRJ_BUILD_DIR_ANACONDA=${WORKSPACE}/prj_oran_inf_anaconda
241 PRJ_SHARED_DIR=${WORKSPACE}/prj_shared
242 PRJ_SHARED_DL_DIR=${WORKSPACE}/prj_shared/downloads
243 PRJ_SHARED_SS_DIR=${WORKSPACE}/prj_shared/sstate-cache
244 SRC_META_PATCHES=${SRC_ORAN_DIR}/rtp/scripts/meta-patches/src_stx
245 SRC_CONFIGS=${SRC_ORAN_DIR}/rtp/scripts/configs
246 IMG_STX=stx-image-aio
247 IMG_ANACONDA=stx-image-aio-installer
248 IMG_INF=inf-image-aio-installer
249 ISO_STX=${PRJ_BUILD_DIR}/tmp/deploy/images/${BSP}/${IMG_STX}-${BSP}.iso
250 ISO_ANACONDA=${PRJ_BUILD_DIR_ANACONDA}/tmp-glibc/deploy/images/${BSP}/${IMG_ANACONDA}-${BSP}.iso
251 ISO_INF=${PRJ_BUILD_DIR_ANACONDA}/tmp-glibc/deploy/images/${BSP}/${IMG_INF}-${BSP}.iso
253 prepare_workspace () {
254 msg_step="Create workspace for the build"
257 mkdir -p ${PRJ_BUILD_DIR} ${SRC_ORAN_DIR} ${PRJ_BUILD_DIR_ANACONDA} ${PRJ_SHARED_DL_DIR} ${PRJ_SHARED_SS_DIR}
259 echo_info "The following directories are created in your workspace(${WORKSPACE}):"
260 echo_info "For all layers source: ${SRC_LAYER_DIR}"
261 echo_info "For StarlingX build project: ${PRJ_BUILD_DIR}"
262 echo_info "For anaconda (installer) build project: ${PRJ_BUILD_DIR_ANACONDA}"
268 msg_step="Get the source code repos"
271 # Clone the oran layer if it's not already cloned
272 # Check if the script is inside the repo
273 if cd ${SCRIPTS_DIR} && git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
274 CLONED_ORAN_REPO=`dirname ${SCRIPTS_DIR}`
275 echo_info "Use the cloned oran repo: ${CLONED_ORAN_REPO}"
276 mkdir -p ${SRC_ORAN_DIR}/rtp
277 cd ${SRC_ORAN_DIR}/rtp
278 rm -rf meta-oran meta-stx scripts
279 ln -sf ${CLONED_ORAN_REPO}/meta-oran meta-oran
280 ln -sf ${CLONED_ORAN_REPO}/meta-stx meta-stx
281 ln -sf ${CLONED_ORAN_REPO}/scripts scripts
283 echo_info "Cloning oran layer:"
285 clone_update_repo ${SRC_ORAN_BRANCH} ${SRC_ORAN_URL} rtp
288 echo_info "Cloning or update Yocto layers:"
291 for layer_url in ${SRC_YP_URL}; do
292 layer_name=$(basename ${layer_url})
293 clone_update_repo ${SRC_YP_BRANCH} ${layer_url} ${layer_name}
299 for l in $(ls -1 ${SRC_META_PATCHES}); do
300 msg_step="Apply meta patches for ${l}"
302 cd ${SRC_LAYER_DIR}/${l}
304 # backup current branch
305 local_branch=$(git rev-parse --abbrev-ref HEAD)
306 git branch -m "${local_branch}_${TIMESTAMP}"
307 git checkout ${local_branch}
309 for p in $(ls -1 ${SRC_META_PATCHES}/${l}); do
310 echo_info "Apllying patch: ${SRC_META_PATCHES}/${l}/${p}"
311 git am ${SRC_META_PATCHES}/${l}/${p}
317 add_layer_stx_build () {
318 msg_step="Add required layers to the StarlingX build project"
321 source_env ${PRJ_BUILD_DIR}
323 for layer_url in ${SRC_YP_URL}; do
324 layer_name=$(basename ${layer_url})
325 case ${layer_name} in
330 for sub_layer in ${SUB_LAYER_META_OE}; do
331 SRC_LAYERS="${SRC_LAYERS} ${SRC_LAYER_DIR}/${layer_name}/${sub_layer}"
335 SRC_LAYERS="${SRC_LAYERS} ${SRC_LAYER_DIR}/${layer_name}"
336 for sub_layer in ${SUB_LAYER_META_CLOUD_SERVICES}; do
337 SRC_LAYERS="${SRC_LAYERS} ${SRC_LAYER_DIR}/${layer_name}/${sub_layer}"
341 SRC_LAYERS="${SRC_LAYERS} ${SRC_LAYER_DIR}/${layer_name}"
342 for sub_layer in ${SUB_LAYER_META_SECURITY}; do
343 SRC_LAYERS="${SRC_LAYERS} ${SRC_LAYER_DIR}/${layer_name}/${sub_layer}"
347 SRC_LAYERS="${SRC_LAYERS} ${SRC_LAYER_DIR}/${layer_name}"
353 SRC_LAYERS="${SRC_LAYERS} ${SRC_ORAN_DIR}/rtp/meta-stx"
355 for src_layer in ${SRC_LAYERS}; do
356 RUN_CMD="bitbake-layers add-layer ${src_layer}"
357 echo_cmd "Add the ${src_layer} layer into the build project"
364 add_configs_stx_build () {
365 msg_step="Add extra configs into local.conf for StarlingX build"
369 echo_info "Adding the following extra configs into local.conf"
370 cat ${SRC_CONFIGS}/local-stx.conf | \
371 sed -e "s/@BSP@/${BSP}/" | tee -a conf/local.conf
373 echo "DL_DIR = '${PRJ_SHARED_DL_DIR}'" | tee -a conf/local.conf
374 echo "SSTATE_DIR = '${PRJ_SHARED_SS_DIR}'" | tee -a conf/local.conf
376 if [ "${RM_WORK}" == "Yes" ]; then
377 echo "INHERIT += 'rm_work'" | tee -a conf/local.conf
381 if [ "${EXTRA_CONF}" != "" ] && [ -f "${EXTRA_CONF}" ]; then
382 cat ${EXTRA_CONF} | tee -a conf/local.conf
388 echo_step_start "Setup StarlingX build project"
393 if ! grep -q 'Configs for StarlingX' conf/local.conf; then
394 add_configs_stx_build
396 echo_info "Nothing is added into local.conf"
399 echo_step_end "Setup StarlingX build project"
403 msg_step="Build StarlingX images"
406 source_env ${PRJ_BUILD_DIR}
410 RUN_CMD="bitbake ${DRYRUN} ${IMG_STX}"
411 echo_cmd "Build the ${IMG_STX} image"
412 bitbake ${DRYRUN} ${IMG_STX} 2>&1|tee logs/bitbake_${IMG_STX}_${TIMESTAMP}.log
416 echo_info "Build succeeded, you can get the image in ${ISO_STX}"
419 add_layer_anaconda_build () {
420 msg_step="Add required layers to the anaconda (installer) build project"
423 source_env ${PRJ_BUILD_DIR_ANACONDA}
425 for sub_layer in ${SUB_LAYER_META_OE_ANACONDA}; do
426 SRC_LAYERS="${SRC_LAYERS} ${SRC_LAYER_DIR}/meta-openembedded/${sub_layer}"
428 SRC_LAYERS="${SRC_LAYERS} ${SRC_LAYER_DIR}/meta-intel"
429 SRC_LAYERS="${SRC_LAYERS} ${SRC_LAYER_DIR}/meta-anaconda"
430 SRC_LAYERS="${SRC_LAYERS} ${SRC_ORAN_DIR}/rtp/meta-stx"
432 for src_layer in ${SRC_LAYERS}; do
433 RUN_CMD="bitbake-layers add-layer ${src_layer}"
434 echo_cmd "Add the ${src_layer} layer into the build project"
441 add_configs_anaconda_build () {
442 msg_step="Add extra configs into local.conf for anaconda (installer) build"
445 cd ${PRJ_BUILD_DIR_ANACONDA}
446 echo_info "Adding the following extra configs into local.conf"
447 cat ${SRC_CONFIGS}/local-anaconda.conf | \
448 sed -e "s/@BSP@/${BSP}/" \
449 -e "s|@TARGET_BUILD@|${PRJ_BUILD_DIR}|" \
450 | tee -a conf/local.conf
452 echo "DL_DIR = '${PRJ_SHARED_DL_DIR}'" | tee -a conf/local.conf
453 echo "SSTATE_DIR = '${PRJ_SHARED_SS_DIR}'" | tee -a conf/local.conf
455 if [ "${RM_WORK}" == "Yes" ]; then
456 echo "INHERIT += 'rm_work'" | tee -a conf/local.conf
459 if [ "${EXTRA_CONF}" != "" ] && [ -f "${EXTRA_CONF}" ]; then
460 cat ${EXTRA_CONF} | tee -a conf/local.conf
466 setup_anaconda_build () {
467 echo_step_start "Setup anaconda (installer) build project"
469 add_layer_anaconda_build
471 cd ${PRJ_BUILD_DIR_ANACONDA}
472 if ! grep -q 'Configs for anaconda' conf/local.conf; then
473 add_configs_anaconda_build
475 echo_info "Nothing is added into local.conf"
478 echo_step_end "Setup anaconda build project"
481 build_anaconda_image () {
482 echo_step_start "Build anaconda (installer) images"
483 source_env ${PRJ_BUILD_DIR_ANACONDA}
487 if [ -f ${ISO_ANACONDA} ]; then
488 bitbake ${DRYRUN} -c clean ${IMG_ANACONDA}
490 RUN_CMD="bitbake ${DRYRUN} ${IMG_ANACONDA}"
491 echo_cmd "Build the ${IMG_ANACONDA} image"
492 bitbake ${DRYRUN} ${IMG_ANACONDA} 2>&1|tee logs/bitbake_${IMG_ANACONDA}_${TIMESTAMP}.log
494 if [ -z "${DRYRUN}" ]; then
495 cp -Pf ${ISO_ANACONDA} ${ISO_INF}
500 echo_info "Build succeeded, you can get the image in ${ISO_INF}"
503 #########################################################################
505 #########################################################################