From 1ffa857af8537ba66ca261165dd45f6bfcc8baf3 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 17 Apr 2024 17:01:54 +0800 Subject: [PATCH] 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 --- dist/scripts/lib-version.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/dist/scripts/lib-version.sh b/dist/scripts/lib-version.sh index dcb2922c03a3..c88cf1f4faff 100755 --- a/dist/scripts/lib-version.sh +++ b/dist/scripts/lib-version.sh @@ -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