diff mbox series

[v2,4/5] kbuild: srcrpm-pkg: create source package without cleaning

Message ID 20230129184602.3974058-4-masahiroy@kernel.org (mailing list archive)
State New, archived
Headers show
Series [v2,1/5] kbuild: add a tool to generate a list of files ignored by git | expand

Commit Message

Masahiro Yamada Jan. 29, 2023, 6:46 p.m. UTC
If you run 'make (src)rpm-pkg', all objects are lost due to 'make clean',
which makes the incremental builds impossible.

Instead of cleaning, pass the exclude list to tar's --exclude-from
option.

Previously, the .config was contained in the source tarball.

With this commit, the source rpm consists of separate linux.tar.gz
and .config.

Remove stale comments. Now, 'make (src)rpm-pkg' works with O= option.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

(no changes since v1)

 scripts/Makefile.package | 50 +++-------------------------------------
 scripts/package/mkspec   |  8 +++----
 2 files changed, 7 insertions(+), 51 deletions(-)

Comments

Miguel Ojeda Jan. 29, 2023, 11:20 p.m. UTC | #1
On Sun, Jan 29, 2023 at 7:46 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> -               include init io_uring ipc kernel lib mm net rust \

For Rust, it is early to deal with packaging, so removing this from
here should not hurt.

In any case, I quickly tried the series and noticed that the
`.src.rpm` does not end in the `SRPMS` folder (as it did before) -- is
that expected?

Thanks!

Cheers,
Miguel
Masahiro Yamada Jan. 30, 2023, 1:28 a.m. UTC | #2
On Mon, Jan 30, 2023 at 8:20 AM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On Sun, Jan 29, 2023 at 7:46 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > -               include init io_uring ipc kernel lib mm net rust \
>
> For Rust, it is early to deal with packaging, so removing this from
> here should not hurt.

I guess you are talking about kernel-devel-*.rpm
(and linux-headers-.deb).

They are not useful for building external modules
written in Rust since they do not contain *.rmeta etc.
I am not caring about that because Rust support is not
mature enough yet.


This series does not touch binary packages,
rather it just changes how the source package is created.

I stopped hard-coding the top-level directories.
The resulting source package still contains all check-in files
under rust/, so it is good from the source package perspective.




> In any case, I quickly tried the series and noticed that the
> `.src.rpm` does not end in the `SRPMS` folder (as it did before) -- is
> that expected?


5/5 changed the behavior because rpm-pkg re-uses the
*.src.rpm generated by srcrpm-pkg.


Having *.src.rpm in the kernel tree seems Redhat's preference.
Commit 8818039f959b2efc0d6f2cb101f8061332f0c77e
added --define='_srcrpmdir $(srctree)'.



In contrast, binary rpm files are generated under rpmbuild/RPMS/.
I want to fix this inconsistency, though.
Miguel Ojeda Jan. 30, 2023, noon UTC | #3
On Mon, Jan 30, 2023 at 2:29 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> I guess you are talking about kernel-devel-*.rpm
> (and linux-headers-.deb).
>
> They are not useful for building external modules
> written in Rust since they do not contain *.rmeta etc.
> I am not caring about that because Rust support is not
> mature enough yet.

Yeah, that is what I meant, i.e. since the Rust ML was Cc'd, I checked
and wanted to say removing `rust` from there was OK (an `Acked-by`
seemed too much for just that line :).

> I stopped hard-coding the top-level directories.
> The resulting source package still contains all check-in files
> under rust/, so it is good from the source package perspective.

Sounds good to me.

> 5/5 changed the behavior because rpm-pkg re-uses the
> *.src.rpm generated by srcrpm-pkg.

(3/5?)

> Having *.src.rpm in the kernel tree seems Redhat's preference.
> Commit 8818039f959b2efc0d6f2cb101f8061332f0c77e
> added --define='_srcrpmdir $(srctree)'.

Thanks for the details! I just noticed it, so I thought I would let
you know just in case.

(Perhaps it could be useful to mention this change in the output in
the commit message.)

> In contrast, binary rpm files are generated under rpmbuild/RPMS/.
> I want to fix this inconsistency, though.

That would be nice.

Cheers,
Miguel
Masahiro Yamada Jan. 31, 2023, 4:29 p.m. UTC | #4
On Mon, Jan 30, 2023 at 9:00 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On Mon, Jan 30, 2023 at 2:29 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > I guess you are talking about kernel-devel-*.rpm
> > (and linux-headers-.deb).
> >
> > They are not useful for building external modules
> > written in Rust since they do not contain *.rmeta etc.
> > I am not caring about that because Rust support is not
> > mature enough yet.
>
> Yeah, that is what I meant, i.e. since the Rust ML was Cc'd, I checked
> and wanted to say removing `rust` from there was OK (an `Acked-by`
> seemed too much for just that line :).
>
> > I stopped hard-coding the top-level directories.
> > The resulting source package still contains all check-in files
> > under rust/, so it is good from the source package perspective.
>
> Sounds good to me.
>
> > 5/5 changed the behavior because rpm-pkg re-uses the
> > *.src.rpm generated by srcrpm-pkg.
>
> (3/5?)


Yes.


