• Masahiro Yamada's avatar
    kbuild: rpm-pkg: fix build error when _arch is undefined · 3089b2be
    Masahiro Yamada authored
    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: default avatarJason Self <jason@bluehome.net>
    Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
    3089b2be
mkspec 4.84 KB