diff mbox series

[v6,12/12] kbuild: add srcdeb-pkg target

Message ID 20230215012034.403356-12-masahiroy@kernel.org (mailing list archive)
State New, archived
Headers show
Series [v6,01/12] kbuild: add a tool to list files ignored by git | expand

Commit Message

Masahiro Yamada Feb. 15, 2023, 1:20 a.m. UTC
This new target builds only the debian source package.

Factor similar code out to the 'build-deb-pkg' variable.

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

Changes in v6:
  - New patch

 scripts/Makefile.package | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

Comments

Nicolas Schier Feb. 24, 2023, 10:48 p.m. UTC | #1
On Wed, Feb 15, 2023 at 10:20:34AM +0900 Masahiro Yamada wrote:
> This new target builds only the debian source package.
> 
> Factor similar code out to the 'build-deb-pkg' variable.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
> Changes in v6:
>   - New patch
> 
>  scripts/Makefile.package | 23 ++++++++++++++++++++---
>  1 file changed, 20 insertions(+), 3 deletions(-)
> 
> diff --git a/scripts/Makefile.package b/scripts/Makefile.package
> index b941e6341b36..8650d9432c26 100644
> --- a/scripts/Makefile.package
> +++ b/scripts/Makefile.package
> @@ -100,6 +100,9 @@ binrpm-pkg:
>  	+rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
>  		$(UTS_MACHINE)-linux -bb $(objtree)/binkernel.spec
>  
> +# deb-pkg srcdeb-pkg bindeb-pkg
> +# ---------------------------------------------------------------------------
> +
>  quiet_cmd_debianize = GEN     $@
>        cmd_debianize = $(srctree)/scripts/package/mkdebian
>  
> @@ -117,14 +120,27 @@ debian-orig: linux.tar.gz debian
>  		cp $< ../$(orig-name); \
>  	fi
>  
> +build-deb-pkg = \
> +        dpkg-buildpackage \
> +        --build=$(build-type) --no-pre-clean --unsigned-changes \
> +        $(if $(findstring source, $(build-type)), --unsigned-source) \
> +        $(if $(findstring binary, $(build-type)), -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch)) \
> +        $(DPKG_FLAGS)
> +
>  PHONY += deb-pkg
> +deb-pkg: private build-type := source,binary
>  deb-pkg: debian-orig
> -	+dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) \
> -		--build=source,binary -nc -us -uc
> +	+$(build-deb-pkg)
> +
> +PHONY += srcdeb-pkg
> +srcdeb-pkg: private build-type := source
> +srcdeb-pkg: debian-orig
> +	+$(build-deb-pkg)
>  
>  PHONY += bindeb-pkg
> +bindeb-pkg: private build-type := binary
>  bindeb-pkg: debian
> -	+dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -b -nc -uc
> +	+$(build-deb-pkg)
>  
>  PHONY += intdeb-pkg
>  intdeb-pkg:
> @@ -225,6 +241,7 @@ help:
>  	@echo '  srcrpm-pkg          - Build only the source kernel RPM package'
>  	@echo '  binrpm-pkg          - Build only the binary kernel RPM package'
>  	@echo '  deb-pkg             - Build both source and binary deb kernel packages'
> +	@echo '  binsrc-pkg          - Build only the source kernel deb package'

typo: srcdeb-dpkg

With this typo fixed:
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

>  	@echo '  bindeb-pkg          - Build only the binary kernel deb package'
>  	@echo '  snap-pkg            - Build only the binary kernel snap package'
>  	@echo '                        (will connect to external hosts)'
> -- 
> 2.34.1

Thanks for the patch (and the whole patch set), I appreciate it!

While testing, I stumbled over one thing, not really related to this patch:

As tar complains about any kind of tree changes while it creates an archive,
'olddefconfig' and 'srcdeb-pkg' must not be build at the same time.  Is it
sensible to add another 'mixed-build' check in top-level Makefile against all
target depending on linux.tar.gz?

    $ make olddefconfig srcdeb-pkg -j8
    #
    # No change to .config
    #
      GEN     debian
      UPD     .tmp_filelist
      TAR     linux.tar.gz
    tar: .: file changed as we read it
    make[2]: *** [scripts/Makefile.package:58: linux.tar.gz] Error 1
    make[2]: *** Deleting file 'linux.tar.gz'
    make[1]: *** [Makefile:1654: srcdeb-pkg] Error 2
    make: *** [Makefile:358: __build_one_by_one] Error 2

