.scmversion is used by (src)rpm-pkg and deb-pkg to carry KERNELRELEASE.
In fact, deb-pkg does not rely on it any more because the generated
debian/rules specifies KERNELRELEASE from the command line.
Do likwise for (src)rpm-pkg, and remove this feature.
Signed-off-by: Masahiro Yamada <[email protected]>
---
scripts/Makefile.package | 6 ++----
scripts/package/mkspec | 6 +++---
scripts/setlocalversion | 19 +------------------
3 files changed, 6 insertions(+), 25 deletions(-)
diff --git a/scripts/Makefile.package b/scripts/Makefile.package
index 525a2820976f..e84c4e8ceb8e 100644
--- a/scripts/Makefile.package
+++ b/scripts/Makefile.package
@@ -32,7 +32,7 @@ export KDEB_SOURCENAME
TAR_CONTENT := Documentation LICENSES arch block certs crypto drivers fs \
include init io_uring ipc kernel lib mm net rust \
samples scripts security sound tools usr virt \
- .config .scmversion Makefile \
+ .config Makefile \
Kbuild Kconfig COPYING $(wildcard localversion*)
MKSPEC := $(srctree)/scripts/package/mkspec
@@ -47,10 +47,8 @@ if test "$(objtree)" != "$(srctree)"; then \
echo >&2; \
false; \
fi ; \
-$(srctree)/scripts/setlocalversion --save-scmversion; \
tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \
- --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3); \
-rm -f $(objtree)/.scmversion
+ --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3)
# rpm-pkg
# ---------------------------------------------------------------------------
diff --git a/scripts/package/mkspec b/scripts/package/mkspec
index adab28fa7f89..d3c6701b7769 100755
--- a/scripts/package/mkspec
+++ b/scripts/package/mkspec
@@ -90,7 +90,7 @@ $S rm -f scripts/basic/fixdep scripts/kconfig/conf
$S rm -f tools/objtool/{fixdep,objtool}
$S
$S %build
-$S $MAKE %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}
+$S $MAKE %{?_smp_mflags} KERNELRELEASE=%{version} KBUILD_BUILD_VERSION=%{release}
$S
%install
mkdir -p %{buildroot}/boot
@@ -101,8 +101,8 @@ $S
%else
cp \$($MAKE -s image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE
%endif
-$M $MAKE %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} modules_install
- $MAKE %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
+$M $MAKE %{?_smp_mflags} KERNELRELEASE=%{version} INSTALL_MOD_PATH=%{buildroot} modules_install
+ $MAKE %{?_smp_mflags} KERNELRELEASE=%{version} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE
cp .config %{buildroot}/boot/config-$KERNELRELEASE
$S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/build
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index af4754a35e66..3b31702b4a4a 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -11,16 +11,11 @@
#
usage() {
- echo "Usage: $0 [--save-scmversion] [srctree]" >&2
+ echo "Usage: $0 [srctree]" >&2
exit 1
}
-scm_only=false
srctree=.
-if test "$1" = "--save-scmversion"; then
- scm_only=true
- shift
-fi
if test $# -gt 0; then
srctree=$1
shift
@@ -35,10 +30,6 @@ scm_version()
short=false
cd "$srctree"
- if test -e .scmversion; then
- cat .scmversion
- return
- fi
if test "$1" = "--short"; then
short=true
fi
@@ -103,14 +94,6 @@ collect_files()
echo "$res"
}
-if $scm_only; then
- if test ! -e .scmversion; then
- res=$(scm_version)
- echo "$res" >.scmversion
- fi
- exit
-fi
-
if ! test -e include/config/auto.conf; then
echo "Error: kernelrelease not valid - run 'make prepare' to update it" >&2
exit 1
--
2.34.1
With the --short option given, scm_version() prints "+".
Just append it.
Signed-off-by: Masahiro Yamada <[email protected]>
---
scripts/setlocalversion | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 3b31702b4a4a..5cdf409204aa 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -121,8 +121,7 @@ elif [ "${LOCALVERSION+set}" != "set" ]; then
#
# If the variable LOCALVERSION is set (including being set
# to an empty string), we don't want to append a plus sign.
- scm=$(scm_version --short)
- res="$res${scm:++}"
+ res="$res$(scm_version --short)"
fi
echo "$res"
--
2.34.1
Return earlier if we are not in the correct git repository. This makes
the code more readable.
Signed-off-by: Masahiro Yamada <[email protected]>
---
scripts/setlocalversion | 79 +++++++++++++++++++++--------------------
1 file changed, 41 insertions(+), 38 deletions(-)
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 5cdf409204aa..b8e1018d611e 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -34,46 +34,49 @@ scm_version()
short=true
fi
- # Check for git and a git repo.
- if test -z "$(git rev-parse --show-cdup 2>/dev/null)" &&
- head=$(git rev-parse --verify HEAD 2>/dev/null); then
-
- # 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
-
- # If only the short version is requested, don't bother
- # running further git commands
- if $short; then
- 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
- echo "$atag" | awk -F- '{printf("-%05d", $(NF-1))}'
- fi
-
- # Add -g and exactly 12 hex chars.
- printf '%s%s' -g "$(echo $head | cut -c1-12)"
- fi
+ if test -n "$(git rev-parse --show-cdup 2>/dev/null)"; then
+ return
+ fi
+
+ if ! head=$(git rev-parse --verify HEAD 2>/dev/null); then
+ 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
- # Check for uncommitted changes.
- # This script must avoid any write attempt to the source tree,
- # which might be read-only.
- # You cannot use 'git describe --dirty' because it tries to
- # create .git/index.lock .
- # First, with git-status, but --no-optional-locks is only
- # supported in git >= 2.14, so fall back to git-diff-index if
- # it fails. Note that git-diff-index does not refresh the
- # index, so it may give misleading results. See
- # git-update-index(1), git-diff-index(1), and git-status(1).
- if {
- git --no-optional-locks status -uno --porcelain 2>/dev/null ||
- git diff-index --name-only HEAD
- } | read dummy; then
- printf '%s' -dirty
+ # If only the short version is requested, don't bother
+ # running further git commands
+ if $short; then
+ 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
+ echo "$atag" | awk -F- '{printf("-%05d", $(NF-1))}'
+ fi
+
+ # Add -g and exactly 12 hex chars.
+ printf '%s%s' -g "$(echo $head | cut -c1-12)"
+ fi
+
+ # Check for uncommitted changes.
+ # This script must avoid any write attempt to the source tree, which
+ # might be read-only.
+ # You cannot use 'git describe --dirty' because it tries to create
+ # .git/index.lock .
+ # First, with git-status, but --no-optional-locks is only supported in
+ # git >= 2.14, so fall back to git-diff-index if it fails. Note that
+ # git-diff-index does not refresh the index, so it may give misleading
+ # results.
+ # See git-update-index(1), git-diff-index(1), and git-status(1).
+ if {
+ git --no-optional-locks status -uno --porcelain 2>/dev/null ||
+ git diff-index --name-only HEAD
+ } | read dummy; then
+ printf '%s' -dirty
fi
}
--
2.34.1
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 <[email protected]>
---
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
Print $(KERNELVERSION) in setlocalversion so that the callers get
simpler.
Signed-off-by: Masahiro Yamada <[email protected]>
---
Makefile | 5 ++---
scripts/setlocalversion | 4 +++-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index ed3294c7be97..d0a95277f08a 100644
--- a/Makefile
+++ b/Makefile
@@ -1247,8 +1247,7 @@ vmlinux: vmlinux.o $(KBUILD_LDS) modpost
# make sure no implicit rule kicks in
$(sort $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)): . ;
-filechk_kernel.release = \
- echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
+filechk_kernel.release = $(srctree)/scripts/setlocalversion $(srctree)
# Store (new) KERNELRELEASE string in include/config/kernel.release
include/config/kernel.release: FORCE
@@ -2112,7 +2111,7 @@ checkstack:
$(PERL) $(srctree)/scripts/checkstack.pl $(CHECKSTACK_ARCH)
kernelrelease:
- @echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
+ @$(srctree)/scripts/setlocalversion $(srctree)
kernelversion:
@echo $(KERNELVERSION)
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index a4c9a61b0665..7c7cbefa5aa4 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -113,8 +113,10 @@ if [ -z "${KERNELVERSION}" ]; then
exit 1
fi
+res="${KERNELVERSION}"
+
# localversion* files in the build and source directory
-res="$(collect_files localversion*)"
+res="${res}$(collect_files localversion*)"
if test ! "$srctree" -ef .; then
res="$res$(collect_files "$srctree"/localversion*)"
fi
--
2.34.1
Revert:
- 7b8ea53d7f18 ("makefile: not need to regenerate kernel.release
file when make kernelrelease")
- 01ab17887f4c ("Makefile: "make kernelrelease" should show the
correct full kernel version")
I think the original behavior was better - 'make kernelrelease' should
print $(KERNELRELEASE) used in the last build, not the one that will
be used in the next build. Therefore, it is an error if you run it in
the pristine source tree.
Signed-off-by: Masahiro Yamada <[email protected]>
---
Makefile | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index d0a95277f08a..de402d415d5f 100644
--- a/Makefile
+++ b/Makefile
@@ -281,13 +281,13 @@ clean-targets := %clean mrproper cleandocs
no-dot-config-targets := $(clean-targets) \
cscope gtags TAGS tags help% %docs check% coccicheck \
$(version_h) headers headers_% archheaders archscripts \
- %asm-generic kernelversion %src-pkg dt_binding_check \
+ %asm-generic kernelrelease kernelversion %src-pkg dt_binding_check \
outputmakefile rustavailable rustfmt rustfmtcheck
# Installation targets should not require compiler. Unfortunately, vdso_install
# is an exception where build artifacts may be updated. This must be fixed.
no-compiler-targets := $(no-dot-config-targets) install dtbs_install \
- headers_install modules_install kernelrelease image_name
-no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \
+ headers_install modules_install image_name
+no-sync-config-targets := $(no-dot-config-targets) %install \
image_name
single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.rsi %.s %.symtypes %/
@@ -1677,7 +1677,7 @@ help:
@echo ' tags/TAGS - Generate tags file for editors'
@echo ' cscope - Generate cscope index'
@echo ' gtags - Generate GNU GLOBAL index'
- @echo ' kernelrelease - Output the release version string (use with make -s)'
+ @echo ' kernelrelease - Output the release version string used in the last build (use with make -s)'
@echo ' kernelversion - Output the version stored in Makefile (use with make -s)'
@echo ' image_name - Output the image name (use with make -s)'
@echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \
@@ -2111,7 +2111,7 @@ checkstack:
$(PERL) $(srctree)/scripts/checkstack.pl $(CHECKSTACK_ARCH)
kernelrelease:
- @$(srctree)/scripts/setlocalversion $(srctree)
+ @echo $(or $(KERNELRELEASE),$(error kernelrelease not valid - run 'make prepare' to update it))
kernelversion:
@echo $(KERNELVERSION)
--
2.34.1
When KERNELRELEASE is overridden, include/config/kernel.release still
stores the string would be returned by the script if KERNELRELEASE had
not been overridden. This is not strange.
include/config/kernel.release should store KERNELRELEASE that was used
for building the kernel.
Signed-off-by: Masahiro Yamada <[email protected]>
---
scripts/setlocalversion | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 7c7cbefa5aa4..eff8cc831571 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -103,6 +103,11 @@ collect_files()
echo "$res"
}
+if [ -n "${KERNELRELEASE}" ]; then
+ echo "${KERNELRELEASE}"
+ exit 0
+fi
+
if ! test -e include/config/auto.conf; then
echo "Error: kernelrelease not valid - run 'make prepare' to update it" >&2
exit 1
--
2.34.1
On Sun, Jan 22, 2023 at 11:14:21PM +0900, Masahiro Yamada wrote:
> .scmversion is used by (src)rpm-pkg and deb-pkg to carry KERNELRELEASE.
>
> In fact, deb-pkg does not rely on it any more because the generated
> debian/rules specifies KERNELRELEASE from the command line.
>
> Do likwise for (src)rpm-pkg, and remove this feature.
>
> Signed-off-by: Masahiro Yamada <[email protected]>
> ---
>
> scripts/Makefile.package | 6 ++----
> scripts/package/mkspec | 6 +++---
> scripts/setlocalversion | 19 +------------------
> 3 files changed, 6 insertions(+), 25 deletions(-)
Hi Masahiro,
I've been observing some strange behaviour when doing incremental builds
on recent linux-next versions. What happens is that the kernel version
doesn't get updated as I switch branches.
For instance I was rebuilding in a kernel tree which I hadn't touched in
a very long while and rebased on a recent linux-next. The kernel version
then stayed at the prior version rather than being updated to reflect
the actual state of the working tree.
Reverting all of the seven patches in this series fixes the issue, but I
don't really have a clue where exactly it fails. Do you have any ideas
how to fix this?
Thanks,
Thierry
>
> diff --git a/scripts/Makefile.package b/scripts/Makefile.package
> index 525a2820976f..e84c4e8ceb8e 100644
> --- a/scripts/Makefile.package
> +++ b/scripts/Makefile.package
> @@ -32,7 +32,7 @@ export KDEB_SOURCENAME
> TAR_CONTENT := Documentation LICENSES arch block certs crypto drivers fs \
> include init io_uring ipc kernel lib mm net rust \
> samples scripts security sound tools usr virt \
> - .config .scmversion Makefile \
> + .config Makefile \
> Kbuild Kconfig COPYING $(wildcard localversion*)
> MKSPEC := $(srctree)/scripts/package/mkspec
>
> @@ -47,10 +47,8 @@ if test "$(objtree)" != "$(srctree)"; then \
> echo >&2; \
> false; \
> fi ; \
> -$(srctree)/scripts/setlocalversion --save-scmversion; \
> tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \
> - --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3); \
> -rm -f $(objtree)/.scmversion
> + --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3)
>
> # rpm-pkg
> # ---------------------------------------------------------------------------
> diff --git a/scripts/package/mkspec b/scripts/package/mkspec
> index adab28fa7f89..d3c6701b7769 100755
> --- a/scripts/package/mkspec
> +++ b/scripts/package/mkspec
> @@ -90,7 +90,7 @@ $S rm -f scripts/basic/fixdep scripts/kconfig/conf
> $S rm -f tools/objtool/{fixdep,objtool}
> $S
> $S %build
> -$S $MAKE %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}
> +$S $MAKE %{?_smp_mflags} KERNELRELEASE=%{version} KBUILD_BUILD_VERSION=%{release}
> $S
> %install
> mkdir -p %{buildroot}/boot
> @@ -101,8 +101,8 @@ $S
> %else
> cp \$($MAKE -s image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE
> %endif
> -$M $MAKE %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} modules_install
> - $MAKE %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
> +$M $MAKE %{?_smp_mflags} KERNELRELEASE=%{version} INSTALL_MOD_PATH=%{buildroot} modules_install
> + $MAKE %{?_smp_mflags} KERNELRELEASE=%{version} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
> cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE
> cp .config %{buildroot}/boot/config-$KERNELRELEASE
> $S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/build
> diff --git a/scripts/setlocalversion b/scripts/setlocalversion
> index af4754a35e66..3b31702b4a4a 100755
> --- a/scripts/setlocalversion
> +++ b/scripts/setlocalversion
> @@ -11,16 +11,11 @@
> #
>
> usage() {
> - echo "Usage: $0 [--save-scmversion] [srctree]" >&2
> + echo "Usage: $0 [srctree]" >&2
> exit 1
> }
>
> -scm_only=false
> srctree=.
> -if test "$1" = "--save-scmversion"; then
> - scm_only=true
> - shift
> -fi
> if test $# -gt 0; then
> srctree=$1
> shift
> @@ -35,10 +30,6 @@ scm_version()
> short=false
>
> cd "$srctree"
> - if test -e .scmversion; then
> - cat .scmversion
> - return
> - fi
> if test "$1" = "--short"; then
> short=true
> fi
> @@ -103,14 +94,6 @@ collect_files()
> echo "$res"
> }
>
> -if $scm_only; then
> - if test ! -e .scmversion; then
> - res=$(scm_version)
> - echo "$res" >.scmversion
> - fi
> - exit
> -fi
> -
> if ! test -e include/config/auto.conf; then
> echo "Error: kernelrelease not valid - run 'make prepare' to update it" >&2
> exit 1
> --
> 2.34.1
>
On Sat, Jan 28, 2023 at 12:08 AM Thierry Reding
<[email protected]> wrote:
>
> On Sun, Jan 22, 2023 at 11:14:21PM +0900, Masahiro Yamada wrote:
> > .scmversion is used by (src)rpm-pkg and deb-pkg to carry KERNELRELEASE.
> >
> > In fact, deb-pkg does not rely on it any more because the generated
> > debian/rules specifies KERNELRELEASE from the command line.
> >
> > Do likwise for (src)rpm-pkg, and remove this feature.
> >
> > Signed-off-by: Masahiro Yamada <[email protected]>
> > ---
> >
> > scripts/Makefile.package | 6 ++----
> > scripts/package/mkspec | 6 +++---
> > scripts/setlocalversion | 19 +------------------
> > 3 files changed, 6 insertions(+), 25 deletions(-)
>
> Hi Masahiro,
>
> I've been observing some strange behaviour when doing incremental builds
> on recent linux-next versions. What happens is that the kernel version
> doesn't get updated as I switch branches.
>
> For instance I was rebuilding in a kernel tree which I hadn't touched in
> a very long while and rebased on a recent linux-next. The kernel version
> then stayed at the prior version rather than being updated to reflect
> the actual state of the working tree.
>
> Reverting all of the seven patches in this series fixes the issue, but I
> don't really have a clue where exactly it fails. Do you have any ideas
> how to fix this?
Thanks for the report.
"setlocalversion: print ${KERNELRELEASE} if set" is bad.
I will fix it.
Best Regards
Masahiro Yamada
On Sun, Jan 22, 2023 at 11:14 PM Masahiro Yamada <[email protected]> wrote:
>
> When KERNELRELEASE is overridden, include/config/kernel.release still
> stores the string would be returned by the script if KERNELRELEASE had
> not been overridden. This is not strange.
>
> include/config/kernel.release should store KERNELRELEASE that was used
> for building the kernel.
>
> Signed-off-by: Masahiro Yamada <[email protected]>
I will drop this patch because a regression was reported.
https://lore.kernel.org/linux-kbuild/CAK7LNATc_aPxiYXabzYbGXOMUW0Rcf0KQi6GBPvoy71uPuqKPg@mail.gmail.com/T/#m514a0303841590f48f0446b70f56986b9f1402cc
> ---
>
> scripts/setlocalversion | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/scripts/setlocalversion b/scripts/setlocalversion
> index 7c7cbefa5aa4..eff8cc831571 100755
> --- a/scripts/setlocalversion
> +++ b/scripts/setlocalversion
> @@ -103,6 +103,11 @@ collect_files()
> echo "$res"
> }
>
> +if [ -n "${KERNELRELEASE}" ]; then
> + echo "${KERNELRELEASE}"
> + exit 0
> +fi
> +
> if ! test -e include/config/auto.conf; then
> echo "Error: kernelrelease not valid - run 'make prepare' to update it" >&2
> exit 1
> --
> 2.34.1
>
--
Best Regards
Masahiro Yamada
Hi Masahiro,
On Sun, Jan 22, 2023 at 11:14:21PM +0900, Masahiro Yamada wrote:
> .scmversion is used by (src)rpm-pkg and deb-pkg to carry KERNELRELEASE.
>
> In fact, deb-pkg does not rely on it any more because the generated
> debian/rules specifies KERNELRELEASE from the command line.
>
> Do likwise for (src)rpm-pkg, and remove this feature.
>
> Signed-off-by: Masahiro Yamada <[email protected]>
> ---
>
> scripts/Makefile.package | 6 ++----
> scripts/package/mkspec | 6 +++---
> scripts/setlocalversion | 19 +------------------
> 3 files changed, 6 insertions(+), 25 deletions(-)
>
> diff --git a/scripts/Makefile.package b/scripts/Makefile.package
> index 525a2820976f..e84c4e8ceb8e 100644
> --- a/scripts/Makefile.package
> +++ b/scripts/Makefile.package
> @@ -32,7 +32,7 @@ export KDEB_SOURCENAME
> TAR_CONTENT := Documentation LICENSES arch block certs crypto drivers fs \
> include init io_uring ipc kernel lib mm net rust \
> samples scripts security sound tools usr virt \
> - .config .scmversion Makefile \
> + .config Makefile \
> Kbuild Kconfig COPYING $(wildcard localversion*)
> MKSPEC := $(srctree)/scripts/package/mkspec
>
> @@ -47,10 +47,8 @@ if test "$(objtree)" != "$(srctree)"; then \
> echo >&2; \
> false; \
> fi ; \
> -$(srctree)/scripts/setlocalversion --save-scmversion; \
> tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \
> - --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3); \
> -rm -f $(objtree)/.scmversion
> + --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3)
>
> # rpm-pkg
> # ---------------------------------------------------------------------------
> diff --git a/scripts/package/mkspec b/scripts/package/mkspec
> index adab28fa7f89..d3c6701b7769 100755
> --- a/scripts/package/mkspec
> +++ b/scripts/package/mkspec
> @@ -90,7 +90,7 @@ $S rm -f scripts/basic/fixdep scripts/kconfig/conf
> $S rm -f tools/objtool/{fixdep,objtool}
> $S
> $S %build
> -$S $MAKE %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}
> +$S $MAKE %{?_smp_mflags} KERNELRELEASE=%{version} KBUILD_BUILD_VERSION=%{release}
> $S
> %install
> mkdir -p %{buildroot}/boot
> @@ -101,8 +101,8 @@ $S
> %else
> cp \$($MAKE -s image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE
> %endif
> -$M $MAKE %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} modules_install
> - $MAKE %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
> +$M $MAKE %{?_smp_mflags} KERNELRELEASE=%{version} INSTALL_MOD_PATH=%{buildroot} modules_install
> + $MAKE %{?_smp_mflags} KERNELRELEASE=%{version} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
> cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE
> cp .config %{buildroot}/boot/config-$KERNELRELEASE
> $S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/build
> diff --git a/scripts/setlocalversion b/scripts/setlocalversion
> index af4754a35e66..3b31702b4a4a 100755
> --- a/scripts/setlocalversion
> +++ b/scripts/setlocalversion
> @@ -11,16 +11,11 @@
> #
>
> usage() {
> - echo "Usage: $0 [--save-scmversion] [srctree]" >&2
> + echo "Usage: $0 [srctree]" >&2
> exit 1
> }
>
> -scm_only=false
> srctree=.
> -if test "$1" = "--save-scmversion"; then
> - scm_only=true
> - shift
> -fi
> if test $# -gt 0; then
> srctree=$1
> shift
> @@ -35,10 +30,6 @@ scm_version()
> short=false
>
> cd "$srctree"
> - if test -e .scmversion; then
> - cat .scmversion
> - return
> - fi
> if test "$1" = "--short"; then
> short=true
> fi
> @@ -103,14 +94,6 @@ collect_files()
> echo "$res"
> }
>
> -if $scm_only; then
> - if test ! -e .scmversion; then
> - res=$(scm_version)
> - echo "$res" >.scmversion
> - fi
> - exit
> -fi
> -
> if ! test -e include/config/auto.conf; then
> echo "Error: kernelrelease not valid - run 'make prepare' to update it" >&2
> exit 1
> --
> 2.34.1
>
I believe this patch causes issues with binrpm-pkg (I have not done a
full bisect, as I am not fully online today; the source path has been
replaced with $PWD):
$ make -skj"$(nproc)" ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- RPMOPTS="--define '_topdir $PWD/rpmbuild'" olddefconfig binrpm-pkg
...
Building target platforms: aarch64-linux
Building for target aarch64-linux
warning: line 23: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers
error: cannot open Packages database in /var/lib/rpm
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.targJq
+ umask 022
+ cd .
+ /usr/bin/rm -rf $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64
+ /usr/bin/mkdir -p $PWD/rpmbuild/BUILDROOT
+ /usr/bin/mkdir $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64
+ mkdir -p $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64/boot
++ make -f ./Makefile -s image_name
+ cp arch/arm64/boot/Image.gz $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64/boot/vmlinuz-6.2.0-rc5-next-20230127+
+ make -f ./Makefile -j128 KERNELRELEASE=6.2.0_rc5_next_20230127+ INSTALL_MOD_PATH=$PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64 modules_install
make[3]: warning: -j128 forced in submake: resetting jobserver mode.
+ make -f ./Makefile -j128 KERNELRELEASE=6.2.0_rc5_next_20230127+ INSTALL_HDR_PATH=$PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64/usr headers_install
make[3]: warning: -j128 forced in submake: resetting jobserver mode.
+ cp System.map $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64/boot/System.map-6.2.0-rc5-next-20230127+
+ cp .config $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64/boot/config-6.2.0-rc5-next-20230127+
+ /usr/lib/rpm/brp-compress
Processing files: kernel-6.2.0_rc5_next_20230127+-1.aarch64
error: File not found: $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64/lib/modules/6.2.0-rc5-next-20230127+
warning: File not found: $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64/lib/modules/6.2.0-rc5-next-20230127+/build
warning: File not found: $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64/lib/modules/6.2.0-rc5-next-20230127+/source
RPM build warnings:
line 23: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers
File not found: $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64/lib/modules/6.2.0-rc5-next-20230127+/build
File not found: $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64/lib/modules/6.2.0-rc5-next-20230127+/source
RPM build errors:
cannot open Packages database in /var/lib/rpm
File not found: $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64/lib/modules/6.2.0-rc5-next-20230127+
...
Cheers,
Nathan
On Sat, Jan 28, 2023 at 4:29 AM Nathan Chancellor <[email protected]> wrote:
>
> Hi Masahiro,
>
> On Sun, Jan 22, 2023 at 11:14:21PM +0900, Masahiro Yamada wrote:
> > .scmversion is used by (src)rpm-pkg and deb-pkg to carry KERNELRELEASE.
> >
> > In fact, deb-pkg does not rely on it any more because the generated
> > debian/rules specifies KERNELRELEASE from the command line.
> >
> > Do likwise for (src)rpm-pkg, and remove this feature.
> >
> > Signed-off-by: Masahiro Yamada <[email protected]>
> > ---
> >
> > scripts/Makefile.package | 6 ++----
> > scripts/package/mkspec | 6 +++---
> > scripts/setlocalversion | 19 +------------------
> > 3 files changed, 6 insertions(+), 25 deletions(-)
> >
> > diff --git a/scripts/Makefile.package b/scripts/Makefile.package
> > index 525a2820976f..e84c4e8ceb8e 100644
> > --- a/scripts/Makefile.package
> > +++ b/scripts/Makefile.package
> > @@ -32,7 +32,7 @@ export KDEB_SOURCENAME
> > TAR_CONTENT := Documentation LICENSES arch block certs crypto drivers fs \
> > include init io_uring ipc kernel lib mm net rust \
> > samples scripts security sound tools usr virt \
> > - .config .scmversion Makefile \
> > + .config Makefile \
> > Kbuild Kconfig COPYING $(wildcard localversion*)
> > MKSPEC := $(srctree)/scripts/package/mkspec
> >
> > @@ -47,10 +47,8 @@ if test "$(objtree)" != "$(srctree)"; then \
> > echo >&2; \
> > false; \
> > fi ; \
> > -$(srctree)/scripts/setlocalversion --save-scmversion; \
> > tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \
> > - --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3); \
> > -rm -f $(objtree)/.scmversion
> > + --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3)
> >
> > # rpm-pkg
> > # ---------------------------------------------------------------------------
> > diff --git a/scripts/package/mkspec b/scripts/package/mkspec
> > index adab28fa7f89..d3c6701b7769 100755
> > --- a/scripts/package/mkspec
> > +++ b/scripts/package/mkspec
> > @@ -90,7 +90,7 @@ $S rm -f scripts/basic/fixdep scripts/kconfig/conf
> > $S rm -f tools/objtool/{fixdep,objtool}
> > $S
> > $S %build
> > -$S $MAKE %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}
> > +$S $MAKE %{?_smp_mflags} KERNELRELEASE=%{version} KBUILD_BUILD_VERSION=%{release}
> > $S
> > %install
> > mkdir -p %{buildroot}/boot
> > @@ -101,8 +101,8 @@ $S
> > %else
> > cp \$($MAKE -s image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE
> > %endif
> > -$M $MAKE %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} modules_install
> > - $MAKE %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
> > +$M $MAKE %{?_smp_mflags} KERNELRELEASE=%{version} INSTALL_MOD_PATH=%{buildroot} modules_install
> > + $MAKE %{?_smp_mflags} KERNELRELEASE=%{version} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
> > cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE
> > cp .config %{buildroot}/boot/config-$KERNELRELEASE
> > $S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/build
> > diff --git a/scripts/setlocalversion b/scripts/setlocalversion
> > index af4754a35e66..3b31702b4a4a 100755
> > --- a/scripts/setlocalversion
> > +++ b/scripts/setlocalversion
> > @@ -11,16 +11,11 @@
> > #
> >
> > usage() {
> > - echo "Usage: $0 [--save-scmversion] [srctree]" >&2
> > + echo "Usage: $0 [srctree]" >&2
> > exit 1
> > }
> >
> > -scm_only=false
> > srctree=.
> > -if test "$1" = "--save-scmversion"; then
> > - scm_only=true
> > - shift
> > -fi
> > if test $# -gt 0; then
> > srctree=$1
> > shift
> > @@ -35,10 +30,6 @@ scm_version()
> > short=false
> >
> > cd "$srctree"
> > - if test -e .scmversion; then
> > - cat .scmversion
> > - return
> > - fi
> > if test "$1" = "--short"; then
> > short=true
> > fi
> > @@ -103,14 +94,6 @@ collect_files()
> > echo "$res"
> > }
> >
> > -if $scm_only; then
> > - if test ! -e .scmversion; then
> > - res=$(scm_version)
> > - echo "$res" >.scmversion
> > - fi
> > - exit
> > -fi
> > -
> > if ! test -e include/config/auto.conf; then
> > echo "Error: kernelrelease not valid - run 'make prepare' to update it" >&2
> > exit 1
> > --
> > 2.34.1
> >
>
> I believe this patch causes issues with binrpm-pkg (I have not done a
> full bisect, as I am not fully online today; the source path has been
> replaced with $PWD):
Thanks for the report.
%{version} contains underscores instead of hyphens.
So, it does not match to ${KERNELRELEASE} used during the build.
I will squash the following:
diff --git a/scripts/package/mkspec b/scripts/package/mkspec
index a73d25c76efe..cd4026208100 100755
--- a/scripts/package/mkspec
+++ b/scripts/package/mkspec
@@ -90,7 +90,7 @@ $S rm -f scripts/basic/fixdep scripts/kconfig/conf
$S rm -f tools/objtool/{fixdep,objtool}
$S
$S %build
-$S $MAKE %{?_smp_mflags} KERNELRELEASE=%{version}
KBUILD_BUILD_VERSION=%{release}
+$S $MAKE %{?_smp_mflags} KERNELRELEASE=$KERNELRELEASE
KBUILD_BUILD_VERSION=%{release}
$S
%install
mkdir -p %{buildroot}/boot
@@ -101,8 +101,8 @@ $S
%else
cp \$($MAKE -s image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE
%endif
-$M $MAKE %{?_smp_mflags} KERNELRELEASE=%{version}
INSTALL_MOD_PATH=%{buildroot} modules_install
- $MAKE %{?_smp_mflags} KERNELRELEASE=%{version}
INSTALL_HDR_PATH=%{buildroot}/usr headers_install
+$M $MAKE %{?_smp_mflags} KERNELRELEASE=$KERNELRELEASE
INSTALL_MOD_PATH=%{buildroot} modules_install
+ $MAKE %{?_smp_mflags} KERNELRELEASE=$KERNELRELEASE
INSTALL_HDR_PATH=%{buildroot}/usr headers_install
cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE
cp .config %{buildroot}/boot/config-$KERNELRELEASE
$S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/build
>
> $ make -skj"$(nproc)" ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- RPMOPTS="--define '_topdir $PWD/rpmbuild'" olddefconfig binrpm-pkg
> ...
> Building target platforms: aarch64-linux
> Building for target aarch64-linux
> warning: line 23: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers
> error: cannot open Packages database in /var/lib/rpm
> Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.targJq
> + umask 022
> + cd .
> + /usr/bin/rm -rf $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64
> + /usr/bin/mkdir -p $PWD/rpmbuild/BUILDROOT
> + /usr/bin/mkdir $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64
> + mkdir -p $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64/boot
> ++ make -f ./Makefile -s image_name
> + cp arch/arm64/boot/Image.gz $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64/boot/vmlinuz-6.2.0-rc5-next-20230127+
> + make -f ./Makefile -j128 KERNELRELEASE=6.2.0_rc5_next_20230127+ INSTALL_MOD_PATH=$PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64 modules_install
> make[3]: warning: -j128 forced in submake: resetting jobserver mode.
> + make -f ./Makefile -j128 KERNELRELEASE=6.2.0_rc5_next_20230127+ INSTALL_HDR_PATH=$PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64/usr headers_install
> make[3]: warning: -j128 forced in submake: resetting jobserver mode.
> + cp System.map $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64/boot/System.map-6.2.0-rc5-next-20230127+
> + cp .config $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64/boot/config-6.2.0-rc5-next-20230127+
> + /usr/lib/rpm/brp-compress
> Processing files: kernel-6.2.0_rc5_next_20230127+-1.aarch64
> error: File not found: $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64/lib/modules/6.2.0-rc5-next-20230127+
> warning: File not found: $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64/lib/modules/6.2.0-rc5-next-20230127+/build
> warning: File not found: $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64/lib/modules/6.2.0-rc5-next-20230127+/source
>
> RPM build warnings:
> line 23: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers
> File not found: $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64/lib/modules/6.2.0-rc5-next-20230127+/build
> File not found: $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64/lib/modules/6.2.0-rc5-next-20230127+/source
>
> RPM build errors:
> cannot open Packages database in /var/lib/rpm
> File not found: $PWD/rpmbuild/BUILDROOT/kernel-6.2.0_rc5_next_20230127+-1.aarch64/lib/modules/6.2.0-rc5-next-20230127+
> ...
>
> Cheers,
> Nathan
--
Best Regards
Masahiro Yamada
On Sun 22 Jan 2023 23:14:21 GMT, Masahiro Yamada wrote:
> .scmversion is used by (src)rpm-pkg and deb-pkg to carry
> KERNELRELEASE.
>
> In fact, deb-pkg does not rely on it any more because the generated
> debian/rules specifies KERNELRELEASE from the command line.
>
> Do likwise for (src)rpm-pkg, and remove this feature.
>
> Signed-off-by: Masahiro Yamada <[email protected]>
> ---
>
> scripts/Makefile.package | 6 ++----
> scripts/package/mkspec | 6 +++---
> scripts/setlocalversion | 19 +------------------
> 3 files changed, 6 insertions(+), 25 deletions(-)
>
> diff --git a/scripts/Makefile.package b/scripts/Makefile.package
> index 525a2820976f..e84c4e8ceb8e 100644
> --- a/scripts/Makefile.package
> +++ b/scripts/Makefile.package
> @@ -32,7 +32,7 @@ export KDEB_SOURCENAME
> TAR_CONTENT := Documentation LICENSES arch block certs crypto drivers fs \
> include init io_uring ipc kernel lib mm net rust \
> samples scripts security sound tools usr virt \
> - .config .scmversion Makefile \
> + .config Makefile \
> Kbuild Kconfig COPYING $(wildcard localversion*)
> MKSPEC := $(srctree)/scripts/package/mkspec
>
> @@ -47,10 +47,8 @@ if test "$(objtree)" != "$(srctree)"; then \
> echo >&2; \
> false; \
> fi ; \
> -$(srctree)/scripts/setlocalversion --save-scmversion; \
> tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \
> - --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3); \
> -rm -f $(objtree)/.scmversion
> + --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3)
>
> # rpm-pkg
> # ---------------------------------------------------------------------------
> diff --git a/scripts/package/mkspec b/scripts/package/mkspec
> index adab28fa7f89..d3c6701b7769 100755
> --- a/scripts/package/mkspec
> +++ b/scripts/package/mkspec
> @@ -90,7 +90,7 @@ $S rm -f scripts/basic/fixdep scripts/kconfig/conf
> $S rm -f tools/objtool/{fixdep,objtool}
> $S
> $S %build
> -$S $MAKE %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}
> +$S $MAKE %{?_smp_mflags} KERNELRELEASE=%{version} KBUILD_BUILD_VERSION=%{release}
> $S
> %install
> mkdir -p %{buildroot}/boot
> @@ -101,8 +101,8 @@ $S
> %else
> cp \$($MAKE -s image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE
> %endif
> -$M $MAKE %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} modules_install
> - $MAKE %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
> +$M $MAKE %{?_smp_mflags} KERNELRELEASE=%{version} INSTALL_MOD_PATH=%{buildroot} modules_install
> + $MAKE %{?_smp_mflags} KERNELRELEASE=%{version} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
> cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE
> cp .config %{buildroot}/boot/config-$KERNELRELEASE
> $S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/build
> diff --git a/scripts/setlocalversion b/scripts/setlocalversion
> index af4754a35e66..3b31702b4a4a 100755
> --- a/scripts/setlocalversion
> +++ b/scripts/setlocalversion
> @@ -11,16 +11,11 @@
> #
>
> usage() {
> - echo "Usage: $0 [--save-scmversion] [srctree]" >&2
> + echo "Usage: $0 [srctree]" >&2
Hi Masahiro,
as .scmversion will not we generated (or removed by 'make clean' or
'make mrproper'), might it make sense to add it to
scripts/remove-stale-files?
Reviewed-by: Nicolas Schier <[email protected]>
Kind regards,
Nicolas
On Sun 22 Jan 2023 23:14:23 GMT, Masahiro Yamada wrote:
> Return earlier if we are not in the correct git repository. This makes
> the code more readable.
>
> Signed-off-by: Masahiro Yamada <[email protected]>
> ---
>
> scripts/setlocalversion | 79 +++++++++++++++++++++--------------------
> 1 file changed, 41 insertions(+), 38 deletions(-)
>
> diff --git a/scripts/setlocalversion b/scripts/setlocalversion
> index 5cdf409204aa..b8e1018d611e 100755
> --- a/scripts/setlocalversion
> +++ b/scripts/setlocalversion
> @@ -34,46 +34,49 @@ scm_version()
> short=true
> fi
>
> - # Check for git and a git repo.
> - if test -z "$(git rev-parse --show-cdup 2>/dev/null)" &&
> - head=$(git rev-parse --verify HEAD 2>/dev/null); then
> -
> - # 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
> -
> - # If only the short version is requested, don't bother
> - # running further git commands
> - if $short; then
> - 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
> - echo "$atag" | awk -F- '{printf("-%05d", $(NF-1))}'
> - fi
> -
> - # Add -g and exactly 12 hex chars.
> - printf '%s%s' -g "$(echo $head | cut -c1-12)"
> - fi
> + if test -n "$(git rev-parse --show-cdup 2>/dev/null)"; then
> + return
> + fi
> +
> + if ! head=$(git rev-parse --verify HEAD 2>/dev/null); then
> + 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
>
> - # Check for uncommitted changes.
> - # This script must avoid any write attempt to the source tree,
> - # which might be read-only.
> - # You cannot use 'git describe --dirty' because it tries to
> - # create .git/index.lock .
> - # First, with git-status, but --no-optional-locks is only
> - # supported in git >= 2.14, so fall back to git-diff-index if
> - # it fails. Note that git-diff-index does not refresh the
> - # index, so it may give misleading results. See
> - # git-update-index(1), git-diff-index(1), and git-status(1).
> - if {
> - git --no-optional-locks status -uno --porcelain 2>/dev/null ||
> - git diff-index --name-only HEAD
> - } | read dummy; then
> - printf '%s' -dirty
> + # If only the short version is requested, don't bother
> + # running further git commands
> + if $short; then
> + 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
> + echo "$atag" | awk -F- '{printf("-%05d", $(NF-1))}'
> + fi
> +
> + # Add -g and exactly 12 hex chars.
> + printf '%s%s' -g "$(echo $head | cut -c1-12)"
> + fi
> +
> + # Check for uncommitted changes.
> + # This script must avoid any write attempt to the source tree, which
> + # might be read-only.
> + # You cannot use 'git describe --dirty' because it tries to create
> + # .git/index.lock .
> + # First, with git-status, but --no-optional-locks is only supported in
> + # git >= 2.14, so fall back to git-diff-index if it fails. Note that
> + # git-diff-index does not refresh the index, so it may give misleading
> + # results.
> + # See git-update-index(1), git-diff-index(1), and git-status(1).
> + if {
> + git --no-optional-locks status -uno --porcelain 2>/dev/null ||
> + git diff-index --name-only HEAD
> + } | read dummy; then
> + printf '%s' -dirty
> fi
> }
>
> --
> 2.34.1
Reviewed-by: Nicolas Schier <[email protected]>
On Mon, Jan 30, 2023 at 6:29 AM Nicolas Schier <[email protected]> wrote:
>
> On Sun 22 Jan 2023 23:14:21 GMT, Masahiro Yamada wrote:
> > .scmversion is used by (src)rpm-pkg and deb-pkg to carry
> > KERNELRELEASE.
> >
> > In fact, deb-pkg does not rely on it any more because the generated
> > debian/rules specifies KERNELRELEASE from the command line.
> >
> > Do likwise for (src)rpm-pkg, and remove this feature.
> >
> > Signed-off-by: Masahiro Yamada <[email protected]>
> > ---
> >
> > scripts/Makefile.package | 6 ++----
> > scripts/package/mkspec | 6 +++---
> > scripts/setlocalversion | 19 +------------------
> > 3 files changed, 6 insertions(+), 25 deletions(-)
> >
> > diff --git a/scripts/Makefile.package b/scripts/Makefile.package
> > index 525a2820976f..e84c4e8ceb8e 100644
> > --- a/scripts/Makefile.package
> > +++ b/scripts/Makefile.package
> > @@ -32,7 +32,7 @@ export KDEB_SOURCENAME
> > TAR_CONTENT := Documentation LICENSES arch block certs crypto drivers fs \
> > include init io_uring ipc kernel lib mm net rust \
> > samples scripts security sound tools usr virt \
> > - .config .scmversion Makefile \
> > + .config Makefile \
> > Kbuild Kconfig COPYING $(wildcard localversion*)
> > MKSPEC := $(srctree)/scripts/package/mkspec
> >
> > @@ -47,10 +47,8 @@ if test "$(objtree)" != "$(srctree)"; then \
> > echo >&2; \
> > false; \
> > fi ; \
> > -$(srctree)/scripts/setlocalversion --save-scmversion; \
> > tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \
> > - --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3); \
> > -rm -f $(objtree)/.scmversion
> > + --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3)
> >
> > # rpm-pkg
> > # ---------------------------------------------------------------------------
> > diff --git a/scripts/package/mkspec b/scripts/package/mkspec
> > index adab28fa7f89..d3c6701b7769 100755
> > --- a/scripts/package/mkspec
> > +++ b/scripts/package/mkspec
> > @@ -90,7 +90,7 @@ $S rm -f scripts/basic/fixdep scripts/kconfig/conf
> > $S rm -f tools/objtool/{fixdep,objtool}
> > $S
> > $S %build
> > -$S $MAKE %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}
> > +$S $MAKE %{?_smp_mflags} KERNELRELEASE=%{version} KBUILD_BUILD_VERSION=%{release}
> > $S
> > %install
> > mkdir -p %{buildroot}/boot
> > @@ -101,8 +101,8 @@ $S
> > %else
> > cp \$($MAKE -s image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE
> > %endif
> > -$M $MAKE %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} modules_install
> > - $MAKE %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
> > +$M $MAKE %{?_smp_mflags} KERNELRELEASE=%{version} INSTALL_MOD_PATH=%{buildroot} modules_install
> > + $MAKE %{?_smp_mflags} KERNELRELEASE=%{version} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
> > cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE
> > cp .config %{buildroot}/boot/config-$KERNELRELEASE
> > $S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/build
> > diff --git a/scripts/setlocalversion b/scripts/setlocalversion
> > index af4754a35e66..3b31702b4a4a 100755
> > --- a/scripts/setlocalversion
> > +++ b/scripts/setlocalversion
> > @@ -11,16 +11,11 @@
> > #
> >
> > usage() {
> > - echo "Usage: $0 [--save-scmversion] [srctree]" >&2
> > + echo "Usage: $0 [srctree]" >&2
>
> Hi Masahiro,
>
> as .scmversion will not we generated (or removed by 'make clean' or
> 'make mrproper'), might it make sense to add it to
> scripts/remove-stale-files?
>
> Reviewed-by: Nicolas Schier <[email protected]>
>
> Kind regards,
> Nicolas
Good point.
.scmversion is removed after the tarball is created
(see "rm -f $(objtree)/.scmversion"), but
it is left over if the user interrupts while the
tarball is being created.
I will fold it locally.
Thanks.
--
Best Regards
Masahiro Yamada
On Sun, Jan 22, 2023 at 11:14 PM Masahiro Yamada <[email protected]> wrote:
>
> Revert:
> - 7b8ea53d7f18 ("makefile: not need to regenerate kernel.release
> file when make kernelrelease")
>
> - 01ab17887f4c ("Makefile: "make kernelrelease" should show the
> correct full kernel version")
>
> I think the original behavior was better - 'make kernelrelease' should
> print $(KERNELRELEASE) used in the last build, not the one that will
> be used in the next build. Therefore, it is an error if you run it in
> the pristine source tree.
>
> Signed-off-by: Masahiro Yamada <[email protected]>
I locally got a question about this, and
on second thought, this might be annoying
because you need to build something to get kernelrelease.
I will drop this commit.
--
Best Regards
Masahiro Yamada
On Sun 22 Jan 2023 23:14:22 GMT, Masahiro Yamada wrote:
> With the --short option given, scm_version() prints "+".
> Just append it.
>
> Signed-off-by: Masahiro Yamada <[email protected]>
> ---
>
> scripts/setlocalversion | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/scripts/setlocalversion b/scripts/setlocalversion
> index 3b31702b4a4a..5cdf409204aa 100755
> --- a/scripts/setlocalversion
> +++ b/scripts/setlocalversion
> @@ -121,8 +121,7 @@ elif [ "${LOCALVERSION+set}" != "set" ]; then
> #
> # If the variable LOCALVERSION is set (including being set
> # to an empty string), we don't want to append a plus sign.
> - scm=$(scm_version --short)
> - res="$res${scm:++}"
> + res="$res$(scm_version --short)"
> fi
>
> echo "$res"
> --
> 2.34.1
Reviewed-by: Nicolas Schier <[email protected]>
On Sun, Jan 22, 2023 at 11:14 PM Masahiro Yamada <[email protected]> wrote:
>
> 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 <[email protected]>
I will drop this patch,
and send an alternative one.
--
Best Regards
Masahiro Yamada