Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions scripts/utils-general.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,40 @@ check_folder_age() {
fi
}

# Usage: check_git_match <target_ref> [<repo_dir>]
check_git_match() {
local target_ref="$1"
local repo_dir="${2:-.}"

pushd "$repo_dir" > /dev/null || return 2

local current_tag current_branch current_commit_long current_commit_short
current_tag=$(git describe --tags --exact-match 2>/dev/null || true)
current_branch=$(git symbolic-ref --short HEAD 2>/dev/null || true)
current_commit_long=$(git rev-parse HEAD 2>/dev/null || true)
current_commit_short=$(git rev-parse --short HEAD 2>/dev/null || true)

if [[ -n "$current_tag" && "$target_ref" == "$current_tag" ]]; then
echo "match: tag ($current_tag)"
popd > /dev/null
return 0
elif [[ -n "$current_branch" && "$target_ref" == "$current_branch" ]]; then
echo "match: branch ($current_branch)"
popd > /dev/null
return 0
elif [[ -n "$current_commit_long" && "$target_ref" == "$current_commit_long" ]]; then
echo "match: commit (long $current_commit_long)"
popd > /dev/null
return 0
elif [[ -n "$current_commit_short" && "$target_ref" == "$current_commit_short" ]]; then
echo "match: commit (short $current_commit_short)"
popd > /dev/null
return 0
else
echo "no match found for $target_ref"
printf "Version inconsistency. Please fix ${repo_dir}\n"
printf "(expected: ${target_ref}, got: ${current_tag} ${current_branch} ${current_commit_long} ${current_commit_short})\n"
popd > /dev/null
exit 1
fi
}
9 changes: 2 additions & 7 deletions scripts/utils-openssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ USE_CUR_TAG=${USE_CUR_TAG:-0}

clone_openssl() {
if [ -d ${OPENSSL_SOURCE_DIR} ] && [ "$USE_CUR_TAG" != "1" ]; then
OPENSSL_TAG_CUR=$(cd ${OPENSSL_SOURCE_DIR} && (git describe --tags 2>/dev/null || git branch --show-current))
if [ "${OPENSSL_TAG_CUR}" != "${OPENSSL_TAG}" ]; then # force a rebuild
printf "Version inconsistency. Please fix ${OPENSSL_SOURCE_DIR} (expected: ${OPENSSL_TAG}, got: ${OPENSSL_TAG_CUR})\n"
do_cleanup
exit 1
fi
check_git_match "${OPENSSL_TAG}" "${OPENSSL_SOURCE_DIR}"
fi

if [ ! -d ${OPENSSL_SOURCE_DIR} ]; then
Expand Down Expand Up @@ -83,7 +78,7 @@ clone_openssl() {
}

install_openssl() {
printf "\nInstalling OpenSSL ${OPENSSL_TAG} ..."
printf "\nInstalling OpenSSL ${OPENSSL_TAG} ...\n"
clone_openssl
cd ${OPENSSL_SOURCE_DIR}

Expand Down
7 changes: 1 addition & 6 deletions scripts/utils-wolfssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,7 @@ clone_wolfssl() {
cp -pr ${WOLFSSL_FIPS_BUNDLE}/* ${WOLFSSL_SOURCE_DIR}/
else
if [ -d ${WOLFSSL_SOURCE_DIR} ] && [ "$USE_CUR_TAG" != "1" ]; then
WOLFSSL_TAG_CUR=$(cd ${WOLFSSL_SOURCE_DIR} && (git describe --tags 2>/dev/null || git branch --show-current))
if [ "${WOLFSSL_TAG_CUR}" != "${WOLFSSL_TAG}" ]; then # force a rebuild
printf "Version inconsistency. Please fix ${WOLFSSL_SOURCE_DIR} (expected: ${WOLFSSL_TAG}, got: ${WOLFSSL_TAG_CUR})\n"
do_cleanup
exit 1
fi
check_git_match "${WOLFSSL_TAG}" "${WOLFSSL_SOURCE_DIR}"
fi

if [ ! -d ${WOLFSSL_SOURCE_DIR} ]; then
Expand Down
Loading