public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] kbuild: deb-pkg: move 'make headers' to build-arch
@ 2023-12-30 13:51 Masahiro Yamada
  2023-12-30 13:51 ` [PATCH 2/5] kbuild: deb-pkg: make debian/rules quiet by default Masahiro Yamada
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Masahiro Yamada @ 2023-12-30 13:51 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Ben Hutchings, Masahiro Yamada, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier, linux-kernel

Strictly speaking, 'make headers' should be a part of build-arch
instead of binary-arch.

'make headers' constructs read-to-copy UAPI headers in the kernel
directory.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/package/builddeb     | 1 -
 scripts/package/debian/rules | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index cc8c7a807fcc..842ee4b40528 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -155,7 +155,6 @@ install_libc_headers () {
 
 	rm -rf $pdir
 
-	$MAKE -f $srctree/Makefile headers
 	$MAKE -f $srctree/Makefile headers_install INSTALL_HDR_PATH=$pdir/usr
 
 	# move asm headers to /usr/include/<libc-machine>/asm to match the structure
diff --git a/scripts/package/debian/rules b/scripts/package/debian/rules
index cb084e387469..a686c37d0d02 100755
--- a/scripts/package/debian/rules
+++ b/scripts/package/debian/rules
@@ -26,8 +26,8 @@ binary-arch: build-arch
 build: build-arch build-indep
 build-indep:
 build-arch:
-	$(MAKE) $(make-opts) \
-	olddefconfig all
+	$(MAKE) $(make-opts) olddefconfig
+	$(MAKE) $(make-opts) headers all
 
 .PHONY: clean
 clean:
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/5] kbuild: deb-pkg: make debian/rules quiet by default
  2023-12-30 13:51 [PATCH 1/5] kbuild: deb-pkg: move 'make headers' to build-arch Masahiro Yamada
@ 2023-12-30 13:51 ` Masahiro Yamada
  2024-01-09 14:14   ` Nicolas Schier
  2023-12-30 13:51 ` [PATCH 3/5] kbuild: deb-pkg: use debian/<package> for tmpdir Masahiro Yamada
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Masahiro Yamada @ 2023-12-30 13:51 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Ben Hutchings, Masahiro Yamada, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier, linux-kernel

Add $(Q) to commands in debian/rules to make them quiet when the package
built is initiated by 'make deb-pkg'.

While the commands in debian/rules are not hidden when you directly work
with the debianized tree, you can set 'terse' to DEB_BUILD_OPTIONS to
silence them.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/package/debian/rules | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/scripts/package/debian/rules b/scripts/package/debian/rules
index a686c37d0d02..b3f80f62236c 100755
--- a/scripts/package/debian/rules
+++ b/scripts/package/debian/rules
@@ -11,6 +11,10 @@ ifneq (,$(filter-out parallel=1,$(filter parallel=%,$(DEB_BUILD_OPTIONS))))
     MAKEFLAGS += -j$(NUMJOBS)
 endif
 
+ifneq (,$(filter terse,$(DEB_BUILD_OPTIONS)))
+    Q ?= @
+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))
@@ -19,20 +23,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) headers all
+	$(Q)$(MAKE) $(make-opts) olddefconfig
+	$(Q)$(MAKE) $(make-opts) 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
@@ -41,6 +45,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
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/5] kbuild: deb-pkg: use debian/<package> for tmpdir
  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