Kind regards,
Nicolas
Masahiro Yamada Feb. 25, 2023, 10:14 a.m. UTC | #2
On Sat, Feb 25, 2023 at 7:48 AM Nicolas Schier <nicolas@fjasle.eu> wrote:
>
> On Wed, Feb 15, 2023 at 10:20:34AM +0900 Masahiro Yamada wrote:
> > This new target builds only the debian source package.
> >
> > Factor similar code out to the 'build-deb-pkg' variable.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> >
> > Changes in v6:
> >   - New patch
> >
> >  scripts/Makefile.package | 23 ++++++++++++++++++++---
> >  1 file changed, 20 insertions(+), 3 deletions(-)
> >
> > diff --git a/scripts/Makefile.package b/scripts/Makefile.package
> > index b941e6341b36..8650d9432c26 100644
> > --- a/scripts/Makefile.package
> > +++ b/scripts/Makefile.package
> > @@ -100,6 +100,9 @@ binrpm-pkg:
> >       +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
> >               $(UTS_MACHINE)-linux -bb $(objtree)/binkernel.spec
> >
> > +# deb-pkg srcdeb-pkg bindeb-pkg
> > +# ---------------------------------------------------------------------------
> > +
> >  quiet_cmd_debianize = GEN     $@
> >        cmd_debianize = $(srctree)/scripts/package/mkdebian
> >
> > @@ -117,14 +120,27 @@ debian-orig: linux.tar.gz debian
> >               cp $< ../$(orig-name); \
> >       fi
> >
> > +build-deb-pkg = \
> > +        dpkg-buildpackage \
> > +        --build=$(build-type) --no-pre-clean --unsigned-changes \
> > +        $(if $(findstring source, $(build-type)), --unsigned-source) \
> > +        $(if $(findstring binary, $(build-type)), -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch)) \
> > +        $(DPKG_FLAGS)
> > +
> >  PHONY += deb-pkg
> > +deb-pkg: private build-type := source,binary
> >  deb-pkg: debian-orig
> > -     +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) \
> > -             --build=source,binary -nc -us -uc
> > +     +$(build-deb-pkg)
> > +
> > +PHONY += srcdeb-pkg
> > +srcdeb-pkg: private build-type := source
> > +srcdeb-pkg: debian-orig
> > +     +$(build-deb-pkg)
> >
> >  PHONY += bindeb-pkg
> > +bindeb-pkg: private build-type := binary
> >  bindeb-pkg: debian
> > -     +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -b -nc -uc
> > +     +$(build-deb-pkg)
> >
> >  PHONY += intdeb-pkg
> >  intdeb-pkg:
> > @@ -225,6 +241,7 @@ help:
> >       @echo '  srcrpm-pkg          - Build only the source kernel RPM package'
> >       @echo '  binrpm-pkg          - Build only the binary kernel RPM package'
> >       @echo '  deb-pkg             - Build both source and binary deb kernel packages'
> > +     @echo '  binsrc-pkg          - Build only the source kernel deb package'
>
> typo: srcdeb-dpkg

I will fix. Thanks.


>
> With this typo fixed:
> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
>
> >       @echo '  bindeb-pkg          - Build only the binary kernel deb package'
> >       @echo '  snap-pkg            - Build only the binary kernel snap package'
> >       @echo '                        (will connect to external hosts)'
> > --
> > 2.34.1
>
> Thanks for the patch (and the whole patch set), I appreciate it!
>
> While testing, I stumbled over one thing, not really related to this patch:
>
> As tar complains about any kind of tree changes while it creates an archive,
> 'olddefconfig' and 'srcdeb-pkg' must not be build at the same time.  Is it
> sensible to add another 'mixed-build' check in top-level Makefile against all
> target depending on linux.tar.gz?
>
>     $ make olddefconfig srcdeb-pkg -j8

This is already done.

The mixture of config targets and non-config targets
are treated as mixed-build. [1]
So, Kbuild internally divides it into 'make olddefconfig -j8'
followed by 'make srcdeb-pkg -j8'.


[1] https://github.com/torvalds/linux/blob/v6.2/Makefile#L335





>     #
>     # No change to .config
>     #
>       GEN     debian
>       UPD     .tmp_filelist
>       TAR     linux.tar.gz
>     tar: .: file changed as we read it
>     make[2]: *** [scripts/Makefile.package:58: linux.tar.gz] Error 1
>     make[2]: *** Deleting file 'linux.tar.gz'
>     make[1]: *** [Makefile:1654: srcdeb-pkg] Error 2
>     make: *** [Makefile:358: __build_one_by_one] Error 2


