linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] kbuild: rpm-pkg: fix build error when _arch is undefined
@ 2022-07-14  5:02 Masahiro Yamada
  2022-07-14  5:02 ` [PATCH 2/4] kbuild: rpm-pkg: pass 'linux' to --target option of rpmbuild Masahiro Yamada
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Masahiro Yamada @ 2022-07-14  5:02 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Masahiro Yamada, Jason Self, Guo Ren, Michal Marek,
	Nick Desaulniers, linux-csky, linux-kernel

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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/4] kbuild: rpm-pkg: pass 'linux' to --target option of rpmbuild
  2022-07-14  5:02 [PATCH 1/4] kbuild: rpm-pkg: fix build error when _arch is undefined Masahiro Yamada
@ 2022-07-14  5:02 ` Masahiro Yamada
  2022-07-14  5:02 ` [PATCH 3/4] kbuild: error out if $(KBUILD_EXTMOD) contains % or : Masahiro Yamada
  2022-07-14  5:02 ` [PATCH 4/4] kbuild: error out if $(INSTALL_MOD_PATH) " Masahiro Yamada
  2 siblings, 0 replies; 8+ messages in thread
From: Masahiro Yamada @ 2022-07-14  5:02 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Masahiro Yamada, Michal Marek, Nick Desaulniers, linux-kernel

Presumably, _target_os is defined even if the --target flag does not
specify it, but it is better to make it explicit.

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

 scripts/Makefile.package | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/Makefile.package b/scripts/Makefile.package
index 77b612183c08..5017f6b2da80 100644
--- a/scripts/Makefile.package
+++ b/scripts/Makefile.package
@@ -56,7 +56,7 @@ rpm-pkg:
 	$(MAKE) clean
 	$(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
 	$(call cmd,src_tar,$(KERNELPATH),kernel.spec)
-	+rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz \
+	+rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -ta $(KERNELPATH).tar.gz \
 	--define='_smp_mflags %{nil}'
 
 # binrpm-pkg
@@ -66,7 +66,7 @@ binrpm-pkg:
 	$(MAKE) -f $(srctree)/Makefile
 	$(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
 	+rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
-		$(UTS_MACHINE) -bb $(objtree)/binkernel.spec
+		$(UTS_MACHINE)-linux -bb $(objtree)/binkernel.spec
 
 PHONY += deb-pkg
 deb-pkg:
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/4] kbuild: error out if $(KBUILD_EXTMOD) contains % or :
  2022-07-14  5:02 [PATCH 1/4] kbuild: rpm-pkg: fix build error when _arch is undefined Masahiro Yamada
  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 ` 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
  2 siblings, 2 replies; 8+ messages in thread
From: Masahiro Yamada @ 2022-07-14  5:02 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Masahiro Yamada, Michal Marek, Nick Desaulniers, linux-kernel

If the directory pass given to KBUILD_EXTMOD (or M=) contains % or :,
the module fails to build.

% is used in pattern rules, and : as the separator of dependencies.

Bail out with a clearer error message.

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

 Makefile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Makefile b/Makefile
index faa4880f25f7..ecda62e27553 100644
--- a/Makefile
+++ b/Makefile
@@ -129,6 +129,9 @@ endif
 $(if $(word 2, $(KBUILD_EXTMOD)), \
 	$(error building multiple external modules is not supported))
 
+$(foreach x, % :, $(if $(findstring $x, $(KBUILD_EXTMOD)), \
+	$(error module directory path cannot contain '$x')))
+
 # Remove trailing slashes
 ifneq ($(filter %/, $(KBUILD_EXTMOD)),)
 KBUILD_EXTMOD := $(shell dirname $(KBUILD_EXTMOD).)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/4] kbuild: error out if $(INSTALL_MOD_PATH) contains % or :
  2022-07-14  5:02 [PATCH 1/4] kbuild: rpm-pkg: fix build error when _arch is undefined Masahiro Yamada
  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-14  5:02 ` Masahiro Yamada
  2022-07-15  9:17   ` Nicolas Schier
  2022-07-16 15:40   ` Masahiro Yamada
  2 siblings, 2 replies; 8+ messages in thread
From: Masahiro Yamada @ 2022-07-14  5:02 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Masahiro Yamada, Michal Marek, Nick Desaulniers, linux-kernel

If the directory pass given to INSTALL_MOD_PATH contains % or :,
the module_install fails.

% is used in pattern rules, and : as the separator of dependencies.

Bail out with a clearer error message.

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

 scripts/Makefile.modinst | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
index 16a02e9237d3..a4c987c23750 100644
--- a/scripts/Makefile.modinst
+++ b/scripts/Makefile.modinst
@@ -18,6 +18,9 @@ INSTALL_MOD_DIR ?= extra
 dst := $(MODLIB)/$(INSTALL_MOD_DIR)
 endif
 
+$(foreach x, % :, $(if $(findstring $x, $(dst)), \
+	$(error module installation path cannot contain '$x')))
+
 suffix-y				:=
 suffix-$(CONFIG_MODULE_COMPRESS_GZIP)	:= .gz
 suffix-$(CONFIG_MODULE_COMPRESS_XZ)	:= .xz
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/4] kbuild: error out if $(KBUILD_EXTMOD) contains % or :
  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
  1 sibling, 0 replies; 8+ messages in thread