@ 2023-12-30 13:51 ` Masahiro Yamada
  2024-01-09 14:18   ` Nicolas Schier
  2023-12-30 13:51 ` [PATCH 4/5] kbuild: deb-pkg: build binary-arch in parallel Masahiro Yamada
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Masahiro Yamada @ 2023-12-30 13:51 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Ben Hutchings, Masahiro Yamada, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier, linux-kernel

Use debian/<package> for tmpdir, which is the default of debhelper.
This simplifies the code.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/package/builddeb | 41 ++++++++++++----------------------------
 1 file changed, 12 insertions(+), 29 deletions(-)

diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 842ee4b40528..bf96a3c24608 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -25,9 +25,7 @@ if_enabled_echo() {
 }
 
 create_package() {
-	local pname="$1" pdir="$2"
-
-	export DH_OPTIONS="-p${pname} -P${pdir}"
+	export DH_OPTIONS="-p${1}"
 
 	dh_installdocs
 	dh_installchangelogs
@@ -39,8 +37,8 @@ create_package() {
 }
 
 install_linux_image () {
-	pdir=$1
-	pname=$2
+	pname=$1
+	pdir=debian/$1
 
 	rm -rf ${pdir}
 
@@ -109,7 +107,7 @@ install_linux_image () {
 }
 
 install_linux_image_dbg () {
-	pdir=$1
+	pdir=debian/$1
 
 	rm -rf ${pdir}
 
@@ -139,8 +137,8 @@ install_linux_image_dbg () {
 }
 
 install_kernel_headers () {
-	pdir=$1
-	version=$2
+	pdir=debian/$1
+	version=${1#linux-headers-}
 
 	rm -rf $pdir
 
@@ -151,7 +149,7 @@ install_kernel_headers () {
 }
 
 install_libc_headers () {
-	pdir=$1
+	pdir=debian/$1
 
 	rm -rf $pdir
 
@@ -171,28 +169,13 @@ for package in ${packages_enabled}
 do
 	case ${package} in
 	*-dbg)
-		install_linux_image_dbg debian/linux-image-dbg;;
+		install_linux_image_dbg "${package}";;
 	linux-image-*|user-mode-linux-*)
-		install_linux_image debian/linux-image ${package};;
+		install_linux_image "${package}";;
 	linux-libc-dev)
-		install_libc_headers debian/linux-libc-dev;;
+		install_libc_headers "${package}";;
 	linux-headers-*)
-		install_kernel_headers debian/linux-headers ${package#linux-headers-};;
+		install_kernel_headers "${package}";;
 	esac
+	create_package "${package}"
 done
-
-for package in ${packages_enabled}
-do
-	case ${package} in
-	*-dbg)
-		create_package ${package} debian/linux-image-dbg;;
-	linux-image-*|user-mode-linux-*)
-		create_package ${package} debian/linux-image;;
-	linux-libc-dev)
-		create_package ${package} debian/linux-libc-dev;;
-	linux-headers-*)
-		create_package ${package} debian/linux-headers;;
-	esac
-done
-
-exit 0
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/5] kbuild: deb-pkg: build binary-arch in parallel
  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
  2023-12-30 13:51 ` [PATCH 3/5] kbuild: deb-pkg: use debian/<package> for tmpdir Masahiro Yamada
@ 2023-12-30 13:51 ` Masahiro Yamada
  2024-01-10 13:47   ` Nicolas Schier
  2023-12-30 13:52 ` [PATCH 5/5] kbuild: deb-pkg: call more misc debhelper commands Masahiro Yamada
  2024-01-09  4:38 ` [PATCH 1/5] kbuild: deb-pkg: move 'make headers' to build-arch Masahiro Yamada
  4 siblings, 1 reply; 14+ messages in thread
From: Masahiro Yamada @ 2023-12-30 13:51 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Ben Hutchings, Masahiro Yamada, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier, linux-kernel

'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


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 5/5] kbuild: deb-pkg: call more misc debhelper commands
  2023-12-30 13:51 [PATCH 1/5] kbuild: deb-pkg: move 'make headers' to build-arch Masahiro Yamada
                   ` (2 preceding siblings ...)
  2023-12-30 13:51 ` [PATCH 4/5] kbuild: deb-pkg: build binary-arch in parallel Masahiro Yamada
