3 # Copyright (C) 2022 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 SCRIPTS_DIR=$(dirname $(readlink -f $0))
25 SCRIPTS_NAME=$(basename $0)
26 TIMESTAMP=`date +"%Y%m%d_%H%M%S"`
28 #########################################################################
30 #########################################################################
35 This is a wrapper script to build both Yocto based and CentOS based images
36 with default options, and tend to be used by ORAN CI build only.
38 ${SCRIPTS_NAME} [-w WORKSPACE_DIR] [-n] [-h]
40 -w WORKSPACE_DIR is the path for the project
41 -n dry-run only for bitbake
50 [ -n "$1" ] && msg_step=$1
51 echo "#########################################################################################"
52 echo "## ${SCRIPTS_NAME} - STEP START: ${msg_step}"
53 echo "#########################################################################################"
57 [ -n "$1" ] && msg_step=$1
58 echo "#########################################################################################"
59 echo "## ${SCRIPTS_NAME} - STEP END: ${msg_step}"
60 echo "#########################################################################################"
75 echo "CMD: ${RUN_CMD}"
79 #########################################################################
81 #########################################################################
89 while getopts "w:ycdnh" OPTION; do
92 WORKSPACE=`readlink -f ${OPTARG}`
114 if [ -z ${WORKSPACE} ]; then
115 echo_info "No workspace specified, a directory 'workspace' will be created in current directory as the workspace"
116 WORKSPACE=`readlink -f workspace`
119 #########################################################################
120 # Functions for each step
121 #########################################################################
122 WORKSPACE_YP=${WORKSPACE}/workspace_yocto
123 WORKSPACE_CENTOS=${WORKSPACE}/workspace_centos
124 WORKSPACE_DEB=${WORKSPACE}/workspace_debian
125 SCRIPT_YP=${SCRIPTS_DIR}/build_inf_yocto/build_inf_yocto.sh
126 SCRIPT_CENTOS=${SCRIPTS_DIR}/build_inf_centos/build_inf_centos.sh
127 SCRIPT_CENTOS_PRE=${SCRIPTS_DIR}/build_inf_centos/build_inf_prepare_jenkins.sh
128 SCRIPT_DEB=${SCRIPTS_DIR}/build_inf_debian/build_inf_debian.sh
129 SCRIPT_DEB_PRE=${SCRIPTS_DIR}/build_inf_debian/build_inf_prepare_jenkins.sh
131 prepare_workspace () {
132 msg_step="Create workspace for the multi-os builds"
135 mkdir -p ${WORKSPACE_YP} ${WORKSPACE_CENTOS} ${WORKSPACE_DEB}
137 echo_info "The following directories are created in your workspace(${WORKSPACE}):"
138 echo_info "For Yocto buid: ${WORKSPACE_YP}"
139 echo_info "For CentOS buid: ${WORKSPACE_CENTOS}"
140 echo_info "For Debian buid: ${WORKSPACE_DEB}"
145 # debug for CI Jenkins build
147 msg_step="Get debug info for CI Jenkins build"
150 echo_info "=== Get env ==="
152 echo_info "==============="
170 msg_step="Yocto builds"
173 RUN_CMD="${SCRIPT_YP} -w ${WORKSPACE_YP} ${DRYRUN} ${YP_ARGS}"
174 run_cmd "Start Yocto builds"
180 # dry-run is not supported yet for CentOS build
181 if [ -z "${DRYRUN}" ]; then
182 msg_step="CentOS builds"
185 if [ "$CI" = "true" ]; then
186 RUN_CMD="${SCRIPT_CENTOS_PRE} -w ${WORKSPACE_CENTOS}"
187 run_cmd "Prepare for CentOS builds"
189 RUN_CMD="${SCRIPT_CENTOS} -w ${WORKSPACE_CENTOS} -m ${DRYRUN}"
190 run_cmd "Start CentOS builds"
197 if [ -z "${DRYRUN}" ]; then
198 msg_step="Debian builds"
201 if [ "$CI" = "true" ]; then
202 RUN_CMD="${SCRIPT_DEB_PRE} -w ${WORKSPACE_DEB}"
203 run_cmd "Prepare for Debian builds"
206 RUN_CMD="${SCRIPT_DEB} -w ${WORKSPACE_DEB} -m ${DRYRUN}"
207 run_cmd "Start Debian builds"
214 #########################################################################
216 #########################################################################
219 if [ "$CI" = "true" ]; then
223 if [ "${YOCTO_ONLY}" == "Yes" ]; then
225 elif [ "${CENTOS_ONLY}" == "Yes" ]; then
227 elif [ "${DEBIAN_ONLY}" == "Yes" ]; then