^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #!/bin/sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) # Script which prints out the version to use for building cpupowerutils.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) # Must be called from tools/power/cpupower/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) # Heavily based on tools/perf/util/PERF-VERSION-GEN .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) LF='
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) '
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) # First check if there is a .git to get the version from git describe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) # otherwise try to get the version from the kernel makefile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) if test -d ../../../.git -o -f ../../../.git &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) case "$VN" in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) *$LF*) (exit 1) ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) v[0-9]*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) git update-index -q --refresh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) test -z "$(git diff-index --name-only HEAD --)" ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) VN="$VN-dirty" ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) esac
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) VN=$(echo "$VN" | sed -e 's/-/./g');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) eval $(grep '^VERSION[[:space:]]*=' ../../../Makefile|tr -d ' ')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) eval $(grep '^PATCHLEVEL[[:space:]]*=' ../../../Makefile|tr -d ' ')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) eval $(grep '^SUBLEVEL[[:space:]]*=' ../../../Makefile|tr -d ' ')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) eval $(grep '^EXTRAVERSION[[:space:]]*=' ../../../Makefile|tr -d ' ')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) VN="${VERSION}.${PATCHLEVEL}.${SUBLEVEL}${EXTRAVERSION}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) VN=$(expr "$VN" : v*'\(.*\)')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) echo $VN