@ 2023-12-30 13:52 ` 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
  4 siblings, 1 reply; 14+ messages in thread
From: Masahiro Yamada @ 2023-12-30 13:52 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Ben Hutchings, Masahiro Yamada, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier, linux-kernel

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 <masahiroy@kernel.org>
---

 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/<libc-machine>/asm to match the structure
diff --git a/scripts/package/debian/rules b/scripts/package/debian/rules
index 407f46a4a655..5c5554c70949 100755
--- a/scripts/package/debian/rules
+++ b/scripts/package/debian/rules
@@ -32,6 +32,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)
@@ -62,7 +65,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
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/5] kbuild: deb-pkg: move 'make headers' to build-arch
  2023-12-30 13:51 [PATCH 1/5] kbuild: deb-pkg: move 'make headers' to build-arch Masahiro Yamada
                   ` (3 preceding siblings ...)
  2023-12-30 13:52 ` [PATCH 5/5] kbuild: deb-pkg: call more misc debhelper commands Masahiro Yamada
@ 2024-01-09  4:38 ` Masahiro Yamada
  2024-01-09 13:24   ` Nicolas Schier
  4 siblings, 1 reply; 14+ messages in thread
From: Masahiro Yamada @ 2024-01-09  4:38 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Ben Hutchings, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, linux-kernel

On Sat, Dec 30, 2023 at 10:52 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> Strictly speaking, 'make headers' should be a part of build-arch
> instead of binary-arch.
>
> 'make headers' constructs read-to-copy UAPI headers in the kernel
> directory.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
>  scripts/package/builddeb     | 1 -
>  scripts/package/debian/rules | 4 ++--
>  2 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/scripts/package/builddeb b/scripts/package/builddeb
> index cc8c7a807fcc..842ee4b40528 100755
> --- a/scripts/package/builddeb
> +++ b/scripts/package/builddeb
> @@ -155,7 +155,6 @@ install_libc_headers () {
>
>         rm -rf $pdir
>
> -       $MAKE -f $srctree/Makefile headers
>         $MAKE -f $srctree/Makefile headers_install INSTALL_HDR_PATH=$pdir/usr
>
>         # move asm headers to /usr/include/<libc-machine>/asm to match the structure
> diff --git a/scripts/package/debian/rules b/scripts/package/debian/rules
> index cb084e387469..a686c37d0d02 100755
> --- a/scripts/package/debian/rules
> +++ b/scripts/package/debian/rules
> @@ -26,8 +26,8 @@ binary-arch: build-arch
>  build: build-arch build-indep
>  build-indep:
>  build-arch:
> -       $(MAKE) $(make-opts) \
> -       olddefconfig all
> +       $(MAKE) $(make-opts) olddefconfig
> +       $(MAKE) $(make-opts) headers all




To avoid a build error for ARCH=um,
I will apply the following fix-up.





diff --git a/scripts/package/debian/rules b/scripts/package/debian/rules
index 1a18ca3c43db..098307780062 100755
--- a/scripts/package/debian/rules
+++ b/scripts/package/debian/rules
@@ -27,7 +27,7 @@ build: build-arch build-indep
 build-indep:
 build-arch:
        $(MAKE) $(make-opts) olddefconfig
-       $(MAKE) $(make-opts) headers all
+       $(MAKE) $(make-opts) $(if $(filter um,$(ARCH)),,headers) all

 .PHONY: clean
 clean:







>
>  .PHONY: clean
>  clean:
> --
> 2.40.1
>


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/5] kbuild: deb-pkg: move 'make headers' to build-arch
  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
  0 siblings, 1 reply; 14+ messages in thread
From: Nicolas Schier @ 2024-01-09 13:24 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, Ben Hutchings, Nathan Chancellor, Nick Desaulniers,
	linux-kernel, Nicolas Schier

On Tue, Jan 09, 2024 at 01:38:07PM +0900, Masahiro Yamada wrote:
> On Sat, Dec 30, 2023 at 10:52 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > Strictly speaking, 'make headers' should be a part of build-arch
> > instead of binary-arch.
> >
> > 'make headers' constructs read-to-copy UAPI headers in the kernel

s/read/ready/ ?

> > directory.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> >
> >  scripts/package/builddeb     | 1 -
> >  scripts/package/debian/rules | 4 ++--
> >  2 files changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/scripts/package/builddeb b/scripts/package/builddeb
> > index cc8c7a807fcc..842ee4b40528 100755
> > --- a/scripts/package/builddeb
> > +++ b/scripts/package/builddeb
> > @@ -155,7 +155,6 @@ install_libc_headers () {
> >
> >         rm -rf $pdir
> >
> > -       $MAKE -f $srctree/Makefile headers
> >         $MAKE -f $srctree/Makefile headers_install INSTALL_HDR_PATH=$pdir/usr
> >
> >         # move asm headers to /usr/include/<libc-machine>/asm to match the structure
> > diff --git a/scripts/package/debian/rules b/scripts/package/debian/rules
> > index cb084e387469..a686c37d0d02 100755
> > --- a/scripts/package/debian/rules
> > +++ b/scripts/package/debian/rules
> > @@ -26,8 +26,8 @@ binary-arch: build-arch
> >  build: build-arch build-indep
> >  build-indep:
> >  build-arch:
> > -       $(MAKE) $(make-opts) \
> > -       olddefconfig all
> > +       $(MAKE) $(make-opts) olddefconfig
> > +       $(MAKE) $(make-opts) headers all
> 
> 
> 
> 
> To avoid a build error for ARCH=um,
> I will apply the following fix-up.
> 
> 
> 
> 
> 
> diff --git a/scripts/package/debian/rules b/scripts/package/debian/rules
> index 1a18ca3c43db..098307780062 100755
> --- a/scripts/package/debian/rules
> +++ b/scripts/package/debian/rules
> @@ -27,7 +27,7 @@ build: build-arch build-indep
>  build-indep:
>  build-arch:
>         $(MAKE) $(make-opts) olddefconfig
> -       $(MAKE) $(make-opts) headers all
> +       $(MAKE) $(make-opts) $(if $(filter um,$(ARCH)),,headers) all

Reviewed-by: Nicolas Schier <n.schier@avm.de>

I'm wondering if we might want to change the headers target in top-level
Makefile to not bail-out for ARCH=um but only show a warning that there
is nothing to export.

Kind regards,
Nicolas

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/5] kbuild: deb-pkg: make debian/rules quiet by default
  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
  0 siblings, 1 reply; 14+ messages in thread
From: Nicolas Schier @ 2024-01-09 14:14 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, Ben Hutchings, Nathan Chancellor, Nick Desaulniers,
	linux-kernel

On Sat, Dec 30, 2023 at 10:51:57PM +0900, Masahiro Yamada wrote:
> Add $(Q) to commands in debian/rules to make them quiet when the package
> built is initiated by 'make deb-pkg'.
> 
> While the commands in debian/rules are not hidden when you directly work
> with the debianized tree, you can set 'terse' to DEB_BUILD_OPTIONS to
> silence them.

Reading Debian Policy §4.9 [1] I'd expected some fiddling with V=1 or
'make -s', but I am ok with the simple '@' silencing (which matches my
personal preference).

Reviewed-by: Nicolas Schier <n.schier@avm.de>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/5] kbuild: deb-pkg: use debian/<package> for tmpdir
  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
  0 siblings, 0 replies; 14+ messages in thread
From: Nicolas Schier @ 2024-01-09 14:18 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, Ben Hutchings, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, linux-kernel

On Sat, Dec 30, 2023 at 10:51:58PM +0900, Masahiro Yamada wrote:
> Use debian/<package> for tmpdir, which is the default of debhelper.
> This simplifies the code.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---

Reviewed-by: Nicolas Schier <n.schier@avm.de>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/5] kbuild: deb-pkg: move 'make headers' to build-arch
  2024-01-09 13:24   ` Nicolas Schier
