Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+46 -33
+11 -29
scripts/package/builddeb
··· 24 24 fi 25 25 } 26 26 27 - create_package() { 28 - export DH_OPTIONS="-p${1}" 29 - 30 - dh_installdocs 31 - dh_installchangelogs 32 - dh_compress 33 - dh_fixperms 34 - dh_gencontrol 35 - dh_md5sums 36 - dh_builddeb -- ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} 37 - } 38 - 39 27 install_linux_image () { 40 28 pname=$1 41 29 pdir=debian/$1 ··· 149 161 mv "$pdir/usr/include/asm" "$pdir/usr/include/${DEB_HOST_MULTIARCH}" 150 162 } 151 163 152 - rm -f debian/files 164 + package=$1 153 165 154 - packages_enabled=$(dh_listpackages) 155 - 156 - for package in ${packages_enabled} 157 - do 158 - case ${package} in 159 - *-dbg) 160 - install_linux_image_dbg "${package}";; 161 - linux-image-*|user-mode-linux-*) 162 - install_linux_image "${package}";; 163 - linux-libc-dev) 164 - install_libc_headers "${package}";; 165 - linux-headers-*) 166 - install_kernel_headers "${package}";; 167 - esac 168 - create_package "${package}" 169 - done 166 + case "${package}" in 167 + *-dbg) 168 + install_linux_image_dbg "${package}";; 169 + linux-image-*|user-mode-linux-*) 170 + install_linux_image "${package}";; 171 + linux-libc-dev) 172 + install_libc_headers "${package}";; 173 + linux-headers-*) 174 + install_kernel_headers "${package}";; 175 + esac
+35 -4
scripts/package/debian/rules
··· 25 25 CROSS_COMPILE ?= $(filter-out $(DEB_BUILD_GNU_TYPE)-, $(DEB_HOST_GNU_TYPE)-) 26 26 make-opts = ARCH=$(ARCH) KERNELRELEASE=$(KERNELRELEASE) KBUILD_BUILD_VERSION=$(revision) $(addprefix CROSS_COMPILE=,$(CROSS_COMPILE)) 27 27 28 + binary-targets := $(addprefix binary-, image image-dbg headers libc-dev) 29 + 30 + all-packages = $(shell dh_listpackages) 31 + image-package = $(filter linux-image-% user-%, $(filter-out %-dbg, $(all-packages))) 32 + image-dbg-package = $(filter %-dbg, $(all-packages)) 33 + libc-dev-package = $(filter linux-libc-dev, $(all-packages)) 34 + headers-package = $(filter linux-headers-%, $(all-packages)) 35 + 36 + mk-files = $(patsubst binary-%,debian/%.files,$1) 37 + package = $($(@:binary-%=%-package)) 38 + 39 + # DH_OPTION is an environment variable common for all debhelper commands. 40 + # We could 'export' it, but here it is passed from the command line to clarify 41 + # which package is being processed in the build log. 42 + DH_OPTIONS = -p$(package) 43 + 44 + define binary 45 + $(Q)+$(MAKE) $(make-opts) run-command KBUILD_RUN_COMMAND='+$$(srctree)/scripts/package/builddeb $(package)' 46 + $(Q)dh_installdocs $(DH_OPTIONS) 47 + $(Q)dh_installchangelogs $(DH_OPTIONS) 48 + $(Q)dh_compress $(DH_OPTIONS) 49 + $(Q)dh_fixperms $(DH_OPTIONS) 50 + $(Q)dh_gencontrol $(DH_OPTIONS) -- -f$(call mk-files,$@) 51 + $(Q)dh_md5sums $(DH_OPTIONS) 52 + $(Q)dh_builddeb $(DH_OPTIONS) -- $(addprefix -Z,$(KDEB_COMPRESS)) 53 + endef 54 + 55 + .PHONY: $(binary-targets) 56 + $(binary-targets): build-arch 57 + $(Q)truncate -s0 $(call mk-files,$@) 58 + $(if $(package),$(binary)) 59 + 28 60 .PHONY: binary binary-indep binary-arch 29 61 binary: binary-arch binary-indep 30 62 binary-indep: build-indep 31 - binary-arch: build-arch 32 - $(Q)$(MAKE) $(make-opts) \ 33 - run-command KBUILD_RUN_COMMAND='+$$(srctree)/scripts/package/builddeb' 63 + binary-arch: $(binary-targets) 64 + $(Q)cat $(call mk-files,$^) > debian/files 34 65 35 66 .PHONY: build build-indep build-arch 36 67 build: build-arch build-indep ··· 72 41 73 42 .PHONY: clean 74 43 clean: 75 - $(Q)rm -rf debian/files debian/linux-* debian/deb-env.vars* 44 + $(Q)rm -rf debian/files debian/linux-* debian/deb-env.vars* debian/*.files 76 45 $(Q)$(MAKE) ARCH=$(ARCH) clean 77 46 78 47 # If DEB_HOST_ARCH is empty, it is likely that debian/rules was executed