>
> > Having *.src.rpm in the kernel tree seems Redhat's preference.
> > Commit 8818039f959b2efc0d6f2cb101f8061332f0c77e
> > added --define='_srcrpmdir $(srctree)'.
>
> Thanks for the details! I just noticed it, so I thought I would let
> you know just in case.
>
> (Perhaps it could be useful to mention this change in the output in
> the commit message.)


Fair enough.

I updated the commit description in v3.


>
> > In contrast, binary rpm files are generated under rpmbuild/RPMS/.
> > I want to fix this inconsistency, though.
>
> That would be nice.
>
> Cheers,
> Miguel
diff mbox series

Patch

diff --git a/scripts/Makefile.package b/scripts/Makefile.package
index 97e146885e53..0e16ecfddad6 100644
--- a/scripts/Makefile.package
+++ b/scripts/Makefile.package
@@ -3,53 +3,11 @@ 
 
 include $(srctree)/scripts/Kbuild.include
 
-# RPM target
-# ---------------------------------------------------------------------------
-# The rpm target generates two rpm files:
-# /usr/src/packages/SRPMS/kernel-2.6.7rc2-1.src.rpm
-# /usr/src/packages/RPMS/i386/kernel-2.6.7rc2-1.<arch>.rpm
-# The src.rpm files includes all source for the kernel being built
-# The <arch>.rpm includes kernel configuration, modules etc.
-#
-# Process to create the rpm files
-# a) clean the kernel
-# b) Generate .spec file
-# c) Build a tar ball, using symlink to make kernel version
-#    first entry in the path
-# d) and pack the result to a tar.gz file
-# e) generate the rpm files, based on kernel.spec
-# - Use /. to avoid tar packing just the symlink
-
-# Note that the rpm-pkg target cannot be used with KBUILD_OUTPUT,
-# but the binrpm-pkg target can; for some reason O= gets ignored.
-
-# Remove hyphens since they have special meaning in RPM filenames
-KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE))
 KDEB_SOURCENAME ?= linux-upstream
 KBUILD_PKG_ROOTCMD ?="fakeroot -u"
 export KDEB_SOURCENAME
-# Include only those top-level files that are needed by make, plus the GPL copy
-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 Makefile \
-               Kbuild Kconfig COPYING $(wildcard localversion*)
 MKSPEC     := $(srctree)/scripts/package/mkspec
 
-quiet_cmd_src_tar = TAR     $(2).tar.gz
-      cmd_src_tar = \
-if test "$(objtree)" != "$(srctree)"; then \
-	echo >&2; \
-	echo >&2 "  ERROR:"; \
-	echo >&2 "  Building source tarball is not possible outside the"; \
-	echo >&2 "  kernel source tree. Don't set KBUILD_OUTPUT, or use the"; \
-	echo >&2 "  binrpm-pkg or bindeb-pkg target instead."; \
-	echo >&2; \
-	false; \
-fi ; \
-tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \
-	--transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3)
-
 # Source Tarball
 # ---------------------------------------------------------------------------
 
@@ -80,12 +38,10 @@  rpm-pkg: srcrpm-pkg
 # srcrpm-pkg
 # ---------------------------------------------------------------------------
 PHONY += srcrpm-pkg
-srcrpm-pkg:
-	$(MAKE) clean
+srcrpm-pkg: linux.tar.gz
 	$(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
-	$(call cmd,src_tar,$(KERNELPATH),kernel.spec)
-	+rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -ts $(KERNELPATH).tar.gz \
-	--define='_smp_mflags %{nil}' --define='_srcrpmdir $(srctree)'
+	+rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -bs kernel.spec \
+	--define='_smp_mflags %{nil}' --define='_sourcedir .' --define='_srcrpmdir .'
 
 # binrpm-pkg
 # ---------------------------------------------------------------------------
diff --git a/scripts/package/mkspec b/scripts/package/mkspec
index 108c0cb95436..83a64d9d7372 100755
--- a/scripts/package/mkspec
+++ b/scripts/package/mkspec
@@ -47,7 +47,8 @@  sed -e '/^DEL/d' -e 's/^\t*//' <<EOF
 	Group: System Environment/Kernel
 	Vendor: The Linux Community
 	URL: https://www.kernel.org
-$S	Source: kernel-$__KERNELRELEASE.tar.gz
+$S	Source0: linux.tar.gz
+$S	Source1: .config
 	Provides: $PROVIDES
 $S	BuildRequires: bc binutils bison dwarves
 $S	BuildRequires: (elfutils-libelf-devel or libelf-devel) flex
@@ -83,9 +84,8 @@  $S$M	This package provides kernel headers and makefiles sufficient to build modu
 $S$M	against the $__KERNELRELEASE kernel package.
 $S$M
 $S	%prep
-$S	%setup -q
-$S	rm -f scripts/basic/fixdep scripts/kconfig/conf
-$S	rm -f tools/objtool/{fixdep,objtool}
+$S	%setup -q -n linux
+$S	cp %{SOURCE1} .
 $S
 $S	%build
 $S	$MAKE %{?_smp_mflags} KERNELRELEASE=$KERNELRELEASE KBUILD_BUILD_VERSION=%{release}