diff mbox series

[1/7] kbuild: do not put .scmversion into the source tarball

Message ID 20230122141428.115372-1-masahiroy@kernel.org (mailing list archive)
State New, archived
Headers show
Series [1/7] kbuild: do not put .scmversion into the source tarball | expand

Commit Message

Masahiro Yamada Jan. 22, 2023, 2:14 p.m. UTC
.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 <masahiroy@kernel.org>
---

 scripts/Makefile.package |  6 ++----
 scripts/package/mkspec   |  6 +++---
 scripts/setlocalversion  | 19 +------------------
 3 files changed, 6 insertions(+), 25 deletions(-)

Comments

Thierry Reding Jan. 27, 2023, 3:07 p.m. UTC | #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 <masahiroy@kernel.org>
> ---
> 
>  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
>
Masahiro Yamada Jan. 27, 2023, 3:50 p.m. UTC | #2
On Sat, Jan 28, 2023 at 12:08 AM Thierry Reding
<thierry.reding@gmail.com> 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 <masahiroy@kernel.org>
> > ---
> >
> >  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
Nathan Chancellor Jan. 27, 2023, 7:29 p.m. UTC | #3
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 <masahiroy@kernel.org>
> ---
> 
>  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
Masahiro Yamada Jan. 28, 2023, 1:11 a.m. UTC | #4
On Sat, Jan 28, 2023 at 4:29 AM Nathan Chancellor <nathan@kernel.org> 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 <masahiroy@kernel.org>
> > ---
> >
> >  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
Nicolas Schier Jan. 29, 2023, 9:29 p.m. UTC | #5
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 <masahiroy@kernel.org>
> ---
> 
>  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 <nicolas@fjasle.eu>

Kind regards,
Nicolas
Masahiro Yamada Jan. 30, 2023, 1:44 a.m. UTC | #6
On Mon, Jan 30, 2023 at 6:29 AM Nicolas Schier <nicolas@fjasle.eu> 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 <masahiroy@kernel.org>
> > ---
> >
> >  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 <nicolas@fjasle.eu>
>
> 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.
diff mbox series

Patch

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