diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/pmdk/utils/version.sh | |
parent | Initial commit. (diff) | |
download | ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-x | src/pmdk/utils/version.sh | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/pmdk/utils/version.sh b/src/pmdk/utils/version.sh new file mode 100755 index 000000000..fd751c9d9 --- /dev/null +++ b/src/pmdk/utils/version.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2017-2020, Intel Corporation +# +# utils/version.sh -- determine project's version +# +set -e + +if [ -f "$1/VERSION" ]; then + cat "$1/VERSION" + exit 0 +fi + +if [ -f $1/GIT_VERSION ]; then + echo -n "\$Format:%h\$" | cmp -s $1/GIT_VERSION - && true + if [ $? -eq 0 ]; then + PARSE_GIT_VERSION=0 + else + PARSE_GIT_VERSION=1 + fi +else + PARSE_GIT_VERSION=0 +fi + +LATEST_RELEASE=$(cat $1/ChangeLog | grep "* Version" | cut -d " " -f 3 | sort -rd | head -n1) + +if [ $PARSE_GIT_VERSION -eq 1 ]; then + GIT_VERSION_HASH=$(cat $1/GIT_VERSION) + + if [ -n "$GIT_VERSION_HASH" ]; then + echo "$LATEST_RELEASE+git.$GIT_VERSION_HASH" + exit 0 + fi +fi + +cd "$1" + +GIT_DESCRIBE=$(git describe 2>/dev/null) && true +if [ -n "$GIT_DESCRIBE" ]; then + # 1.5-19-gb8f78a329 -> 1.5+git19.gb8f78a329 + # 1.5-rc1-19-gb8f78a329 -> 1.5-rc1+git19.gb8f78a329 + echo "$GIT_DESCRIBE" | sed "s/\([0-9.]*\)-rc\([0-9]*\)-\([0-9]*\)-\([0-9a-g]*\)/\1-rc\2+git\3.\4/" | sed "s/\([0-9.]*\)-\([0-9]*\)-\([0-9a-g]*\)/\1+git\2.\3/" + exit 0 +fi + +# try commit it, git describe can fail when there are no tags (e.g. with shallow clone, like on Travis) +GIT_COMMIT=$(git log -1 --format=%h) && true +if [ -n "$GIT_COMMIT" ]; then + echo "$LATEST_RELEASE+git.$GIT_COMMIT" + exit 0 +fi + +cd - >/dev/null + +# If nothing works, try to get version from directory name +VER=$(basename `realpath "$1"` | sed 's/pmdk[-]*\([0-9a-z.+-]*\).*/\1/') +if [ -n "$VER" ]; then + echo "$VER" + exit 0 +fi + +exit 1 |