Parse dependency versions from TF-M CMake
To make sure CI totally aligned with TF-M, it is better to automatically
parse dependency versions by CI instead of passing a fixed version via
Jenkins environment variable.
This patch adds the logic to select dependency version specified in TF-M
CMake system by default. And CI user can also manually change the
dependency version by setting the corresponding Jenkins environment
variable when triggerring CI jobs.
For the dependency version which differs from platforms, for example
tf-m-extras, the version is double checked with the value in CMake Cache
in each single build-config job.
Signed-off-by: Xinyu Zhang <xinyu.zhang@arm.com>
Change-Id: Ia528783f4235786530c7f25785facae93534c1d3
diff --git a/util_git.sh b/util_git.sh
new file mode 100644
index 0000000..9cbf835
--- /dev/null
+++ b/util_git.sh
@@ -0,0 +1,53 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2023 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+# Don't print mouthful "You are in 'detached HEAD' state." messages.
+git config --global advice.detachedHead false
+
+# Global defaults
+GIT_CLONE_PARAMS="--no-checkout"
+
+function git_clone() {
+ # Parse the repo elements
+ REPO_URL=$1
+ REPO_PATH=$2
+
+ # In case repository is not defined, just skip it
+ if [ -z "${REPO_URL}" ]; then
+ return
+ fi
+
+ # Clone if it does not exit
+ if [ ! -d ${REPO_PATH} ]; then
+ git clone --quiet ${GIT_CLONE_PARAMS} ${REPO_URL} ${REPO_PATH}
+ fi
+}
+
+function git_checkout() {
+ # Parse the repo elements
+ REPO_PATH=$1
+ REPO_REFSPEC=$2
+
+ # Checkout if repo exits
+ if [ -d ${REPO_PATH} ]; then
+ cd ${REPO_PATH}
+
+ # Fetch the corresponding refspec
+ REPO_FETCH_HEAD=$(git ls-remote --quiet | grep ${REPO_REFSPEC} | awk -v d=" " '{s=(NR==1?s:s d)$1} END{print s}')
+
+ if [ -z "${REPO_FETCH_HEAD}" ]; then
+ git fetch --all
+ else
+ git fetch origin ${REPO_FETCH_HEAD}
+ fi
+
+ # Checkout to specified refspec
+ git checkout ${REPO_REFSPEC}
+ echo -e "Share Folder ${REPO_PATH} $(git rev-parse --short HEAD)\n"
+ cd $OLDPWD
+ fi
+}