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 ORAN_REL="ORAN F-Release (6.0)"
30 SCRIPTS_DIR=$(dirname $(readlink -f $0))
31 SCRIPTS_NAME=$(basename $0)
32 TIMESTAMP=`date +"%Y%m%d_%H%M%S"`
34 #########################################################################
36 #########################################################################
41 ${SCRIPTS_NAME} [-w WORKSPACE_DIR] [-n] [-u] [-h]
43 -w WORKSPACE_DIR is the path for the project
44 -n dry-run only for bitbake
45 -u update the repo if it exists
54 [ -n "$1" ] && msg_step=$1
55 echo "#########################################################################################"
56 echo "## ${SCRIPTS_NAME} - STEP START: ${msg_step}"
57 echo "#########################################################################################"
61 [ -n "$1" ] && msg_step=$1
62 echo "#########################################################################################"
63 echo "## ${SCRIPTS_NAME} - STEP END: ${msg_step}"
64 echo "#########################################################################################"
79 echo "CMD: ${RUN_CMD}"
83 #########################################################################
85 #########################################################################
89 while getopts "w:b:e:r:unh" OPTION; do
92 WORKSPACE=`readlink -f ${OPTARG}`
107 if [ -z ${WORKSPACE} ]; then
108 echo_info "No workspace specified, a directory 'workspace' will be created in current directory as the workspace"
109 WORKSPACE=`readlink -f workspace`
112 #########################################################################
113 # Functions for each step
114 #########################################################################
115 PRJ_NAME=prj_oran_stx_centos
117 STX_SRC_BRANCH="r/stx.6.0"
118 STX_LOCAL_DIR=${WORKSPACE}/localdisk
119 STX_LOCAL_SRC_DIR=${STX_LOCAL_DIR}/designer/${USER}/${PRJ_NAME}
120 STX_LOCAL_PRJ_DIR=${STX_LOCAL_DIR}/loadbuild/${USER}/${PRJ_NAME}
121 STX_SRC_DIR=${WORKSPACE}/src
122 STX_PRJ_DIR=${WORKSPACE}/${PRJ_NAME}
123 STX_PRJ_OUTPUT=${WORKSPACE}/prj_output
124 STX_MIRROR_DIR=${WORKSPACE}/mirror
125 STX_MANIFEST_URL="https://opendev.org/starlingx/manifest"
127 SRC_META_PATCHES=${SCRIPTS_DIR}/meta-patches
129 ISO_INF_COS=inf-image-centos-all-x86-64.iso
131 prepare_workspace () {
132 msg_step="Create workspace for the CentOS build"
135 mkdir -p ${STX_LOCAL_SRC_DIR} ${STX_LOCAL_PRJ_DIR} ${STX_MIRROR_DIR} ${STX_PRJ_OUTPUT}
136 rm -f ${STX_SRC_DIR} ${STX_PRJ_DIR}
137 ln -sf $(realpath --relative-to=${WORKSPACE} ${STX_LOCAL_SRC_DIR}) ${STX_SRC_DIR}
138 ln -sf $(realpath --relative-to=${WORKSPACE} ${STX_LOCAL_PRJ_DIR}) ${STX_PRJ_DIR}
140 echo_info "The following directories are created in your workspace(${WORKSPACE}):"
141 echo_info "For all layers source: ${STX_SRC_DIR}"
142 echo_info "For StarlingX rpm mirror: ${STX_MIRROR_DIR}"
143 echo_info "For StarlingX build project: ${STX_PRJ_DIR}"
149 msg_step="Create env file for the CentOS build"
152 ENV_FILENAME=env.${PRJ_NAME}
154 cat <<EOF > ${WORKSPACE}/${ENV_FILENAME}
156 export STX_MIRROR_DIR=${STX_MIRROR_DIR}
158 #######################################
160 #######################################
162 export LC_ALL=en_US.UTF-8
163 export PROJECT=${PRJ_NAME}
164 export SRC_BUILD_ENVIRONMENT=tis-r6-pike
165 export MY_LOCAL_DISK=${STX_SRC_DIR}
166 export MY_REPO_ROOT_DIR=\${MY_LOCAL_DISK}
167 export MY_REPO=\${MY_REPO_ROOT_DIR}/cgcs-root
168 export CGCSDIR=\${MY_REPO}/stx
169 export MY_WORKSPACE=${WORKSPACE}/\${PROJECT}
170 export MY_BUILD_ENVIRONMENT=\${USER}-\${PROJECT}-\${SRC_BUILD_ENVIRONMENT}
171 export MY_BUILD_ENVIRONMENT_FILE=\${MY_BUILD_ENVIRONMENT}.cfg
172 export MY_BUILD_ENVIRONMENT_FILE_STD=\${MY_BUILD_ENVIRONMENT}-std.cfg
173 export MY_BUILD_ENVIRONMENT_FILE_RT=\${MY_BUILD_ENVIRONMENT}-rt.cfg
174 export MY_BUILD_ENVIRONMENT_FILE_STD_B0=\${MY_WORKSPACE}/std/configs/\${MY_BUILD_ENVIRONMENT}-std/\${MY_BUILD_ENVIRONMENT}-std.b0.cfg
175 export MY_BUILD_ENVIRONMENT_FILE_RT_B0=\${MY_WORKSPACE}/rt/configs/\${MY_BUILD_ENVIRONMENT}-rt/\${MY_BUILD_ENVIRONMENT}-rt.b0.cfg
176 export MY_BUILD_DIR=${WORKSPACE}/\${PROJECT}
177 export MY_SRC_RPM_BUILD_DIR=\${MY_BUILD_DIR}/rpmbuild
178 export MY_BUILD_CFG=\${MY_WORKSPACE}/\${MY_BUILD_ENVIRONMENT_FILE}
179 export MY_BUILD_CFG_STD=\${MY_WORKSPACE}/std/\${MY_BUILD_ENVIRONMENT_FILE_STD}
180 export MY_BUILD_CFG_RT=\${MY_WORKSPACE}/rt/\${MY_BUILD_ENVIRONMENT_FILE_RT}
181 export PATH=\${MY_REPO}/build-tools:\${MY_LOCAL_DISK}/bin:\${CGCSDIR}/stx-update/extras/scripts:\${PATH}
182 export CGCSPATCH_DIR=\${CGCSDIR}/stx-update/cgcs-patch
183 export BUILD_ISO_USE_UDEV=1
185 # WRCP/WRA/WRO do not support layered builds at this time.
188 # StarlingX since 4.0 supports layered builds (compiler, distro, flock) as an option.
189 # Note: Only flock layer builds an iso at this time.
190 # Note: You may leave LAYER="", this will build everything, also known as a 'monolithic' build.
191 # export LAYER=compiler
192 # export LAYER=distro
195 # Upstream issue seems to have been corrected
196 # export REPO_VERSION="--repo-branch=repo-1"
199 # In order to avoid running out of space in your home directory
200 export XDG_CACHE_HOME=\${MY_LOCAL_DISK}/.cache;
201 export XDG_DATA_HOME=\${MY_LOCAL_DISK}
203 #/bin/title "\${HOSTNAME} \${PROJECT}"
205 alias patch_build=\${MY_REPO}/stx/update/extras/scripts/patch_build.sh
207 alias cdrepo="cd \$MY_REPO_ROOT_DIR"
208 alias cdbuild="cd \$MY_BUILD_DIR"
210 cd \${MY_REPO_ROOT_DIR}
214 echo_info "Env file created at ${WORKSPACE}/$ENV_FILENAME"
216 source ${WORKSPACE}/${ENV_FILENAME}
222 msg_step="Init the repo and sync"
225 cd ${MY_REPO_ROOT_DIR}
226 STX_MANIFEST="default.xml"
227 if [ "$LAYER" != "" ]; then
228 STX_MANIFEST=${LAYER}.xml
231 RUN_CMD="repo init ${REPO_VERSION} -u ${STX_MANIFEST_URL} -b ${STX_SRC_BRANCH} -m ${STX_MANIFEST}"
232 run_cmd "Init the repo from manifest"
234 RUN_CMD="repo sync --force-sync"
241 echo_step_start "Some source codes need to be patched for INF project"
243 sed -i "s|/import/mirrors|${STX_MIRROR_DIR}|" \
244 ${MY_REPO}/stx/metal/installer/pxe-network-installer/centos/build_srpm.data
246 grep -q "${ORAN_REL}" \
247 ${MY_REPO}/stx/config-files/centos-release-config/files/issue* \
248 || sed -i "s/\(@PLATFORM_RELEASE@\)/\1 - ${ORAN_REL}/" \
249 ${MY_REPO}/stx/config-files/centos-release-config/files/issue*
252 cd ${SRC_META_PATCHES}
253 src_dirs=$(find . -type f -printf "%h\n"|uniq)
254 for d in ${src_dirs}; do
255 cd ${MY_REPO_ROOT_DIR}/${d}
257 # backup current branch
258 local_branch=$(git rev-parse --abbrev-ref HEAD)
259 if [ "${local_branch}" = "HEAD" ]; then
260 git checkout ${STX_SRC_BRANCH}
261 local_branch=$(git rev-parse --abbrev-ref HEAD)
263 git branch -m "${local_branch}_${TIMESTAMP}"
264 git checkout ${STX_SRC_BRANCH}
266 for p in $(ls -1 ${SRC_META_PATCHES}/${d}); do
267 echo_info "Apllying patch: ${SRC_META_PATCHES}/${d}/${p}"
268 git am ${SRC_META_PATCHES}/${d}/${p}
276 ${MY_REPO_ROOT_DIR}/stx-tools/toCOPY/generate-centos-repo.sh ${STX_MIRROR_DIR}/stx-6.0
277 ${MY_REPO_ROOT_DIR}/stx-tools/toCOPY/populate_downloads.sh ${STX_MIRROR_DIR}/stx-6.0
281 echo_step_start "Build CentOS images"
283 mkdir -p ${STX_PRJ_OUTPUT}
285 RUN_CMD="build-pkgs --build-avoidance"
288 # The first run always fail
289 build-iso || sleep 60
292 run_cmd "Build ISO image"
294 cp -f ${MY_BUILD_DIR}/export/bootimage.iso ${STX_PRJ_OUTPUT}/${ISO_INF_COS}
298 echo_info "Build succeeded, you can get the image in ${STX_PRJ_OUTPUT}/${ISO_INF_COS}"
301 #########################################################################
303 #########################################################################