dist: ensure release start with decimal number

Upstream: no

RPM NVR expects a decimal starting release. Previously dist build try to
respect git tag as much as possible, but for this case we need to be
careful about breaking RPM specs.

Signed-off-by: Kairui Song <kasong@tencent.com>
This commit is contained in:
Kairui Song 2024-04-17 17:01:54 +08:00 committed by frankjpliu
parent afd9d2d0b6
commit 1ffa857af8
1 changed files with 9 additions and 7 deletions

View File

@ -142,6 +142,10 @@ _is_num() {
[ "$1" -eq "$1" ] &>/dev/null
}
_is_dec_num() {
[ "$1" = "$(( $1 * 1 ))" ] &>/dev/null
}
# Get the tag of a git ref, if the git ref itself is a valid tag, just return itself
# else, search latest tag before this git ref.
_get_git_tag_of() {
@ -649,13 +653,11 @@ prepare_kernel_ver() {
fi
fi
case $krelease in
*.* )
;;
*)
krelease=0.$krelease
;;
esac
# If somehow krelease is still not starting with a decimal number,
# (the most common case is when KTAGRELEASE is set above), force fix that.
if ! _is_dec_num "${krelease%%.*}"; then
krelease=0.$krelease
fi
KERNEL_NAME="kernel${KDIST:+-$KDIST}"
if [[ $localversion ]]; then