From patchwork Sat Jan 13 10:43:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13518968 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7434A79F3; Sat, 13 Jan 2024 10:43:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lqIrmR+i" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A393C433F1; Sat, 13 Jan 2024 10:43:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705142628; bh=7QTEqiII/ATcIcuXjYpHlYvEtuflKe0mzeo9AghBfD8=; h=From:To:Cc:Subject:Date:From; b=lqIrmR+i9CuvBidK8icPurOxo5FokvxXoCpnMakaVxtd5Kns7VuC9pt2cY46M6X0D 2JPzIGax10xZD6WP+idfo5l5YbYH5XUelk1KsKJn6bwkLHdrLcnXpFt6HOd2Mh2g1q BlR35CVBRLHz4JHXSu9eM2aC/Dblnt8M/aNAYZXb+KnL212+kElR99H+aCKPGL5jwG wNWNI6Y5h+6iNj4WyS+XeTbF7L4dc+DtZLqrl0xsDGqR0O0NurMr32SaZTx/aOfJmf ussp6DdZ8s50gSa19tsR30RCg4y946VoM50JZtHVWrFrP+CbHCfXkiLTC6rCFErQnS OLofs/M/rz2gA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Ben Hutchings , Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/4] kbuild: deb-pkg: show verbose log for direct package builds Date: Sat, 13 Jan 2024 19:43:36 +0900 Message-Id: <20240113104339.16131-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When the Debian package build is initiated by Kbuild ('make deb-pkg' or 'make bindeb-pkg'), the log messages are displayed in the short form, which is the Kbuild default. Otherwise, let's show verbose messages (unless the 'terse' tag is set in DEB_BUILD_OPTION), as suggested by Debian Policy: "The package build should be as verbose as reasonably possible, except where the terse tag is included in DEB_BUILD_OPTIONS." [1] This is what the Debian kernel also does. [2] [1]: https://www.debian.org/doc/debian-policy/ch-source.html#main-building-script-debian-rules [2]: https://salsa.debian.org/kernel-team/linux/-/blob/debian/6.7-1_exp1/debian/rules.real#L36 Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- Changes in v2: - New patch scripts/package/debian/rules | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/package/debian/rules b/scripts/package/debian/rules index 098307780062..697fbfa7595f 100755 --- a/scripts/package/debian/rules +++ b/scripts/package/debian/rules @@ -11,6 +11,14 @@ ifneq (,$(filter-out parallel=1,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))) MAKEFLAGS += -j$(NUMJOBS) endif +# When KBUILD_VERBOSE is undefined (presumably you are directly working with +# the debianized tree), show verbose logs unless DEB_BUILD_OPTION=terse is set. +ifeq ($(origin KBUILD_VERBOSE),undefined) + ifeq (,$(filter terse,$(DEB_BUILD_OPTIONS))) + export KBUILD_VERBOSE := 1 + endif +endif + 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)) From patchwork Sat Jan 13 10:43:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13518969 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB16120DF0; Sat, 13 Jan 2024 10:43:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FqXfPtKd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CADDFC43399; Sat, 13 Jan 2024 10:43:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705142630; bh=HMJz/xKuNKASWe7U/KjCcahJnEqUSiHLAv6q7X00jEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FqXfPtKdBkT6GvG/yhrB2yc0Gt4paaqmZX4rihliFQ0ejqVzqmlWi9Zlbk687+8pW JI5tQiMnVggTXky8xt32AAtLLOtA+FARcwJYgdCIjEpaTvpzTcCsYHeGl2OTVpRmuU fnjOP6SZRQS+XMrpBlqbPk0Y/3+Urd0IyQvqSak/zvAmy2jgrKQWdPE76+Ir9MCh4u t7cZqIZKZcwh3YRdmivMKnOG81vkHFED/qM6q8nMj7vMR5O2O4K1rJThrR8oQ58Thf SVC4e5c/P5ZgbcvxQqZMit0F10zSXdtRSe7WJkOh5drQa/b0Ah0VBPzptshLYUcE+0 mrpnmlrJcZsBw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Ben Hutchings , Masahiro Yamada , Nicolas Schier , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/4] kbuild: deb-pkg: make debian/rules quiet for 'make deb-pkg' Date: Sat, 13 Jan 2024 19:43:37 +0900 Message-Id: <20240113104339.16131-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240113104339.16131-1-masahiroy@kernel.org> References: <20240113104339.16131-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add $(Q) to the commands in debian/rules to make them quiet when the package built is initiated by 'make deb-pkg' or when the 'terse' tag is set to DEB_BUILD_OPTIONS. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- Changes in v2: - Rebased scripts/package/debian/rules | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/scripts/package/debian/rules b/scripts/package/debian/rules index 697fbfa7595f..a183e95886e6 100755 --- a/scripts/package/debian/rules +++ b/scripts/package/debian/rules @@ -16,6 +16,8 @@ endif ifeq ($(origin KBUILD_VERBOSE),undefined) ifeq (,$(filter terse,$(DEB_BUILD_OPTIONS))) export KBUILD_VERBOSE := 1 + else + Q := @ endif endif @@ -27,20 +29,20 @@ make-opts = ARCH=$(ARCH) KERNELRELEASE=$(KERNELRELEASE) KBUILD_BUILD_VERSION=$(r binary: binary-arch binary-indep binary-indep: build-indep binary-arch: build-arch - $(MAKE) $(make-opts) \ + $(Q)$(MAKE) $(make-opts) \ run-command KBUILD_RUN_COMMAND='+$$(srctree)/scripts/package/builddeb' .PHONY: build build-indep build-arch build: build-arch build-indep build-indep: build-arch: - $(MAKE) $(make-opts) olddefconfig - $(MAKE) $(make-opts) $(if $(filter um,$(ARCH)),,headers) all + $(Q)$(MAKE) $(make-opts) olddefconfig + $(Q)$(MAKE) $(make-opts) $(if $(filter um,$(ARCH)),,headers) all .PHONY: clean clean: - rm -rf debian/files debian/linux-* debian/deb-env.vars* - $(MAKE) ARCH=$(ARCH) clean + $(Q)rm -rf debian/files debian/linux-* debian/deb-env.vars* + $(Q)$(MAKE) ARCH=$(ARCH) clean # If DEB_HOST_ARCH is empty, it is likely that debian/rules was executed # directly. Run 'dpkg-architecture --print-set --print-format=make' to @@ -49,6 +51,6 @@ ifndef DEB_HOST_ARCH include debian/deb-env.vars debian/deb-env.vars: - dpkg-architecture -a$$(cat debian/arch) --print-set --print-format=make > $@.tmp - mv $@.tmp $@ + $(Q)dpkg-architecture -a$$(cat debian/arch) --print-set --print-format=make > $@.tmp + $(Q)mv $@.tmp $@ endif From patchwork Sat Jan 13 10:43:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13518970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D51D2210EE; Sat, 13 Jan 2024 10:43:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="n8+hBPWB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7E2AC433F1; Sat, 13 Jan 2024 10:43:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705142632; bh=MUg4+EtSwSByo4gfv6gNhVBnkJZagRqOmQ0KCEkifkU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n8+hBPWBvpOzAjRUBVwcToYJnEeXHcN8d+lLHH95j1dMS1lLrr9tq+EqHFYG7va06 U4YgGX4knD+eXkzk9E4BGBOEfc2XAzOCThXDm0RYg1PpsNq5oM0XyExaLBPjDKQrkg EukiWBoYI79gbT8LJyj4apyb28WKVArYeYFIzhahFNsjwHF6KV14ct9GEu/6nxvaAk 7R8oQswnn1H8YazPgYblj+onL/5pKFZr30E8mMXt1/cDGIVLuc/umlk4JNVozYGzB0 5ImqssEpKP8vYQBwiWrZ/HIvc9tYgeCptYz2u3GxcAvv0DovbsPH5o8o7f4WdILAfG 89cn8nkn/1F8Q== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Ben Hutchings , Masahiro Yamada , Nicolas Schier , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , linux-kernel@vger.kernel.org Subject: [PATCH v2 3/4] kbuild: deb-pkg: build binary-arch in parallel Date: Sat, 13 Jan 2024 19:43:38 +0900 Message-Id: <20240113104339.16131-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240113104339.16131-1-masahiroy@kernel.org> References: <20240113104339.16131-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 '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 Reviewed-by: Nicolas Schier --- (no changes since v1) scripts/package/builddeb | 40 ++++++++++-------------------------- scripts/package/debian/rules | 39 +++++++++++++++++++++++++++++++---- 2 files changed, 46 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 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 From patchwork Sat Jan 13 10:43:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13518971 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97B5F21110; Sat, 13 Jan 2024 10:43:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AfJU9lFp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B16F2C43394; Sat, 13 Jan 2024 10:43:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705142634; bh=qojQBt1Bg5uxXkkZTt84eMBF6leDUzIvdOIhZFTxWJQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AfJU9lFpqCXpxLe3cUEJVHNlKj9bYF0BnzZ5d6mLCPGGPdtjo3QD6iFKiHXRO5fPa iWFEe87kpbr8Yzh0AM4imdcM0scW3wz1Bo0ziue5WTqkXDbSY7HhmDmlULbtBpFK1E /y1hSwvDHCctxdb266Fu0jmDviqyWpf1+7NInKslbmZPlTkcbw2AZThS94uNAoXPAm KtBfoqHmXVCMkDWwd6ffeee7kqRckzHjbjH4F6fb9nVvC15GEekbc6/9hZ3mYUPih5 86KGP2y38KPmrx58DhYPXJx2cDhxg3krCG/izE6loXYiw1HgAZdnG3K4oIpirCNFyV ZQyMJuSJIDJRA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Ben Hutchings , Masahiro Yamada , Nicolas Schier , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , linux-kernel@vger.kernel.org Subject: [PATCH v2 4/4] kbuild: deb-pkg: call more misc debhelper commands Date: Sat, 13 Jan 2024 19:43:39 +0900 Message-Id: <20240113104339.16131-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240113104339.16131-1-masahiroy@kernel.org> References: <20240113104339.16131-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use dh_prep instead of removing old build directories manually. Use dh_clean instead of removing build directories and debian/files manually. Call dh_testdir and dh_testroot for preliminary checks. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- (no changes since v1) scripts/package/builddeb | 8 -------- scripts/package/debian/rules | 6 +++++- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/scripts/package/builddeb b/scripts/package/builddeb index d31b16afe0db..e797ad360f7a 100755 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -28,8 +28,6 @@ install_linux_image () { pname=$1 pdir=debian/$1 - rm -rf ${pdir} - # Only some architectures with OF support have this target if is_enabled CONFIG_OF_EARLY_FLATTREE && [ -d "${srctree}/arch/${SRCARCH}/boot/dts" ]; then ${MAKE} -f ${srctree}/Makefile INSTALL_DTBS_PATH="${pdir}/usr/lib/linux-image-${KERNELRELEASE}" dtbs_install @@ -97,8 +95,6 @@ install_linux_image () { install_linux_image_dbg () { pdir=debian/$1 - rm -rf ${pdir} - # Parse modules.order directly because 'make modules_install' may sign, # compress modules, and then run unneeded depmod. while read -r mod; do @@ -128,8 +124,6 @@ install_kernel_headers () { pdir=debian/$1 version=${1#linux-headers-} - rm -rf $pdir - "${srctree}/scripts/package/install-extmod-build" "${pdir}/usr/src/linux-headers-${version}" mkdir -p $pdir/lib/modules/$version/ @@ -139,8 +133,6 @@ install_kernel_headers () { install_libc_headers () { pdir=debian/$1 - rm -rf $pdir - $MAKE -f $srctree/Makefile headers_install INSTALL_HDR_PATH=$pdir/usr # move asm headers to /usr/include//asm to match the structure diff --git a/scripts/package/debian/rules b/scripts/package/debian/rules index 57f1cf7c6b32..ca07243bd5cd 100755 --- a/scripts/package/debian/rules +++ b/scripts/package/debian/rules @@ -42,6 +42,9 @@ package = $($(@:binary-%=%-package)) DH_OPTIONS = -p$(package) define binary + $(Q)dh_testdir $(DH_OPTIONS) + $(Q)dh_testroot $(DH_OPTIONS) + $(Q)dh_prep $(DH_OPTIONS) $(Q)+$(MAKE) $(make-opts) run-command KBUILD_RUN_COMMAND='+$$(srctree)/scripts/package/builddeb $(package)' $(Q)dh_installdocs $(DH_OPTIONS) $(Q)dh_installchangelogs $(DH_OPTIONS) @@ -72,7 +75,8 @@ build-arch: .PHONY: clean clean: - $(Q)rm -rf debian/files debian/linux-* debian/deb-env.vars* debian/*.files + $(Q)dh_clean + $(Q)rm -rf 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