diff options
author | Masahiro Yamada <masahiroy@kernel.org> | 2022-07-14 07:02:40 +0200 |
---|---|---|
committer | Masahiro Yamada <masahiroy@kernel.org> | 2022-07-27 14:18:00 +0200 |
commit | 3089b2be0cce14bd026a1018b8f6e5aed8244545 (patch) | |
tree | 12d2e0d3c5c8419a67b4460fb40ee5ff533cc9eb /scripts | |
parent | docs: kbuild: fix typo (diff) | |
download | linux-3089b2be0cce14bd026a1018b8f6e5aed8244545.tar.xz linux-3089b2be0cce14bd026a1018b8f6e5aed8244545.zip |
kbuild: rpm-pkg: fix build error when _arch is undefined
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>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/package/mkspec | 3 |
1 files changed, 3 insertions, 0 deletions
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} |