mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicolas Schier <n.schier@avm.de>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: linux-kbuild@vger.kernel.org, Ben Hutchings <ben@decadent.org.uk>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Nicolas Schier <nicolas@fjasle.eu>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/6] kbuild: deb-pkg: set DEB_* variables if debian/rules is directly executed
Date: Wed, 27 Dec 2023 09:08:20 +0100	[thread overview]
Message-ID: <ZYvbdMfz1PzROlb6@buildd.core.avm.de> (raw)
In-Reply-To: <20231226135243.1393780-3-masahiroy@kernel.org>

On Tue, Dec 26, 2023 at 10:52:40PM +0900, Masahiro Yamada wrote:
> Since commit 491b146d4c13 ("kbuild: builddeb: Eliminate debian/arch
> use"), direct execution of debian/rules results in the following error:
> 
>   dpkg-architecture: error: unknown option 'DEB_HOST_MULTIARCH'
> 
> The current code:
> 
>   dpkg-architecture -a$DEB_HOST_ARCH -qDEB_HOST_MULTIARCH
> 
> ... does not look sensible because:
> 
>  - For this code to work correctly, DEB_HOST_ARCH must be pre-defined,
>    which is true when the packages are built via dpkg-buildpackage.
>    In this case, DEB_HOST_MULTIARCH is also likely defined, hence there
>    is no need to query DEB_HOST_MULTIARCH in the first place.
> 
>  - If DEB_HOST_MULTIARCH is undefined, DEB_HOST_ARCH is likely undefined
>    too. So, you cannot query DEB_HOST_MULTIARCH in this way. This is
>    mostly the case where debian/rules is directly executed.
> 
> When debian/rules is directly executed, querying DEB_HOST_MUCHARCH is
> not enough because we need to know DEB_{BUILD,HOST}_GNU_TYPE as well.
> 
> All DEB_* variables are defined when the package build is initiated by
> dpkg-buildpackage, but otherwise, let's call dpkg-architecture to set
> all DEB_* environment variables.
> 
> This implementation relies on dpkg commit 7c54fa2b232e
> ("dpkg-architecture: Add a --print-format option").
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  scripts/package/builddeb     |  5 ++---
>  scripts/package/debian/rules | 12 +++++++++++-
>  2 files changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/scripts/package/builddeb b/scripts/package/builddeb
> index 2fe51e6919da..2eb4910f0ef3 100755
> --- a/scripts/package/builddeb
> +++ b/scripts/package/builddeb
> @@ -171,9 +171,8 @@ install_libc_headers () {
>  
>  	# move asm headers to /usr/include/<libc-machine>/asm to match the structure
>  	# used by Debian-based distros (to support multi-arch)
> -	host_arch=$(dpkg-architecture -a$DEB_HOST_ARCH -qDEB_HOST_MULTIARCH)
> -	mkdir $pdir/usr/include/$host_arch
> -	mv $pdir/usr/include/asm $pdir/usr/include/$host_arch/
> +	mkdir "$pdir/usr/include/${DEB_HOST_MULTIARCH}"
> +	mv "$pdir/usr/include/asm" "$pdir/usr/include/${DEB_HOST_MULTIARCH}"
>  }
>  
>  rm -f debian/files
> diff --git a/scripts/package/debian/rules b/scripts/package/debian/rules
> index 529b71b55efa..8f24a8e84bf2 100755
> --- a/scripts/package/debian/rules
> +++ b/scripts/package/debian/rules
> @@ -30,5 +30,15 @@ build-arch:
>  
>  .PHONY: clean
>  clean:
> -	rm -rf debian/files debian/linux-*
> +	rm -rf debian/files debian/linux-* debian/deb-env.vars
>  	$(MAKE) -f $(srctree)/Makefile 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
> +# generate a makefile construct that exports all DEB_* variables.
> +ifndef DEB_HOST_ARCH
> +-include debian/deb-env.vars
> +
> +debian/deb-env.vars:
> +	dpkg-architecture -a$$(cat debian/arch) --print-set --print-format=make > $@
> +endif
> -- 
> 2.40.1

Thanks!

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

  reply	other threads:[~2023-12-27  8:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-26 13:52 [PATCH 1/6] kbuild: deb-pkg: factor out common Make options in debian/rules Masahiro Yamada
2023-12-26 13:52 ` [PATCH 2/6] kbuild: deb-pkg: squash scripts/package/deb-build-option to debian/rules Masahiro Yamada
2023-12-27  7:56   ` Nicolas Schier
2023-12-26 13:52 ` [PATCH 3/6] kbuild: deb-pkg: set DEB_* variables if debian/rules is directly executed Masahiro Yamada
2023-12-27  8:08   ` Nicolas Schier [this message]
2023-12-26 13:52 ` [PATCH 4/6] kbuild: deb-pkg: allow to run debian/rules from output directory Masahiro Yamada
2023-12-27  8:09   ` Nicolas Schier
2023-12-26 13:52 ` [PATCH 5/6] kbuild: deb-pkg: remove unneeded '-f $srctree/Makefile' in debian/rules Masahiro Yamada
2023-12-27  8:11   ` Nicolas Schier
2023-12-26 13:52 ` [PATCH 6/6] kbuild: deb-pkg: use more debhelper commands in builddeb Masahiro Yamada
2024-04-02 15:59   ` Robert Nelson
2024-04-02 20:35     ` Robert Nelson
2023-12-27  7:55 ` [PATCH 1/6] kbuild: deb-pkg: factor out common Make options in debian/rules Nicolas Schier

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=ZYvbdMfz1PzROlb6@buildd.core.avm.de \
    --to=n.schier@avm.de \
    --cc=ben@decadent.org.uk \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@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

all inboxes | Powered by JetHome®