[2/6] kbuild: deb-pkg: squash scripts/package/deb-build-option to debian/rules

Message ID 20231226135243.1393780-2-masahiroy@kernel.org
State New
Headers
Series [1/6] kbuild: deb-pkg: factor out common Make options in debian/rules |

Commit Message

Masahiro Yamada Dec. 26, 2023, 1:52 p.m. UTC
  The binary-arch target needs to use the same CROSS_COMPILE as used in
build-arch; otherwise, 'make run-command' may attempt to resync the
.config file.

Squash scripts/package/deb-build-option into debian/rules, as it is a
small amount of code.

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

 scripts/package/deb-build-option | 14 --------------
 scripts/package/debian/rules     |  5 +++--
 2 files changed, 3 insertions(+), 16 deletions(-)
 delete mode 100755 scripts/package/deb-build-option
  

Comments

Nicolas Schier Dec. 27, 2023, 7:56 a.m. UTC | #1
On Tue, Dec 26, 2023 at 10:52:39PM +0900, Masahiro Yamada wrote:
> The binary-arch target needs to use the same CROSS_COMPILE as used in
> build-arch; otherwise, 'make run-command' may attempt to resync the
> .config file.
> 
> Squash scripts/package/deb-build-option into debian/rules, as it is a
> small amount of code.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---

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


> 
>  scripts/package/deb-build-option | 14 --------------
>  scripts/package/debian/rules     |  5 +++--
>  2 files changed, 3 insertions(+), 16 deletions(-)
>  delete mode 100755 scripts/package/deb-build-option
> 
> diff --git a/scripts/package/deb-build-option b/scripts/package/deb-build-option
> deleted file mode 100755
> index 7950eff01781..000000000000
> --- a/scripts/package/deb-build-option
> +++ /dev/null
> @@ -1,14 +0,0 @@
> -#!/bin/sh
> -# SPDX-License-Identifier: GPL-2.0-only
> -
> -# Set up CROSS_COMPILE if not defined yet
> -if [ "${CROSS_COMPILE+set}" != "set" -a "${DEB_HOST_ARCH}" != "${DEB_BUILD_ARCH}" ]; then
> -	echo CROSS_COMPILE=${DEB_HOST_GNU_TYPE}-
> -fi
> -
> -version=$(dpkg-parsechangelog -S Version)
> -debian_revision="${version##*-}"
> -
> -if [ "${version}" != "${debian_revision}" ]; then
> -	echo KBUILD_BUILD_VERSION=${debian_revision}
> -fi
> diff --git a/scripts/package/debian/rules b/scripts/package/debian/rules
> index 26bc6239e200..529b71b55efa 100755
> --- a/scripts/package/debian/rules
> +++ b/scripts/package/debian/rules
> @@ -10,7 +10,9 @@ ifneq (,$(filter-out parallel=1,$(filter parallel=%,$(DEB_BUILD_OPTIONS))))
>      MAKEFLAGS += -j$(NUMJOBS)
>  endif
>  
> -make-opts = ARCH=$(ARCH) KERNELRELEASE=$(KERNELRELEASE)
> +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))
>  
>  .PHONY: binary binary-indep binary-arch
>  binary: binary-arch binary-indep
> @@ -24,7 +26,6 @@ build: build-arch build-indep
>  build-indep:
>  build-arch:
>  	$(MAKE) -f $(srctree)/Makefile $(make-opts) \
> -	$(shell $(srctree)/scripts/package/deb-build-option) \
>  	olddefconfig all
>  
>  .PHONY: clean
> -- 
> 2.40.1
>
  

Patch

diff --git a/scripts/package/deb-build-option b/scripts/package/deb-build-option
deleted file mode 100755
index 7950eff01781..000000000000
--- a/scripts/package/deb-build-option
+++ /dev/null
@@ -1,14 +0,0 @@ 
-#!/bin/sh
-# SPDX-License-Identifier: GPL-2.0-only
-
-# Set up CROSS_COMPILE if not defined yet
-if [ "${CROSS_COMPILE+set}" != "set" -a "${DEB_HOST_ARCH}" != "${DEB_BUILD_ARCH}" ]; then
-	echo CROSS_COMPILE=${DEB_HOST_GNU_TYPE}-
-fi
-
-version=$(dpkg-parsechangelog -S Version)
-debian_revision="${version##*-}"
-
-if [ "${version}" != "${debian_revision}" ]; then
-	echo KBUILD_BUILD_VERSION=${debian_revision}
-fi
diff --git a/scripts/package/debian/rules b/scripts/package/debian/rules
index 26bc6239e200..529b71b55efa 100755
--- a/scripts/package/debian/rules
+++ b/scripts/package/debian/rules
@@ -10,7 +10,9 @@  ifneq (,$(filter-out parallel=1,$(filter parallel=%,$(DEB_BUILD_OPTIONS))))
     MAKEFLAGS += -j$(NUMJOBS)
 endif
 
-make-opts = ARCH=$(ARCH) KERNELRELEASE=$(KERNELRELEASE)
+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))
 
 .PHONY: binary binary-indep binary-arch
 binary: binary-arch binary-indep
@@ -24,7 +26,6 @@  build: build-arch build-indep
 build-indep:
 build-arch:
 	$(MAKE) -f $(srctree)/Makefile $(make-opts) \
-	$(shell $(srctree)/scripts/package/deb-build-option) \
 	olddefconfig all
 
 .PHONY: clean