[1/2] kbuild: add srcdeb-pkg target
Commit Message
This new target builds only the debian source package.
Unify the build rules of deb-pkg, srcdeb-pkg, bindeb-pkg to avoid
code duplication.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
---
scripts/Makefile.package | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
Comments
On Mon, 2023-04-17 at 23:25 +0900, Masahiro Yamada wrote:
> This new target builds only the debian source package.
>
> Unify the build rules of deb-pkg, srcdeb-pkg, bindeb-pkg to avoid
> code duplication.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
> ---
[...]
> bindeb-pkg: debian
> - +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -b -nc -uc
> +deb-pkg srcdeb-pkg bindeb-pkg:
> + +$(strip 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), \
> + --no-check-builddeps) \
[...]
There is no need to make the use of --unsigned-source (-us) or -r
conditional on the build type. They will be ignored if not applicable.
This is also adding --no-check-builddeps (-d), which is not explained
in the commit message. It might be valid to add this for srcdeb-pkg,
but the build dependency check is valuable for bindeb-pkg and deb-pkg.
Ben.
On Mon, Apr 17, 2023 at 11:52 PM Ben Hutchings <ben@decadent.org.uk> wrote:
>
> On Mon, 2023-04-17 at 23:25 +0900, Masahiro Yamada wrote:
> > This new target builds only the debian source package.
> >
> > Unify the build rules of deb-pkg, srcdeb-pkg, bindeb-pkg to avoid
> > code duplication.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
> > ---
> [...]
> > bindeb-pkg: debian
> > - +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -b -nc -uc
> > +deb-pkg srcdeb-pkg bindeb-pkg:
> > + +$(strip 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), \
> > + --no-check-builddeps) \
> [...]
>
> There is no need to make the use of --unsigned-source (-us) or -r
> conditional on the build type. They will be ignored if not applicable.
True, but you can also say there is no need
to pass options that we know are unnecessary.
My motivation is to make unneeded options
really don't-care.
2/2 will add KDEB_SOURCE_COMPRESS.
If I do not make it optional,
"KDEB_SOURCE_COMPRESS=foo make bindeb-pkg"
would fail.
dpkg-buildpackage --build=binary --no-pre-clean --unsigned-changes
--unsigned-source --compression=foo -r'fakeroot -u' -a$(cat
debian/arch)
dpkg-buildpackage: info: source package linux-upstream
dpkg-buildpackage: info: source version 6.3.0-rc7-00003-geb58366b57fe-33
dpkg-buildpackage: info: source distribution kinetic
dpkg-buildpackage: info: source changed by Masahiro Yamada
<masahiro.yamada@canonical.com>
dpkg-buildpackage: info: host architecture amd64
dpkg-source --compression=foo --before-build .
dpkg-source: error: foo is not a supported compression
Use --help for program usage information.
"dpkg-buildpackage --build=binary" does not
generate a source package, but still checks
if --compression=foo is correct.
> This is also adding --no-check-builddeps (-d), which is not explained
> in the commit message. It might be valid to add this for srcdeb-pkg,
> but the build dependency check is valuable for bindeb-pkg and deb-pkg.
Yes.
So, I added --no-check-builddeps to the else arm.
I will add the following commit description:
--no-check-builddeps is added to srcbin-pkg
so that build dependencies will not be checked.
>
> Ben.
>
> --
> Ben Hutchings
> Sturgeon's Law: Ninety percent of everything is crap.
On Tue, 2023-04-18 at 10:17 +0900, Masahiro Yamada wrote:
> On Mon, Apr 17, 2023 at 11:52 PM Ben Hutchings <ben@decadent.org.uk> wrote:
[...]
> > This is also adding --no-check-builddeps (-d), which is not explained
> > in the commit message. It might be valid to add this for srcdeb-pkg,
> > but the build dependency check is valuable for bindeb-pkg and deb-pkg.
>
>
> Yes.
> So, I added --no-check-builddeps to the else arm.
[...]
Sorry, I read that wrongly.
Ben.
@@ -5,7 +5,6 @@ include $(srctree)/scripts/Kbuild.include
include $(srctree)/scripts/Makefile.lib
KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE))
-KBUILD_PKG_ROOTCMD ?="fakeroot -u"
# 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 \
@@ -86,6 +85,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 $(mkdebian-opts)
@@ -104,14 +106,25 @@ debian-orig: linux.tar.gz debian
cp $< ../$(orig-name); \
fi
-PHONY += deb-pkg
-deb-pkg: debian-orig
- +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) \
- --build=source,binary -nc -us -uc
+KBUILD_PKG_ROOTCMD ?= 'fakeroot -u'
+
+PHONY += deb-pkg srcdeb-pkg bindeb-pkg
+
+deb-pkg: private build-type := source,binary
+srcdeb-pkg: private build-type := source
+bindeb-pkg: private build-type := binary
-PHONY += bindeb-pkg
+deb-pkg srcdeb-pkg: debian-orig
bindeb-pkg: debian
- +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -b -nc -uc
+deb-pkg srcdeb-pkg bindeb-pkg:
+ +$(strip 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), \
+ --no-check-builddeps) \
+ $(DPKG_FLAGS))
PHONY += intdeb-pkg
intdeb-pkg:
@@ -208,6 +221,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 ' srcdeb-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)'