From f255b0e3136e80ef267ea87c52800263aeffb052 Mon Sep 17 00:00:00 2001 From: Jian Yu Date: Wed, 18 Sep 2024 16:57:50 -0700 Subject: [PATCH] LU-18233 build: check %kernel_module_package_buildreqs If rpm macro %kernel_module_package_buildreqs is undefined, building Lustre codes will report the following error: Dependency tokens must begin with alpha-numeric, '_' or '/': BuildRequires: %kernel_module_package_buildreqs However, the real issue is that kernel-rpm-macros or rpm-build rpm is not installed. And the error should be like: error: Failed build dependencies: kernel-rpm-macros is needed by ... This patch fixes the above issue by checking if the macro %kernel_module_package_buildreqs is defined before adding it to BuildRequires so as to avoid the misleading error. The patch also replaces suse_version with sle_version to get the correct version value for SLES15 SP3. Test-Parameters: trivial clientdistro=el9.4 testlist=sanity Test-Parameters: trivial clientdistro=el8.10 testlist=sanity Test-Parameters: trivial clientdistro=sles15sp6 \ env=SANITY_EXCEPT="103a 120e" testlist=sanity Fixes: 037840fb6b ("LU-12899 build: rhel8 not install kernel-rpm-macros") Fixes: c39d269f9d ("LU-12214 build: add right kernel detect") Fixes: 78c681d9f4 ("LU-16207 build: add rpm-build BuildRequires for SLES15 SP3") Change-Id: I151d93c0c74ab98e6589393a914acf18b5471289 Signed-off-by: Jian Yu Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56403 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Shaun Tancheff Reviewed-by: Qian Yingjin Reviewed-by: Oleg Drokin --- lustre.spec.in | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lustre.spec.in b/lustre.spec.in index 0e7a891..fdfef7f 100644 --- a/lustre.spec.in +++ b/lustre.spec.in @@ -315,13 +315,16 @@ Requires: mlnx-ofa_kernel-kmp %endif %endif %endif +%if %{defined kernel_module_package_buildreqs} +BuildRequires: %kernel_module_package_buildreqs +%else %if 0%{?rhel} >= 8 || 0%{?openEuler} BuildRequires: kernel-rpm-macros %endif -%if 0%{?suse_version} >= 1530 +%if 0%{?sle_version} >= 150300 BuildRequires: rpm-build >= 4.14.3 %endif -BuildRequires: %kernel_module_package_buildreqs +%endif # need to provide a /usr/lib/${uname -r)/build dir BuildRequires: kernel >= 3.10 %if "%{_vendor}" == "redhat" -- 1.8.3.1