From bb95fef3cf19114a9abf051062d0769873b1fd70 Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Mar 19 2022 17:24:55 +0000 Subject: rpm: Use bash for %() expansion (jsc#SLE-18234). Since 15.4 alternatives for /bin/sh are provided by packages -sh. While the interpreter for the build script can be selected the interpreter for %() cannot. The kernel spec files use bashisms in %(). While this could technically be fixed there is more serious underlying problem: neither bash nor any of the alternatives are 100% POSIX compliant nor bug-free. It is not my intent to maintain bug compatibility with any number of shells for shell scripts embedded in the kernel spec file. The spec file syntax is not documented so embedding the shell script in it causes some unspecified transformation to be applied to it. That means that ultimately any changes must be tested by building the kernel, n times if n shells are supported. To reduce maintenance effort require that bash is used for kernel build always. Signed-off-by: Michal Suchanek --- diff --git a/rpm/kernel-binary.spec.in b/rpm/kernel-binary.spec.in index 6293011..9be2051 100644 --- a/rpm/kernel-binary.spec.in +++ b/rpm/kernel-binary.spec.in @@ -114,6 +114,9 @@ Release: .g@COMMIT@ Release: @RELEASE@ %endif URL: https://www.kernel.org/ +%if 0%{?suse_version} > 1500 || 0%{?sle_version} > 150300 +BuildRequires: bash-sh +%endif BuildRequires: bc BuildRequires: bison BuildRequires: coreutils diff --git a/rpm/kernel-docs.spec.in b/rpm/kernel-docs.spec.in index 9310e27..14a8bf6 100644 --- a/rpm/kernel-docs.spec.in +++ b/rpm/kernel-docs.spec.in @@ -37,6 +37,9 @@ Release: .g@COMMIT@ %else Release: @RELEASE@ %endif +%if 0%{?suse_version} > 1500 || 0%{?sle_version} > 150300 +BuildRequires: bash-sh +%endif # TW (4.13 or later) no longer needs xmlto %if 0%{?sle_version} BuildRequires: xmlto diff --git a/rpm/kernel-source.spec.in b/rpm/kernel-source.spec.in index bbbf9dc..2647269 100644 --- a/rpm/kernel-source.spec.in +++ b/rpm/kernel-source.spec.in @@ -42,6 +42,9 @@ License: GPL-2.0-only Group: Development/Sources URL: https://www.kernel.org/ AutoReqProv: off +%if 0%{?suse_version} > 1500 || 0%{?sle_version} > 150300 +BuildRequires: bash-sh +%endif BuildRequires: coreutils BuildRequires: fdupes BuildRequires: sed diff --git a/rpm/macros.kernel-source b/rpm/macros.kernel-source index 81ed8ae..fb4f637 100644 --- a/rpm/macros.kernel-source +++ b/rpm/macros.kernel-source @@ -1,6 +1,11 @@ # A few cross-distro definitions: +%if 0%{?suse_version} > 1500 || 0%{?sle_version} > 150300 +%define kernel_build_shell_package bash-sh +%else +%define kernel_build_shell_package %nil +%endif %kernel_module_package_release 1 -%kernel_module_package_buildreqs modutils kernel-syms kmod-compat +%kernel_module_package_buildreqs modutils kernel-syms kmod-compat %kernel_build_shell_package %cpu_arch %(case %_target_cpu in \ # from rpm --eval '%ix86' \