From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: Ben Hutchings <ben@decadent.org.uk>,
Masahiro Yamada <masahiroy@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Nicolas Schier <nicolas@fjasle.eu>,
linux-kernel@vger.kernel.org
Subject: [PATCH 4/5] kbuild: deb-pkg: build binary-arch in parallel
Date: Sat, 30 Dec 2023 22:51:59 +0900 [thread overview]
Message-ID: <20231230135200.1058873-4-masahiroy@kernel.org> (raw)
In-Reply-To: <20231230135200.1058873-1-masahiroy@kernel.org>
'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>
---
scripts/package/builddeb | 40 ++++++++++--------------------------
scripts/package/debian/rules | 35 +++++++++++++++++++++++++++----
2 files changed, 42 insertions(+), 33 deletions(-)
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index bf96a3c24608..d31b16afe0db 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -24,18 +24,6 @@ if_enabled_echo() {
fi
}
-create_package() {
- export DH_OPTIONS="-p${1}"
-
- dh_installdocs
- dh_installchangelogs
- dh_compress
- dh_fixperms
- dh_gencontrol
- dh_md5sums
- dh_builddeb -- ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS}
-}
-
install_linux_image () {
pname=$1
pdir=debian/$1
@@ -161,21 +149,15 @@ install_libc_headers () {
mv "$pdir/usr/include/asm" "$pdir/usr/include/${DEB_HOST_MULTIARCH}"
}
-rm -f debian/files
+package=$1
-packages_enabled=$(dh_listpackages)
-
-for package in ${packages_enabled}
-do
- case ${package} in
- *-dbg)
- install_linux_image_dbg "${package}";;
- linux-image-*|user-mode-linux-*)
- install_linux_image "${package}";;
- linux-libc-dev)
- install_libc_headers "${package}";;
- linux-headers-*)
- install_kernel_headers "${package}";;
- esac
- create_package "${package}"
-done
+case "${package}" in
+*-dbg)
+ install_linux_image_dbg "${package}";;
+linux-image-*|user-mode-linux-*)
+ install_linux_image "${package}";;
+linux-libc-dev)
+ install_libc_headers "${package}";;
+linux-headers-*)
+ install_kernel_headers "${package}";;
+esac
diff --git a/scripts/package/debian/rules b/scripts/package/debian/rules
index b3f80f62236c..407f46a4a655 100755
--- a/scripts/package/debian/rules
+++ b/scripts/package/debian/rules
@@ -19,12 +19,39 @@ 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_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
@@ -35,7 +62,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
--
2.40.1
next prev parent reply other threads:[~2023-12-30 13:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-30 13:51 [PATCH 1/5] kbuild: deb-pkg: move 'make headers' to build-arch Masahiro Yamada
2023-12-30 13:51 ` [PATCH 2/5] kbuild: deb-pkg: make debian/rules quiet by default Masahiro Yamada
2024-01-09 14:14 ` Nicolas Schier
2024-01-09 14:46 ` Masahiro Yamada
2024-01-10 13:37 ` Nicolas Schier
2023-12-30 13:51 ` [PATCH 3/5] kbuild: deb-pkg: use debian/<package> for tmpdir Masahiro Yamada
2024-01-09 14:18 ` Nicolas Schier
2023-12-30 13:51 ` Masahiro Yamada [this message]
2024-01-10 13:47 ` [PATCH 4/5] kbuild: deb-pkg: build binary-arch in parallel Nicolas Schier
2023-12-30 13:52 ` [PATCH 5/5] kbuild: deb-pkg: call more misc debhelper commands Masahiro Yamada
2024-01-10 13:50 ` Nicolas Schier
2024-01-09 4:38 ` [PATCH 1/5] kbuild: deb-pkg: move 'make headers' to build-arch Masahiro Yamada
2024-01-09 13:24 ` Nicolas Schier
2024-01-09 14:29 ` Masahiro Yamada
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231230135200.1058873-4-masahiroy@kernel.org \
--to=masahiroy@kernel.org \
--cc=ben@decadent.org.uk \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=nicolas@fjasle.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox