]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
update version.sh to cope with a prerelease
authorMatthew Newton <matthew-git@newtoncomputing.co.uk>
Tue, 10 Oct 2023 13:39:24 +0000 (14:39 +0100)
committerMatthew Newton <matthew-git@newtoncomputing.co.uk>
Tue, 10 Oct 2023 16:10:59 +0000 (17:10 +0100)
version.sh

index 6cddbe16c609b78c38f66abe89830716ab6726ba..44aabfba0fb233bfa82eb8dfa17245d2475e3bb9 100755 (executable)
@@ -28,6 +28,7 @@ release_file=RELEASE
 version_major=4
 version_minor=0
 version_incrm=
+version_prerelease=
 commit=
 commit_depth=
 is_release=0
@@ -51,6 +52,8 @@ usage()
        echo "component may be one of:"
        echo "major             Major version component from ${version_file}."
        echo "minor             Minor version component from ${version_file}."
+       echo "incrm             Incremental version component from ${version_file}."
+       echo "prerelease        Pre-release version component from ${version_file}."
        echo "commit            Short (8 hexit) commit hash."
        echo "commit_depth      How many commit since the last tag."
        echo "is_release        true if the current commit has been tagged as a release, else false."
@@ -67,20 +70,25 @@ version_component()
        for c in "$@"; do
        case "$c" in
        major)
-               out=$(cut -f1 -d. 2>/dev/null < ${version_file})
+               out=$(cut -f1 -d~ 2>/dev/null < ${version_file} | cut -f1 -d.)
                if [ -z "${out}" ]; then out="${version_major}"; fi
        ;;
 
        minor)
-               out=$(cut -f2 -d. 2>/dev/null < ${version_file})
+               out=$(cut -f1 -d~ 2>/dev/null < ${version_file} | cut -f2 -d.)
                if [ -z "${out}" ]; then out="${version_minor}"; fi
        ;;
 
        incrm)
-               out=$(cut -f3 -d. 2>/dev/null < ${version_file})
+               out=$(cut -f1 -d~ 2>/dev/null < ${version_file} | cut -f3 -d.)
                if [ -z "${out}" ]; then out="${version_incrm}"; fi
        ;;
 
+       prerelease)
+               out=$(cut -s -f2 -d~ 2>/dev/null < ${version_file})
+               if [ -z "${out}" ]; then out="$version_prerelease"; fi
+       ;;
+
        commit)
                out=$(\
                        cat ${commit_file} 2> /dev/null || \