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"
33 SRC_STX_URL="https://opendev.org/starlingx/meta-starlingx"
36 git://git.yoctoproject.org/poky;commit=HEAD \
37 git://git.openembedded.org/meta-openembedded;commit=HEAD \
38 git://git.openembedded.org/meta-python2;commit=HEAD \
39 git://git.yoctoproject.org/meta-virtualization;commit=HEAD \
40 git://git.yoctoproject.org/meta-cloud-services;commit=HEAD \
41 git://git.yoctoproject.org/meta-security;commit=HEAD \
42 git://git.yoctoproject.org/meta-intel;commit=HEAD \
43 git://git.yoctoproject.org/meta-selinux;commit=HEAD \
44 git://git.yoctoproject.org/meta-dpdk;commit=HEAD \
45 git://git.yoctoproject.org/meta-anaconda;commit=HEAD \
46 https://github.com/intel-iot-devkit/meta-iot-cloud.git;commit=HEAD \
61 SUB_LAYER_META_CLOUD_SERVICES="meta-openstack"
71 SUB_LAYER_META_OE_ANACONDA="\
80 SCRIPTS_DIR=$(dirname $(dirname $(readlink -f $0)))
81 TIMESTAMP=`date +"%Y%m%d_%H%M%S"`
83 #########################################################################
85 #########################################################################
90 $(basename $0) [-w WORKSPACE_DIR] [-b BSP] [-n] [-u] [-h] [-r Yes|No] [-e EXTRA_CONF]
92 -w WORKSPACE_DIR is the path for the project
93 -b BPS is one of supported BSP: "${SUPPORTED_BSP}"
94 (default is intel-corei7-64 if not specified.)
95 -n dry-run only for bitbake
96 -u update the repo if it exists
98 -e EXTRA_CONF is the pat for extra config file
99 -r whether to inherit rm_work (default is Yes)
102 $0 -w workspace_1234 -r no -e /path/to/extra_local.conf
107 [ -n "$1" ] && msg_step=$1
108 echo "#########################################################################################"
109 echo "## STEP START: ${msg_step}"
110 echo "#########################################################################################"
114 [ -n "$1" ] && msg_step=$1
115 echo "#########################################################################################"
116 echo "## STEP END: ${msg_step}"
117 echo "#########################################################################################"
132 echo "CMD: ${RUN_CMD}"
135 check_yn_rm_work () {
145 echo "Invalid arg for -r option."
154 for b in ${SUPPORTED_BSP}; do
155 if [ "${bsp}" == "${b}" ]; then
160 if [ -z "${BSP_VALID}" ]; then
161 echo_error "${bsp} is not a supported BSP, the supported BSPs are: ${SUPPORTED_BSP}"
167 clone_update_repo () {
173 if [ -d ${REPO_NAME}/.git ]; then
174 if [ "${SKIP_UPDATE}" == "Yes" ]; then
175 echo_info "The repo ${REPO_NAME} exists, skip updating for the branch ${REPO_BRANCH}"
177 echo_info "The repo ${REPO_NAME} exists, updating for the branch ${REPO_BRANCH}"
179 git checkout ${REPO_BRANCH}
184 RUN_CMD="git clone --branch ${REPO_BRANCH} ${REPO_URL} ${REPO_NAME}"
185 echo_cmd "Cloning the source of repo '${REPO_NAME}':"
188 if [ -n "${REPO_COMMIT}" ]; then
190 RUN_CMD="git checkout -b ${REPO_BRANCH}-${REPO_COMMIT} ${REPO_COMMIT}"
191 echo_cmd "Checkout the repo ${REPO_NAME} to specific commit: ${REPO_COMMIT}"
200 cd ${SRC_LAYER_DIR}/poky
202 source ./oe-init-build-env ${build_dir}
205 #########################################################################
207 #########################################################################
213 BSP="intel-corei7-64"
215 while getopts "w:b:e:r:unh" OPTION; do
218 WORKSPACE=`readlink -f ${OPTARG}`
221 check_valid_bsp ${OPTARG}
224 EXTRA_CONF=`readlink -f ${OPTARG}`
233 check_yn_rm_work ${OPTARG}
242 if [ -z ${WORKSPACE} ]; then
243 echo_info "No workspace specified, a directory 'workspace' will be created in current directory as the workspace"
244 WORKSPACE=`readlink -f workspace`
247 if [ -n "${BSP_VALID}" ]; then
251 #########################################################################
252 # Functions for each step
253 #########################################################################
254 SRC_LAYER_DIR=${WORKSPACE}/src_layers
255 SRC_ORAN_DIR=${SRC_LAYER_DIR}/oran
256 SRC_STX_DIR=${SRC_LAYER_DIR}/meta-starlingx
257 PRJ_BUILD_DIR=${WORKSPACE}/prj_oran_stx
258 PRJ_BUILD_DIR_ANACONDA=${WORKSPACE}/prj_oran_inf_anaconda
259 PRJ_SHARED_DIR=${WORKSPACE}/prj_shared
260 PRJ_SHARED_DL_DIR=${WORKSPACE}/prj_shared/downloads
261 PRJ_SHARED_SS_DIR=${WORKSPACE}/prj_shared/sstate-cache
262 SRC_SCRIPTS=${SRC_ORAN_DIR}/rtp/scripts/build_inf_yocto
263 SRC_META_PATCHES=${SRC_SCRIPTS}/meta-patches/src_stx
264 SRC_CONFIGS=${SRC_SCRIPTS}/configs
265 IMG_STX=stx-image-aio
266 IMG_ANACONDA=stx-image-aio-installer
267 IMG_INF=inf-image-aio-installer
268 ISO_STX=${PRJ_BUILD_DIR}/tmp/deploy/images/${BSP}/${IMG_STX}-${BSP}.iso
269 ISO_ANACONDA=${PRJ_BUILD_DIR_ANACONDA}/tmp-glibc/deploy/images/${BSP}/${IMG_ANACONDA}-${BSP}.iso
270 ISO_INF=${PRJ_BUILD_DIR_ANACONDA}/tmp-glibc/deploy/images/${BSP}/${IMG_INF}-${BSP}.iso
272 prepare_workspace () {
273 msg_step="Create workspace for the build"
276 mkdir -p ${PRJ_BUILD_DIR} ${SRC_ORAN_DIR} ${PRJ_BUILD_DIR_ANACONDA} ${PRJ_SHARED_DL_DIR} ${PRJ_SHARED_SS_DIR}
278 echo_info "The following directories are created in your workspace(${WORKSPACE}):"
279 echo_info "For all layers source: ${SRC_LAYER_DIR}"
280 echo_info "For StarlingX build project: ${PRJ_BUILD_DIR}"
281 echo_info "For anaconda (installer) build project: ${PRJ_BUILD_DIR_ANACONDA}"
287 msg_step="Get the source code repos"
290 # Clone the oran layer if it's not already cloned
291 # Check if the script is inside the repo
292 if cd ${SCRIPTS_DIR} && git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
293 CLONED_ORAN_REPO=`dirname ${SCRIPTS_DIR}`
294 echo_info "Use the cloned oran repo: ${CLONED_ORAN_REPO}"
295 mkdir -p ${SRC_ORAN_DIR}/rtp
296 cd ${SRC_ORAN_DIR}/rtp
297 rm -rf meta-stx-oran scripts
298 ln -sf ${CLONED_ORAN_REPO}/scripts scripts
299 ln -sf ${CLONED_ORAN_REPO}/meta-stx-oran meta-stx-oran
301 echo_info "Cloning oran layer:"
303 clone_update_repo ${SRC_ORAN_BRANCH} ${SRC_ORAN_URL} rtp
306 echo_info "Cloning or update Yocto layers:"
309 for layer_url in ${SRC_YP_URL}; do
310 layer_name=$(basename ${layer_url%%;commit*})
311 layer_commit=$(basename ${layer_url##*;commit=})
312 clone_update_repo ${SRC_YP_BRANCH} ${layer_url%%;commit*} ${layer_name} ${layer_commit}
315 echo_info "Cloning or update meta-starlingx layers:"
316 clone_update_repo ${SRC_STX_BRANCH} ${SRC_STX_URL} $(basename ${SRC_STX_URL})
320 # Not andy meta-patch is needed for the time being, but new ones may be needed and added
321 # sometime in the future, so just leave these code commented out here.
322 # # Apply meta patches
323 # for l in $(ls -1 ${SRC_META_PATCHES}); do
324 # msg_step="Apply meta patches for ${l}"
326 # cd ${SRC_LAYER_DIR}/${l}
328 # # backup current branch
329 # local_branch=$(git rev-parse --abbrev-ref HEAD)
330 # git branch -m "${local_branch}_${TIMESTAMP}"
331 # git checkout -b ${local_branch} ${local_branch##*-}
333 # for p in $(ls -1 ${SRC_META_PATCHES}/${l}); do
334 # echo_info "Apllying patch: ${SRC_META_PATCHES}/${l}/${p}"
335 # git am ${SRC_META_PATCHES}/${l}/${p}
341 add_layer_stx_build () {
342 msg_step="Add required layers to the StarlingX build project"
345 source_env ${PRJ_BUILD_DIR}
347 for layer_url in ${SRC_YP_URL} ${SRC_STX_URL}; do
348 layer_name=$(basename ${layer_url%%;commit*})
349 case ${layer_name} in
354 for sub_layer in ${SUB_LAYER_META_OE}; do
355 SRC_LAYERS="${SRC_LAYERS} ${SRC_LAYER_DIR}/${layer_name}/${sub_layer}"
359 SRC_LAYERS="${SRC_LAYERS} ${SRC_LAYER_DIR}/${layer_name}"
360 for sub_layer in ${SUB_LAYER_META_CLOUD_SERVICES}; do
361 SRC_LAYERS="${SRC_LAYERS} ${SRC_LAYER_DIR}/${layer_name}/${sub_layer}"
365 for sub_layer in ${SUB_LAYER_STX}; do
366 SRC_LAYERS="${SRC_LAYERS} ${SRC_STX_DIR}/${sub_layer}"
370 SRC_LAYERS="${SRC_LAYERS} ${SRC_LAYER_DIR}/${layer_name}"
375 SRC_LAYERS="${SRC_LAYERS} ${SRC_ORAN_DIR}/rtp/meta-stx-oran"
378 for src_layer in ${SRC_LAYERS}; do
379 RUN_CMD="bitbake-layers add-layer ${src_layer}"
380 echo_cmd "Add the ${src_layer} layer into the build project"
387 add_configs_stx_build () {
388 msg_step="Add extra configs into local.conf for StarlingX build"
392 echo_info "Adding the following extra configs into local.conf"
393 cat ${SRC_CONFIGS}/local-stx.conf | \
394 sed -e "s/@BSP@/${BSP}/" | tee -a conf/local.conf
395 cat ${SRC_CONFIGS}/local-mirrors.conf | tee -a conf/local.conf
397 echo "DL_DIR = '${PRJ_SHARED_DL_DIR}'" | tee -a conf/local.conf
398 echo "SSTATE_DIR = '${PRJ_SHARED_SS_DIR}'" | tee -a conf/local.conf
400 if [ "${RM_WORK}" == "Yes" ]; then
401 echo "INHERIT += 'rm_work'" | tee -a conf/local.conf
402 echo "RM_WORK_EXCLUDE += '${IMG_STX}'" | tee -a conf/local.conf
406 if [ "${EXTRA_CONF}" != "" ] && [ -f "${EXTRA_CONF}" ]; then
407 cat ${EXTRA_CONF} | tee -a conf/local.conf
413 echo_step_start "Setup StarlingX build project"
418 if ! grep -q 'Configs for StarlingX' conf/local.conf; then
419 add_configs_stx_build
421 echo_info "Nothing is added into local.conf"
424 echo_step_end "Setup StarlingX build project"
428 msg_step="Build StarlingX images"
431 source_env ${PRJ_BUILD_DIR}
435 RUN_CMD="bitbake ${DRYRUN} ${IMG_STX}"
436 echo_cmd "Build the ${IMG_STX} image"
437 bitbake ${DRYRUN} ${IMG_STX} 2>&1|tee logs/bitbake_${IMG_STX}_${TIMESTAMP}.log
441 echo_info "Build succeeded, you can get the image in ${ISO_STX}"
444 add_layer_anaconda_build () {
445 msg_step="Add required layers to the anaconda (installer) build project"
448 source_env ${PRJ_BUILD_DIR_ANACONDA}
450 for sub_layer in ${SUB_LAYER_META_OE_ANACONDA}; do
451 SRC_LAYERS="${SRC_LAYERS} ${SRC_LAYER_DIR}/meta-openembedded/${sub_layer}"
453 SRC_LAYERS="${SRC_LAYERS} ${SRC_LAYER_DIR}/meta-intel"
454 SRC_LAYERS="${SRC_LAYERS} ${SRC_LAYER_DIR}/meta-anaconda"
455 SRC_LAYERS="${SRC_LAYERS} ${SRC_STX_DIR}/meta-stx-distro"
456 SRC_LAYERS="${SRC_LAYERS} ${SRC_STX_DIR}/meta-stx-integ"
457 SRC_LAYERS="${SRC_LAYERS} ${SRC_ORAN_DIR}/rtp/meta-stx-oran"
459 for src_layer in ${SRC_LAYERS}; do
460 RUN_CMD="bitbake-layers add-layer ${src_layer}"
461 echo_cmd "Add the ${src_layer} layer into the build project"
468 add_configs_anaconda_build () {
469 msg_step="Add extra configs into local.conf for anaconda (installer) build"
472 cd ${PRJ_BUILD_DIR_ANACONDA}
473 echo_info "Adding the following extra configs into local.conf"
474 cat ${SRC_CONFIGS}/local-anaconda.conf | \
475 sed -e "s/@BSP@/${BSP}/" \
476 -e "s|@TARGET_BUILD@|${PRJ_BUILD_DIR}|" \
477 | tee -a conf/local.conf
478 cat ${SRC_CONFIGS}/local-mirrors.conf | tee -a conf/local.conf
480 echo "DL_DIR = '${PRJ_SHARED_DL_DIR}'" | tee -a conf/local.conf
481 echo "SSTATE_DIR = '${PRJ_SHARED_SS_DIR}'" | tee -a conf/local.conf
483 if [ "${RM_WORK}" == "Yes" ]; then
484 echo "INHERIT += 'rm_work'" | tee -a conf/local.conf
485 echo "RM_WORK_EXCLUDE += '${IMG_ANACONDA}'" | tee -a conf/local.conf
488 if [ "${EXTRA_CONF}" != "" ] && [ -f "${EXTRA_CONF}" ]; then
489 cat ${EXTRA_CONF} | tee -a conf/local.conf
495 setup_anaconda_build () {
496 echo_step_start "Setup anaconda (installer) build project"
498 add_layer_anaconda_build
500 cd ${PRJ_BUILD_DIR_ANACONDA}
501 if ! grep -q 'Configs for anaconda' conf/local.conf; then
502 add_configs_anaconda_build
504 echo_info "Nothing is added into local.conf"
507 echo_step_end "Setup anaconda build project"
510 build_anaconda_image () {
511 echo_step_start "Build anaconda (installer) images"
512 source_env ${PRJ_BUILD_DIR_ANACONDA}
516 if [ -f ${ISO_ANACONDA} ]; then
517 bitbake ${DRYRUN} -c clean ${IMG_ANACONDA}
519 RUN_CMD="bitbake ${DRYRUN} ${IMG_ANACONDA}"
520 echo_cmd "Build the ${IMG_ANACONDA} image"
521 bitbake ${DRYRUN} ${IMG_ANACONDA} 2>&1|tee logs/bitbake_${IMG_ANACONDA}_${TIMESTAMP}.log
523 if [ -z "${DRYRUN}" ]; then
524 cp -Pf ${ISO_ANACONDA} ${ISO_INF}
529 echo_info "Build succeeded, you can get the image in ${ISO_INF}"
532 #########################################################################
534 #########################################################################