summaryrefslogtreecommitdiffstats
path: root/scripts/package/debian
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2024-01-13 19:43:38 +0900
committerMasahiro Yamada <masahiroy@kernel.org>2024-02-19 18:20:39 +0900
commit1d7bae8f8c85ddf153f302cd8d2f33d34762b0fd (patch)
treeb896ad2a323550768eb81f6417f5708110174036 /scripts/package/debian
parentcaf400c8b68af29568e39ef99b12d25966c3e76b (diff)
downloadlinux-1d7bae8f8c85ddf153f302cd8d2f33d34762b0fd.tar.gz
linux-1d7bae8f8c85ddf153f302cd8d2f33d34762b0fd.tar.bz2
linux-1d7bae8f8c85ddf153f302cd8d2f33d34762b0fd.zip
kbuild: deb-pkg: build binary-arch in parallel
'make deb-pkg' builds build-arch in parallel, but binary-arch serially. Given that all binary packages are independent of one another, they can be built in parallel. I am uncertain whether debian/files is robust against a race condition. Just in case, make dh_gencontrol (dpkg-gencontrol) output to separate debian/*.files, which are then concatenated into debian/files. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <n.schier@avm.de>
Diffstat (limited to 'scripts/package/debian')
-rwxr-xr-xscripts/package/debian/rules39
1 files changed, 35 insertions, 4 deletions
diff --git a/scripts/package/debian/rules b/scripts/package/debian/rules
index a183e95886e6..57f1cf7c6b32 100755
--- a/scripts/package/debian/rules
+++ b/scripts/package/debian/rules
@@ -25,12 +25,43 @@ revision = $(lastword $(subst -, ,$(shell dpkg-parsechangelog -S Version)))
CROSS_COMPILE ?= $(filter-out $(DEB_BUILD_GNU_TYPE)-, $(DEB_HOST_GNU_TYPE)-)
make-opts = ARCH=$(ARCH) KERNELRELEASE=$(KERNELRELEASE) KBUILD_BUILD_VERSION=$(revision) $(addprefix CROSS_COMPILE=,$(CROSS_COMPILE))
+binary-targets := $(addprefix binary-, image image-dbg headers libc-dev)
+
+all-packages = $(shell dh_listpackages)
+image-package = $(filter linux-image-% user-%, $(filter-out %-dbg, $(all-packages)))
+image-dbg-package = $(filter %-dbg, $(all-packages))
+libc-dev-package = $(filter linux-libc-dev, $(all-packages))
+headers-package = $(filter linux-headers-%, $(all-packages))
+
+mk-files = $(patsubst binary-%,debian/%.files,$1)
+package = $($(@:binary-%=%-package))
+
+# DH_OPTION is an environment variable common for all debhelper commands.
+# We could 'export' it, but here it is passed from the command line to clarify
+# which package is being processed in the build log.
+DH_OPTIONS = -p$(package)
+
+define binary
+ $(Q)+$(MAKE) $(make-opts) run-command KBUILD_RUN_COMMAND='+$$(srctree)/scripts/package/builddeb $(package)'
+ $(Q)dh_installdocs $(DH_OPTIONS)
+ $(Q)dh_installchangelogs $(DH_OPTIONS)
+ $(Q)dh_compress $(DH_OPTIONS)
+ $(Q)dh_fixperms $(DH_OPTIONS)
+ $(Q)dh_gencontrol $(DH_OPTIONS) -- -f$(call mk-files,$@)
+ $(Q)dh_md5sums $(DH_OPTIONS)
+ $(Q)dh_builddeb $(DH_OPTIONS) -- $(addprefix -Z,$(KDEB_COMPRESS))
+endef
+
+.PHONY: $(binary-targets)
+$(binary-targets): build-arch
+ $(Q)truncate -s0 $(call mk-files,$@)
+ $(if $(package),$(binary))
+
.PHONY: binary binary-indep binary-arch
binary: binary-arch binary-indep
binary-indep: build-indep
-binary-arch: build-arch
- $(Q)$(MAKE) $(make-opts) \
- run-command KBUILD_RUN_COMMAND='+$$(srctree)/scripts/package/builddeb'
+binary-arch: $(binary-targets)
+ $(Q)cat $(call mk-files,$^) > debian/files
.PHONY: build build-indep build-arch
build: build-arch build-indep
@@ -41,7 +72,7 @@ build-arch:
.PHONY: clean
clean:
- $(Q)rm -rf debian/files debian/linux-* debian/deb-env.vars*
+ $(Q)rm -rf debian/files debian/linux-* debian/deb-env.vars* debian/*.files
$(Q)$(MAKE) ARCH=$(ARCH) clean
# If DEB_HOST_ARCH is empty, it is likely that debian/rules was executed