+clone_update_repo () {
+ REPO_BRANCH=$1
+ REPO_URL=$2
+ REPO_NAME=$3
+ REPO_COMMIT=$4
+
+ if [ -d ${REPO_NAME}/.git ]; then
+ if [ "${SKIP_UPDATE}" == "Yes" ]; then
+ echo_info "The repo ${REPO_NAME} exists, skip updating for the branch ${REPO_BRANCH}"
+ else
+ echo_info "The repo ${REPO_NAME} exists, updating for the branch ${REPO_BRANCH}"
+ cd ${REPO_NAME}
+ git checkout ${REPO_BRANCH}
+ git pull
+ cd -
+ fi
+ else
+ RUN_CMD="git clone --branch ${REPO_BRANCH} ${REPO_URL} ${REPO_NAME}"
+ run_cmd "Cloning the source of repo '${REPO_NAME}':"
+
+ if [ -n "${REPO_COMMIT}" ]; then
+ cd ${REPO_NAME}
+ RUN_CMD="git checkout -b ${REPO_BRANCH}-${REPO_COMMIT} ${REPO_COMMIT}"
+ run_cmd "Checkout the repo ${REPO_NAME} to specific commit: ${REPO_COMMIT}"
+ cd -
+ fi
+ fi
+}
+
+
+prepare_src () {
+ msg_step="Get the source code repos"
+ echo_step_start
+
+ # Clone the oran inf source if it's not already cloned
+ # Check if the script is inside the repo
+ if cd ${SCRIPTS_DIR} && git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
+ CLONED_ORAN_REPO=`git rev-parse --show-toplevel`
+ echo_info "Use the cloned oran repo: ${CLONED_ORAN_REPO}"
+ mkdir -p ${SRC_ORAN_DIR}
+ cd ${SRC_ORAN_DIR}
+ rm -rf scripts
+ ln -sf ${CLONED_ORAN_REPO}/scripts scripts
+ else
+ echo_info "Cloning oran layer:"
+ cd ${STX_SRC_DIR}
+ clone_update_repo ${SRC_ORAN_BRANCH} ${SRC_ORAN_URL} rtp
+ fi
+
+ if [ "${USE_MIRROR}" == "Yes" ]; then
+ get_mirror_src
+ get_mirror_pkg
+ else
+ repo_init_sync
+ get_mirror_pkg
+ fi
+ patch_src
+
+ cd ${STX_SRC_DIR}/cgcs-root/stx/
+ clone_update_repo ${SRC_O2_BRANCH} ${SRC_O2_URL} app-oran-o2
+
+ echo_step_end
+}
+