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 SRC_ORAN_BRANCH="master"
26 SRC_ORAN_URL="https://gerrit.o-ran-sc.org/r/pti/rtp"
28 SCRIPTS_DIR=$(dirname $(readlink -f $0))
29 TIMESTAMP=`date +"%Y%m%d_%H%M%S"`
31 #########################################################################
33 #########################################################################
38 $(basename $0) [-w WORKSPACE_DIR] [-n] [-u] [-h]
40 -w WORKSPACE_DIR is the path for the project
41 -n dry-run only for bitbake
42 -u update the repo if it exists
51 [ -n "$1" ] && msg_step=$1
52 echo "#########################################################################################"
53 echo "## STEP START: ${msg_step}"
54 echo "#########################################################################################"
58 [ -n "$1" ] && msg_step=$1
59 echo "#########################################################################################"
60 echo "## STEP END: ${msg_step}"
61 echo "#########################################################################################"
76 echo "CMD: ${RUN_CMD}"
80 #########################################################################
82 #########################################################################
86 while getopts "w:b:e:r:unh" OPTION; do
89 WORKSPACE=`readlink -f ${OPTARG}`
104 if [ -z ${WORKSPACE} ]; then
105 echo_info "No workspace specified, a directory 'workspace' will be created in current directory as the workspace"
106 WORKSPACE=`readlink -f workspace`
109 #########################################################################
110 # Functions for each step
111 #########################################################################
112 PRJ_NAME=prj_oran_stx_centos
114 STX_SRC_BRANCH="r/stx.6.0"
115 STX_LOCAL_DIR=${WORKSPACE}/localdisk
116 STX_LOCAL_SRC_DIR=${STX_LOCAL_DIR}/designer/${USER}/${PRJ_NAME}
117 STX_LOCAL_PRJ_DIR=${STX_LOCAL_DIR}/loadbuild/${USER}/${PRJ_NAME}
118 STX_SRC_DIR=${WORKSPACE}/src
119 STX_PRJ_DIR=${WORKSPACE}/${PRJ_NAME}
120 STX_PRJ_OUTPUT=${WORKSPACE}/prj_output
121 STX_MIRROR_DIR=${WORKSPACE}/mirror
122 STX_MANIFEST_URL="https://opendev.org/starlingx/manifest"
124 prepare_workspace () {
125 msg_step="Create workspace for the build"
128 mkdir -p ${STX_LOCAL_SRC_DIR} ${STX_LOCAL_PRJ_DIR} ${STX_MIRROR_DIR} ${STX_PRJ_OUTPUT}
129 rm -f ${STX_SRC_DIR} ${STX_PRJ_DIR}
130 ln -sf ${STX_LOCAL_SRC_DIR} ${STX_SRC_DIR}
131 ln -sf ${STX_LOCAL_PRJ_DIR} ${STX_PRJ_DIR}
133 echo_info "The following directories are created in your workspace(${WORKSPACE}):"
134 echo_info "For all layers source: ${STX_SRC_DIR}"
135 echo_info "For StarlingX rpm mirror: ${STX_MIRROR_DIR}"
136 echo_info "For StarlingX build project: ${STX_PRJ_DIR}"
142 msg_step="Create env file for the build"
145 ENV_FILENAME=env.${PRJ_NAME}
147 cat <<EOF > ${WORKSPACE}/${ENV_FILENAME}
149 export STX_MIRROR_DIR=${STX_MIRROR_DIR}
151 #######################################
153 #######################################
155 export LC_ALL=en_US.UTF-8
156 export PROJECT=${PRJ_NAME}
157 export SRC_BUILD_ENVIRONMENT=tis-r6-pike
158 export MY_LOCAL_DISK=${STX_SRC_DIR}
159 export MY_REPO_ROOT_DIR=\${MY_LOCAL_DISK}
160 export MY_REPO=\${MY_REPO_ROOT_DIR}/cgcs-root
161 export CGCSDIR=\${MY_REPO}/stx
162 export MY_WORKSPACE=${WORKSPACE}/\${PROJECT}
163 export MY_BUILD_ENVIRONMENT=\${USER}-\${PROJECT}-\${SRC_BUILD_ENVIRONMENT}
164 export MY_BUILD_ENVIRONMENT_FILE=\${MY_BUILD_ENVIRONMENT}.cfg
165 export MY_BUILD_ENVIRONMENT_FILE_STD=\${MY_BUILD_ENVIRONMENT}-std.cfg
166 export MY_BUILD_ENVIRONMENT_FILE_RT=\${MY_BUILD_ENVIRONMENT}-rt.cfg
167 export MY_BUILD_ENVIRONMENT_FILE_STD_B0=\${MY_WORKSPACE}/std/configs/\${MY_BUILD_ENVIRONMENT}-std/\${MY_BUILD_ENVIRONMENT}-std.b0.cfg
168 export MY_BUILD_ENVIRONMENT_FILE_RT_B0=\${MY_WORKSPACE}/rt/configs/\${MY_BUILD_ENVIRONMENT}-rt/\${MY_BUILD_ENVIRONMENT}-rt.b0.cfg
169 export MY_BUILD_DIR=${WORKSPACE}/\${PROJECT}
170 export MY_SRC_RPM_BUILD_DIR=\${MY_BUILD_DIR}/rpmbuild
171 export MY_BUILD_CFG=\${MY_WORKSPACE}/\${MY_BUILD_ENVIRONMENT_FILE}
172 export MY_BUILD_CFG_STD=\${MY_WORKSPACE}/std/\${MY_BUILD_ENVIRONMENT_FILE_STD}
173 export MY_BUILD_CFG_RT=\${MY_WORKSPACE}/rt/\${MY_BUILD_ENVIRONMENT_FILE_RT}
174 export PATH=\${MY_REPO}/build-tools:\${MY_LOCAL_DISK}/bin:\${CGCSDIR}/stx-update/extras/scripts:\${PATH}
175 export CGCSPATCH_DIR=\${CGCSDIR}/stx-update/cgcs-patch
176 export BUILD_ISO_USE_UDEV=1
178 # WRCP/WRA/WRO do not support layered builds at this time.
181 # StarlingX since 4.0 supports layered builds (compiler, distro, flock) as an option.
182 # Note: Only flock layer builds an iso at this time.
183 # Note: You may leave LAYER="", this will build everything, also known as a 'monolithic' build.
184 # export LAYER=compiler
185 # export LAYER=distro
188 # Upstream issue seems to have been corrected
189 # export REPO_VERSION="--repo-branch=repo-1"
192 # In order to avoid running out of space in your home directory
193 export XDG_CACHE_HOME=\${MY_LOCAL_DISK}/.cache;
194 export XDG_DATA_HOME=\${MY_LOCAL_DISK}
196 #/bin/title "\${HOSTNAME} \${PROJECT}"
198 alias patch_build=\${MY_REPO}/stx/update/extras/scripts/patch_build.sh
200 alias cdrepo="cd \$MY_REPO_ROOT_DIR"
201 alias cdbuild="cd \$MY_BUILD_DIR"
203 cd \${MY_REPO_ROOT_DIR}
207 echo_info "Env file created at ${WORKSPACE}/$ENV_FILENAME"
209 source ${WORKSPACE}/${ENV_FILENAME}
215 msg_step="Init the repo and sync"
218 cd ${MY_REPO_ROOT_DIR}
219 STX_MANIFEST="default.xml"
220 if [ "$LAYER" != "" ]; then
221 STX_MANIFEST=${LAYER}.xml
224 RUN_CMD="repo init ${REPO_VERSION} -u ${STX_MANIFEST_URL} -b ${STX_SRC_BRANCH} -m ${STX_MANIFEST}"
225 run_cmd "Init the repo from manifest"
227 RUN_CMD="repo sync --force-sync"
233 create_build_docker () {
234 msg_step="Create build environment docker container"
237 cd ${MY_REPO_ROOT_DIR}/stx-tools/
238 export PATH=$PATH:$PWD
240 echo "MYUNAME=${USER}" > localrc
241 echo "PROJECT=${PRJ_NAME}" >> localrc
242 echo "HOST_PREFIX=${WORKSPACE}" >> localrc
243 echo "HOST_MIRROR_DIR=${WORKSPACE}/mirror" >> localrc
244 echo "LAYER=${LAYER}" >> localrc
245 echo "MY_EMAIL=jackie.huang@windriver.com" >> localrc
249 #sed -i 's/docker /sudo docker /' tb.sh
251 #RUN_CMD="tb.sh create"
252 #run_cmd "Create build environment docker image"
255 run_cmd "Create build environment docker container"
260 exec_build_docker () {
261 msg_step="Enter a bash shell within the build environment container"
264 cd ${MY_REPO_ROOT_DIR}/stx-tools/
265 export PATH=$PATH:$PWD
268 run_cmd "Enter a bash shell within the build environment container"
270 #cd $MY_REPO_ROOT_DIR/stx-tools/centos-mirror-tools/
271 #RUN_CMD="sudo -E ./download_mirror.sh"
272 #run_cmd "Download rpms"
278 # This build script can not successfully build out the image yet,
279 # get the upstream image temporary so we can still test the CI job to
280 # upload the image to nexus
281 ISO_STX_COS=bootimage.iso
283 ISO_UP=http://mirror.starlingx.cengn.ca/mirror/starlingx/release/${ISO_UP_VER}/centos/flock/outputs/iso/${ISO_STX_COS}
284 ISO_INF_COS=inf-image-centos-all-x86-64.iso
288 echo_step_start "Build CentOS images"
290 mkdir -p ${STX_PRJ_OUTPUT}
292 wget ${ISO_UP} -O ${ISO_INF_COS}
296 echo_info "Build succeeded, you can get the image in ${STX_PRJ_OUTPUT}/${ISO_INF_COS}"
300 #########################################################################
302 #########################################################################