From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
Rasmus Villemoes <rasmus.villemoes@prevas.dk>,
Masahiro Yamada <masahiroy@kernel.org>
Subject: [PATCH 4/7] setlocalversion: use only the correct release tag for git-describe
Date: Sun, 22 Jan 2023 23:14:24 +0900 [thread overview]
Message-ID: <20230122141428.115372-4-masahiroy@kernel.org> (raw)
In-Reply-To: <20230122141428.115372-1-masahiroy@kernel.org>
Currently, setlocalversion uses any annotated tag for git-describe.
If we are at a tagged commit, it will not append the commit hash.
$ git checkout v6.2-rc1^
$ make -s defconfig prepare
$ make kernelrelease
6.1.0-14595-g292a089d78d3
$ git tag -a foo -m foo
$ make kernelrelease
6.1.0
If a local tag 'foo' exists, it pretends to be a released version
'6.1.0', while there are many commits on top of it.
The output should be consistent irrespective of such a local tag.
Pass the correct release tag to --match option of git-describe.
In the mainline kernel, the SUBLEVEL is always '0' but it is omitted
from the tag.
version tag
6.1.0 -> v6.1 (mainline)
6.2.0-rc5 -> v6.2-rc5 (mainline, release candidate)
6.1.7 -> v6.1.7 (stable)
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/setlocalversion | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index b8e1018d611e..a4c9a61b0665 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -27,6 +27,7 @@ fi
scm_version()
{
local short
+ local tag
short=false
cd "$srctree"
@@ -42,9 +43,14 @@ scm_version()
return
fi
- # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore it
- # because this version is defined in the top level Makefile.
- if [ -z "$(git describe --exact-match 2>/dev/null)" ]; then
+ # convert the version to a tag
+ # mainline kernel: 6.2.0-rc5 -> v6.2-rc5
+ # stable kernel: 6.1.7 -> v6.1.7
+ tag=v$(echo "${KERNELVERSION}" | sed 's/^\(.*\..*\)\.0\(.*\)$/\1\2/')
+
+ # If we are at a tagged commit and the tag matches the version defined
+ # in the top level Makefile, we ignore it.
+ if [ -z "$(git describe --exact-match --match=$tag 2>/dev/null)" ]; then
# If only the short version is requested, don't bother
# running further git commands
@@ -52,9 +58,9 @@ scm_version()
echo "+"
return
fi
- # If we are past a tagged commit (like
- # "v2.6.30-rc5-302-g72357d5"), we pretty print it.
- if atag="$(git describe 2>/dev/null)"; then
+ # If we are past the release tag, we pretty print it.
+ # (like 6.1.0-14595-g292a089d78d3)
+ if atag="$(git describe --match=$tag 2>/dev/null)"; then
echo "$atag" | awk -F- '{printf("-%05d", $(NF-1))}'
fi
@@ -102,6 +108,11 @@ if ! test -e include/config/auto.conf; then
exit 1
fi
+if [ -z "${KERNELVERSION}" ]; then
+ echo "KERNELVERSION is not set" >&2
+ exit 1
+fi
+
# localversion* files in the build and source directory
res="$(collect_files localversion*)"
if test ! "$srctree" -ef .; then
--
2.34.1
next prev parent reply other threads:[~2023-01-22 14:14 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-22 14:14 [PATCH 1/7] kbuild: do not put .scmversion into the source tarball Masahiro Yamada
2023-01-22 14:14 ` [PATCH 2/7] setlocalversion: simplify the construction of the short version Masahiro Yamada
2023-01-29 21:30 ` Nicolas Schier
2023-01-22 14:14 ` [PATCH 3/7] setlocalversion: make indentation shallower Masahiro Yamada
2023-01-29 21:31 ` Nicolas Schier
2023-01-22 14:14 ` Masahiro Yamada [this message]
2023-02-05 12:02 ` [PATCH 4/7] setlocalversion: use only the correct release tag for git-describe Masahiro Yamada
2023-01-22 14:14 ` [PATCH 5/7] setlocalversion: absorb $(KERNELVERSION) Masahiro Yamada
2023-01-22 14:14 ` [PATCH 6/7] setlocalversion: print ${KERNELRELEASE} if set Masahiro Yamada
2023-01-27 16:19 ` Masahiro Yamada
2023-01-22 14:14 ` [PATCH 7/7] kbuild: do not re-run setlocalversion for kernelrelease Masahiro Yamada
2023-02-01 13:09 ` Masahiro Yamada
2023-01-27 15:07 ` [PATCH 1/7] kbuild: do not put .scmversion into the source tarball Thierry Reding
2023-01-27 15:50 ` Masahiro Yamada
2023-01-27 19:29 ` Nathan Chancellor
2023-01-28 1:11 ` Masahiro Yamada
2023-01-29 21:29 ` Nicolas Schier
2023-01-30 1:44 ` Masahiro Yamada
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230122141428.115372-4-masahiroy@kernel.org \
--to=masahiroy@kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rasmus.villemoes@prevas.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.