@ 2024-01-09 14:29     ` Masahiro Yamada
  0 siblings, 0 replies; 14+ messages in thread
From: Masahiro Yamada @ 2024-01-09 14:29 UTC (permalink / raw)
  To: Nicolas Schier
  Cc: linux-kbuild, Ben Hutchings, Nathan Chancellor, Nick Desaulniers,
	linux-kernel, Nicolas Schier

On Tue, Jan 9, 2024 at 10:24 PM Nicolas Schier <n.schier@avm.de> wrote:
>
> On Tue, Jan 09, 2024 at 01:38:07PM +0900, Masahiro Yamada wrote:
> > On Sat, Dec 30, 2023 at 10:52 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> > >
> > > Strictly speaking, 'make headers' should be a part of build-arch
> > > instead of binary-arch.
> > >
> > > 'make headers' constructs read-to-copy UAPI headers in the kernel
>
> s/read/ready/ ?

Yes, thanks for catching it.




> I'm wondering if we might want to change the headers target in top-level
> Makefile to not bail-out for ARCH=um but only show a warning that there
> is nothing to export.


Yes, this is another way of fixing it, but
I do not even want to show a warning.

Having 'make ARCH=um headers' succeed silently
is another way.

I just stayed on a safer side.



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/5] kbuild: deb-pkg: make debian/rules quiet by default
  2024-01-09 14:14   ` Nicolas Schier
@ 2024-01-09 14:46     ` Masahiro Yamada
  2024-01-10 13:37       ` Nicolas Schier
  0 siblings, 1 reply; 14+ messages in thread
From: Masahiro Yamada @ 2024-01-09 14:46 UTC (permalink / raw)
  To: Nicolas Schier
  Cc: linux-kbuild, Ben Hutchings, Nathan Chancellor, Nick Desaulniers,
	linux-kernel

