File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,3 +48,40 @@ check_folder_age() {
4848 fi
4949}
5050
51+ # Usage: check_git_match <target_ref> [<repo_dir>]
52+ check_git_match () {
53+ local target_ref=" $1 "
54+ local repo_dir=" ${2:- .} "
55+
56+ pushd " $repo_dir " > /dev/null || return 2
57+
58+ local current_tag current_branch current_commit_long current_commit_short
59+ current_tag=$( git describe --tags --exact-match 2> /dev/null || true)
60+ current_branch=$( git symbolic-ref --short HEAD 2> /dev/null || true)
61+ current_commit_long=$( git rev-parse HEAD 2> /dev/null || true)
62+ current_commit_short=$( git rev-parse --short HEAD 2> /dev/null || true)
63+
64+ if [[ -n " $current_tag " && " $target_ref " == " $current_tag " ]]; then
65+ echo " match: tag ($current_tag )"
66+ popd > /dev/null
67+ return 0
68+ elif [[ -n " $current_branch " && " $target_ref " == " $current_branch " ]]; then
69+ echo " match: branch ($current_branch )"
70+ popd > /dev/null
71+ return 0
72+ elif [[ -n " $current_commit_long " && " $target_ref " == " $current_commit_long " ]]; then
73+ echo " match: commit (long $current_commit_long )"
74+ popd > /dev/null
75+ return 0
76+ elif [[ -n " $current_commit_short " && " $target_ref " == " $current_commit_short " ]]; then
77+ echo " match: commit (short $current_commit_short )"
78+ popd > /dev/null
79+ return 0
80+ else
81+ echo " no match found for $target_ref "
82+ printf " Version inconsistency. Please fix ${repo_dir} \n"
83+ printf " (expected: ${target_ref} , got: ${current_tag} ${current_branch} ${current_commit_long} ${current_commit_short} )\n"
84+ popd > /dev/null
85+ exit 1
86+ fi
87+ }
Original file line number Diff line number Diff line change @@ -39,12 +39,7 @@ USE_CUR_TAG=${USE_CUR_TAG:-0}
3939
4040clone_openssl () {
4141 if [ -d ${OPENSSL_SOURCE_DIR} ] && [ " $USE_CUR_TAG " != " 1" ]; then
42- OPENSSL_TAG_CUR=$( cd ${OPENSSL_SOURCE_DIR} && (git describe --tags 2> /dev/null || git branch --show-current))
43- if [ " ${OPENSSL_TAG_CUR} " != " ${OPENSSL_TAG} " ]; then # force a rebuild
44- printf " Version inconsistency. Please fix ${OPENSSL_SOURCE_DIR} (expected: ${OPENSSL_TAG} , got: ${OPENSSL_TAG_CUR} )\n"
45- do_cleanup
46- exit 1
47- fi
42+ check_git_match " ${OPENSSL_TAG} " " ${OPENSSL_SOURCE_DIR} "
4843 fi
4944
5045 if [ ! -d ${OPENSSL_SOURCE_DIR} ]; then
@@ -83,7 +78,7 @@ clone_openssl() {
8378}
8479
8580install_openssl () {
86- printf " \nInstalling OpenSSL ${OPENSSL_TAG} ..."
81+ printf " \nInstalling OpenSSL ${OPENSSL_TAG} ...\n "
8782 clone_openssl
8883 cd ${OPENSSL_SOURCE_DIR}
8984
Original file line number Diff line number Diff line change @@ -44,12 +44,7 @@ clone_wolfssl() {
4444 cp -pr ${WOLFSSL_FIPS_BUNDLE} /* ${WOLFSSL_SOURCE_DIR} /
4545 else
4646 if [ -d ${WOLFSSL_SOURCE_DIR} ] && [ " $USE_CUR_TAG " != " 1" ]; then
47- WOLFSSL_TAG_CUR=$( cd ${WOLFSSL_SOURCE_DIR} && (git describe --tags 2> /dev/null || git branch --show-current))
48- if [ " ${WOLFSSL_TAG_CUR} " != " ${WOLFSSL_TAG} " ]; then # force a rebuild
49- printf " Version inconsistency. Please fix ${WOLFSSL_SOURCE_DIR} (expected: ${WOLFSSL_TAG} , got: ${WOLFSSL_TAG_CUR} )\n"
50- do_cleanup
51- exit 1
52- fi
47+ check_git_match " ${WOLFSSL_TAG} " " ${WOLFSSL_SOURCE_DIR} "
5348 fi
5449
5550 if [ ! -d ${WOLFSSL_SOURCE_DIR} ]; then
You can’t perform that action at this time.
0 commit comments