public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: Masahiro Yamada <masahiroy@kernel.org>,
	Jason Self <jason@bluehome.net>, Guo Ren <guoren@kernel.org>,
	Michal Marek <michal.lkml@markovi.net>,
	Nick Desaulniers <ndesaulniers@google.com>,
	linux-csky@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/4] kbuild: rpm-pkg: fix build error when _arch is undefined
Date: Thu, 14 Jul 2022 14:02:40 +0900	[thread overview]
Message-ID: <20220714050243.16411-1-masahiroy@kernel.org> (raw)

Cross-building (bin)rpm-pkg fails on several architectures.

For example, 'make ARCH=arm binrpm-pkg' fails like follows:

  sh ./scripts/package/mkspec prebuilt > ./binkernel.spec
  rpmbuild  --define "_builddir ." --target \
          arm -bb ./binkernel.spec
  Building target platforms: arm
  Building for target arm
  warning: line 19: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers
  Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.0S8t2F
  + umask 022
  + cd .
  + mkdir -p /home/masahiro/rpmbuild/BUILDROOT/kernel-5.19.0_rc6-19.%{_arch}/boot
  + make -f ./Makefile image_name
  + cp arch/arm/boot/zImage /home/masahiro/rpmbuild/BUILDROOT/kernel-5.19.0_rc6-19.%{_arch}/boot/vmlinuz-5.19.0-rc6
  + make -f ./Makefile INSTALL_MOD_PATH=/home/masahiro/rpmbuild/BUILDROOT/kernel-5.19.0_rc6-19.%{_arch} modules_install
  make[3]: *** No rule to make target '/home/masahiro/rpmbuild/BUILDROOT/kernel-5.19.0_rc6-19.arch/arm/crypto/aes-arm-bs.ko{_arch}/lib/modules/5.19.0-rc6/kernel/%', needed by '__modinst'.  Stop.
  make[2]: *** [Makefile:1768: modules_install] Error 2
  error: Bad exit status from /var/tmp/rpm-tmp.0S8t2F (%install)

By default, 'buildroot' contains %{_arch} (see /usr/lib/rpm/macros).

_arch is generally defined in /usr/lib/rpm/platforms/*/macros, where
the platform sub-directory is specified by --target= option for cross
builds.

If the given arch does not exist, %{_arch} is not expanded.
In the example above, --target=arm is passed to rpmbuild, but
/usr/lib/rpm/platforms/arm-linux/ does not exist.

The '%' character in the path confuses GNU make and rpmbuild.

The same occurs for such architectures as csky, microblaze, nios2, etc.

Define _arch if it has not been defined.

Reported-by: Jason Self <jason@bluehome.net>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/package/mkspec | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/scripts/package/mkspec b/scripts/package/mkspec
index 7c477ca7dc98..8fa7c5b8a1a1 100755
--- a/scripts/package/mkspec
+++ b/scripts/package/mkspec
@@ -49,6 +49,9 @@ sed -e '/^DEL/d' -e 's/^\t*//' <<EOF
 	URL: https://www.kernel.org
 $S	Source: kernel-$__KERNELRELEASE.tar.gz
 	Provides: $PROVIDES
+	# $UTS_MACHINE as a fallback of _arch in case
+	# /usr/lib/rpm/platform/*/macros was not included.
+	%define _arch %{?_arch:$UTS_MACHINE}
 	%define __spec_install_post /usr/lib/rpm/brp-compress || :
 	%define debug_package %{nil}
 
-- 
2.34.1


             reply	other threads:[~2022-07-14  5:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-14  5:02 Masahiro Yamada [this message]
2022-07-14  5:02 ` [PATCH 2/4] kbuild: rpm-pkg: pass 'linux' to --target option of rpmbuild Masahiro Yamada
2022-07-14  5:02 ` [PATCH 3/4] kbuild: error out if $(KBUILD_EXTMOD) contains % or : Masahiro Yamada
2022-07-15  9:17   ` Nicolas Schier
2022-07-16 15:38   ` Masahiro Yamada
2022-07-14  5:02 ` [PATCH 4/4] kbuild: error out if $(INSTALL_MOD_PATH) " Masahiro Yamada
2022-07-15  9:17   ` Nicolas Schier
2022-07-16 15:40   ` Masahiro Yamada

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=20220714050243.16411-1-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=guoren@kernel.org \
    --cc=jason@bluehome.net \
    --cc=linux-csky@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=ndesaulniers@google.com \
    /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