On Tue, Jan 9, 2024 at 11:14 PM Nicolas Schier <nicolas@fjasle.eu> wrote:
>
> On Sat, Dec 30, 2023 at 10:51:57PM +0900, Masahiro Yamada wrote:
> > Add $(Q) to commands in debian/rules to make them quiet when the package
> > built is initiated by 'make deb-pkg'.
> >
> > While the commands in debian/rules are not hidden when you directly work
> > with the debianized tree, you can set 'terse' to DEB_BUILD_OPTIONS to
> > silence them.
>
> Reading Debian Policy §4.9 [1] I'd expected some fiddling with V=1 or
> 'make -s', but I am ok with the simple '@' silencing (which matches my
> personal preference).


Hmm, you are right.


Maybe, we should follow what the Debian kernel does.

Debian kernel sets KBUILD_VERBOSE=1 unless
'terse' is given.


https://salsa.debian.org/kernel-team/linux/-/blob/debian/6.7-1_exp1/debian/rules.real#L36




>
> Reviewed-by: Nicolas Schier <n.schier@avm.de>



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/5] kbuild: deb-pkg: make debian/rules quiet by default
  2024-01-09 14:46     ` Masahiro Yamada
@ 2024-01-10 13:37       ` Nicolas Schier
  0 siblings, 0 replies; 14+ messages in thread
From: Nicolas Schier @ 2024-01-10 13:37 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, Ben Hutchings, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, linux-kernel

On Tue, Jan 09, 2024 at 11:46:49PM +0900, Masahiro Yamada wrote:
> On Tue, Jan 9, 2024 at 11:14 PM Nicolas Schier <nicolas@fjasle.eu> wrote:
> >
> > On Sat, Dec 30, 2023 at 10:51:57PM +0900, Masahiro Yamada wrote:
> > > Add $(Q) to commands in debian/rules to make them quiet when the package
> > > built is initiated by 'make deb-pkg'.
> > >
> > > While the commands in debian/rules are not hidden when you directly work
> > > with the debianized tree, you can set 'terse' to DEB_BUILD_OPTIONS to
> > > silence them.
> >
> > Reading Debian Policy §4.9 [1] I'd expected some fiddling with V=1 or
> > 'make -s', but I am ok with the simple '@' silencing (which matches my
> > personal preference).
> 
> 
> Hmm, you are right.
> 
> 
> Maybe, we should follow what the Debian kernel does.
> 
> Debian kernel sets KBUILD_VERBOSE=1 unless
> 'terse' is given.
> 
> 
> https://salsa.debian.org/kernel-team/linux/-/blob/debian/6.7-1_exp1/debian/rules.real#L36

yes, I think it makes sense to do the Debian way.

Kind regards,
Nicolas

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/5] kbuild: deb-pkg: build binary-arch in parallel
  2023-12-30 13:51 ` [PATCH 4/5] kbuild: deb-pkg: build binary-arch in parallel Masahiro Yamada
@ 2024-01-10 13:47   ` Nicolas Schier
  0 siblings, 0 replies; 14+ messages in thread
From: Nicolas Schier @ 2024-01-10 13:47 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, Ben Hutchings, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, linux-kernel

On Sat, Dec 30, 2023 at 10:51:59PM +0900, Masahiro Yamada wrote:
> '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
> 

Thanks, looks good to me.

Reviewed-by: Nicolas Schier <n.schier@avm.de>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/5] kbuild: deb-pkg: call more misc debhelper commands
  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
  0 siblings, 0 replies; 14+ messages in thread
From: Nicolas Schier @ 2024-01-10 13:50 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, Ben Hutchings, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, linux-kernel

On Sat, Dec 30, 2023 at 10:52:00PM +0900, Masahiro Yamada wrote:
> 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 <masahiroy@kernel.org>
> ---
> 
>  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/<libc-machine>/asm to match the structure
> diff --git a/scripts/package/debian/rules b/scripts/package/debian/rules
> index 407f46a4a655..5c5554c70949 100755
> --- a/scripts/package/debian/rules
> +++ b/scripts/package/debian/rules
> @@ -32,6 +32,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)
> @@ -62,7 +65,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
> -- 
> 2.40.1
> 

Reviewed-by: Nicolas Schier <n.schier@avm.de>

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-01-10 13:51 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 4/5] kbuild: deb-pkg: build binary-arch in parallel Masahiro Yamada
2024-01-10 13:47   ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox