From d7490ffefa30cf31d30f86ec3e142d424a77c0b8 Mon Sep 17 00:00:00 2001 From: Eugene Syromiatnikov Date: Sat, 26 Jan 2019 08:38:11 +0100 Subject: [PATCH] macros.kmp: avoid error in latest_kernel when no kernel is installed If no kernel-devel packages are installed (this is possible, for example, during SRPM generation in an isolated environment), no output would be generated for latest_kernel macro, which would lead to an error (since an RPM macro can't have an empty definition). Append %nil to the input of the "head" command to avoid this situation. * macros.kmp (kernel_module_package): Feed additional line with %nil to the input of head command in the latest_kernel macro definition. Resolves: #1971748 Resolves: #2002887 Signed-off-by: Eugene Syromiatnikov --- macros.kmp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macros.kmp b/macros.kmp index d9508f2..60ec494 100644 --- a/macros.kmp +++ b/macros.kmp @@ -15,7 +15,7 @@ kernel_module_package_release 1 %global kmodtool %{-s*}%{!-s:/usr/lib/rpm/redhat/kmodtool} \ %global kmod_version %{-v*}%{!-v:%{version}} \ %global kmod_release %{-r*}%{!-r:%{release}} \ - %global latest_kernel %(rpm -q --qf '%{VERSION}-%{RELEASE}.%{ARCH}\\\\n' `rpm -qa | egrep "^kernel(-rt|-aarch64)?-devel" | /usr/lib/rpm/redhat/rpmsort -r | head -n 1` | head -n 1) \ + %global latest_kernel %({ rpm -q --qf '%%{VERSION}-%%{RELEASE}.%%{ARCH}\\\\n' `rpm -qa | egrep "^kernel(-rt|-aarch64)?-devel" | /usr/lib/rpm/redhat/rpmsort -r | head -n 1`; echo '%%%%{nil}'; } | head -n 1) \ %{!?kernel_version:%{expand:%%global kernel_version %{latest_kernel}}} \ %global kverrel %(%{kmodtool} verrel %{?kernel_version} 2>/dev/null) \ flavors="default" \