I ran the same command, but I could not reproduce this.





>
> Kind regards,
> Nicolas
Nicolas Schier March 1, 2023, 8:41 p.m. UTC | #3
On Sat 25 Feb 2023 19:14:30 GMT, Masahiro Yamada wrote:
> 
> On Sat, Feb 25, 2023 at 7:48 AM Nicolas Schier <nicolas@fjasle.eu> wrote:
> >
> > On Wed, Feb 15, 2023 at 10:20:34AM +0900 Masahiro Yamada wrote:
> > > This new target builds only the debian source package.
> > >
> > > Factor similar code out to the 'build-deb-pkg' variable.
> > >
> > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > > ---
[...]
> >
> > While testing, I stumbled over one thing, not really related to this patch:
> >
> > As tar complains about any kind of tree changes while it creates an archive,
> > 'olddefconfig' and 'srcdeb-pkg' must not be build at the same time.  Is it
> > sensible to add another 'mixed-build' check in top-level Makefile against all
> > target depending on linux.tar.gz?
> >
> >     $ make olddefconfig srcdeb-pkg -j8
> 
> This is already done.
> 
> The mixture of config targets and non-config targets
> are treated as mixed-build. [1]
> So, Kbuild internally divides it into 'make olddefconfig -j8'
> followed by 'make srcdeb-pkg -j8'.

oh yes, and already for quite some time.  I didn't check carefully 
enough.

> 
> [1] https://github.com/torvalds/linux/blob/v6.2/Makefile#L335
> 
> 
> 
> 
> 
> >     #
> >     # No change to .config
> >     #
> >       GEN     debian
> >       UPD     .tmp_filelist
> >       TAR     linux.tar.gz
> >     tar: .: file changed as we read it
> >     make[2]: *** [scripts/Makefile.package:58: linux.tar.gz] Error 1
> >     make[2]: *** Deleting file 'linux.tar.gz'
> >     make[1]: *** [Makefile:1654: srcdeb-pkg] Error 2
> >     make: *** [Makefile:358: __build_one_by_one] Error 2
> 
> 
> I ran the same command, but I could not reproduce this.

I cannot reproduce it any more; I don't know what might had been the 
problem on my site.

Kind regards,
Nicolas
diff mbox series

Patch

diff --git a/scripts/Makefile.package b/scripts/Makefile.package
index b941e6341b36..8650d9432c26 100644
--- a/scripts/Makefile.package
+++ b/scripts/Makefile.package
@@ -100,6 +100,9 @@  binrpm-pkg:
 	+rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
 		$(UTS_MACHINE)-linux -bb $(objtree)/binkernel.spec
 
+# deb-pkg srcdeb-pkg bindeb-pkg
+# ---------------------------------------------------------------------------
+
 quiet_cmd_debianize = GEN     $@
       cmd_debianize = $(srctree)/scripts/package/mkdebian
 
@@ -117,14 +120,27 @@  debian-orig: linux.tar.gz debian
 		cp $< ../$(orig-name); \
 	fi
 
+build-deb-pkg = \
+        dpkg-buildpackage \
+        --build=$(build-type) --no-pre-clean --unsigned-changes \
+        $(if $(findstring source, $(build-type)), --unsigned-source) \
+        $(if $(findstring binary, $(build-type)), -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch)) \
+        $(DPKG_FLAGS)
+
 PHONY += deb-pkg
+deb-pkg: private build-type := source,binary
 deb-pkg: debian-orig
-	+dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) \
-		--build=source,binary -nc -us -uc
+	+$(build-deb-pkg)
+
+PHONY += srcdeb-pkg
+srcdeb-pkg: private build-type := source
+srcdeb-pkg: debian-orig
+	+$(build-deb-pkg)
 
 PHONY += bindeb-pkg
+bindeb-pkg: private build-type := binary
 bindeb-pkg: debian
-	+dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -b -nc -uc
+	+$(build-deb-pkg)
 
 PHONY += intdeb-pkg
 intdeb-pkg:
@@ -225,6 +241,7 @@  help:
 	@echo '  srcrpm-pkg          - Build only the source kernel RPM package'
 	@echo '  binrpm-pkg          - Build only the binary kernel RPM package'
 	@echo '  deb-pkg             - Build both source and binary deb kernel packages'
+	@echo '  binsrc-pkg          - Build only the source kernel deb package'
 	@echo '  bindeb-pkg          - Build only the binary kernel deb package'
 	@echo '  snap-pkg            - Build only the binary kernel snap package'
 	@echo '                        (will connect to external hosts)'