diff mbox series

[5/5] kbuild: deb-pkg: call more misc debhelper commands

Message ID 20231230135200.1058873-5-masahiroy@kernel.org (mailing list archive)
State New, archived
Headers show
Series [1/5] kbuild: deb-pkg: move 'make headers' to build-arch | expand

Commit Message

Masahiro Yamada Dec. 30, 2023, 1:52 p.m. UTC
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(-)

Comments

Nicolas Schier Jan. 10, 2024, 1:50 p.m. UTC | #1
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>
diff mbox series

Patch

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