From: Nicolas Schier @ 2022-07-15  9:17 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, Michal Marek, Nick Desaulniers, linux-kernel

On Thu, Jul 14, 2022 at 02:02:42PM +0900, Masahiro Yamada wrote:
> If the directory pass given to KBUILD_EXTMOD (or M=) contains % or :,
> the module fails to build.
> 
> % is used in pattern rules, and : as the separator of dependencies.
> 
> Bail out with a clearer error message.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 4/4] kbuild: error out if $(INSTALL_MOD_PATH) contains % or :
  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
  1 sibling, 0 replies; 8+ messages in thread
From: Nicolas Schier @ 2022-07-15  9:17 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, Michal Marek, Nick Desaulniers, linux-kernel

On Thu, Jul 14, 2022 at 02:02:43PM +0900, Masahiro Yamada wrote:
> If the directory pass given to INSTALL_MOD_PATH contains % or :,
> the module_install fails.
> 
> % is used in pattern rules, and : as the separator of dependencies.
> 
> Bail out with a clearer error message.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/4] kbuild: error out if $(KBUILD_EXTMOD) contains % or :
  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
  1 sibling, 0 replies; 8+ messages in thread
From: Masahiro Yamada @ 2022-07-16 15:38 UTC (permalink / raw)
  To: Linux Kbuild mailing list
  Cc: Michal Marek, Nick Desaulniers, Linux Kernel Mailing List

On Thu, Jul 14, 2022 at 2:03 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> If the directory pass given to KBUILD_EXTMOD (or M=) contains % or :,

This is a typo.

directory pass -> directory path




> the module fails to build.
>
> % is used in pattern rules, and : as the separator of dependencies.
>
> Bail out with a clearer error message.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
>  Makefile | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index faa4880f25f7..ecda62e27553 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -129,6 +129,9 @@ endif
>  $(if $(word 2, $(KBUILD_EXTMOD)), \
>         $(error building multiple external modules is not supported))
>
> +$(foreach x, % :, $(if $(findstring $x, $(KBUILD_EXTMOD)), \
> +       $(error module directory path cannot contain '$x')))
> +
>  # Remove trailing slashes
>  ifneq ($(filter %/, $(KBUILD_EXTMOD)),)
>  KBUILD_EXTMOD := $(shell dirname $(KBUILD_EXTMOD).)
> --
> 2.34.1
>


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 4/4] kbuild: error out if $(INSTALL_MOD_PATH) contains % or :
  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
  1 sibling, 0 replies; 8+ messages in thread
From: Masahiro Yamada @ 2022-07-16 15:40 UTC (permalink / raw)
  To: Linux Kbuild mailing list
  Cc: Michal Marek, Nick Desaulniers, Linux Kernel Mailing List

On Thu, Jul 14, 2022 at 2:03 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> If the directory pass given to INSTALL_MOD_PATH contains % or :,

A typo.

directory pass  ->  directory path





> the module_install fails.
>
> % is used in pattern rules, and : as the separator of dependencies.
>
> Bail out with a clearer error message.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
>  scripts/Makefile.modinst | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
> index 16a02e9237d3..a4c987c23750 100644
> --- a/scripts/Makefile.modinst
> +++ b/scripts/Makefile.modinst
> @@ -18,6 +18,9 @@ INSTALL_MOD_DIR ?= extra
>  dst := $(MODLIB)/$(INSTALL_MOD_DIR)
>  endif
>
> +$(foreach x, % :, $(if $(findstring $x, $(dst)), \
> +       $(error module installation path cannot contain '$x')))
> +
>  suffix-y                               :=
>  suffix-$(CONFIG_MODULE_COMPRESS_GZIP)  := .gz
>  suffix-$(CONFIG_MODULE_COMPRESS_XZ)    := .xz
> --
> 2.34.1
>


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-07-16 15:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-14  5:02 [PATCH 1/4] kbuild: rpm-pkg: fix build error when _arch is undefined Masahiro Yamada
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).