add macros to extract major and minor nvidia version

This commit is contained in:
Mikhail Novosyolov 2022-09-20 14:42:53 +03:00
parent 34a69ebc4a
commit d7c49bf34e
2 changed files with 12 additions and 1 deletions

View file

@ -3,7 +3,7 @@ Name: auto-krokodil
Group: System/Kernel and hardware
License: GPLv3
Url: https://abf.io/import/auto-krokodil
Version: 0.9
Version: 0.10
Release: 1
BuildArch: noarch
%ifarch %{ix86} %{x86_64}

View file

@ -101,3 +101,14 @@ Requires: (kmod-nvidia%{-j*}.%{-n*}-kabi(%{-p*}) if nvidia%{-j*}) \
Requires: (kmod-nvidia-%{-k*}-%{-f*}(%{-j*}.%{-n*}) if kernel-%{-k*}-%{-f*}) \
%{nil} \
}
# Extract major and minor versions of package $1
# Example:
# kernel-source-nvidia390 has version 390.5
# korko_j will extract 390, kroko_n will extract 5
# See also: https://github.com/rpm-software-management/rpm/pull/1794
# p - name of package which version to extract (e.g.: kernel-source-nvidia390)
# r - any number (e.g.: 0, 1, 390 etc.)
# needed at SRPM stage when _j and _n cannot extract real versions to avoid duplicate subpackages
%kroko_j(p:r:) %(if rpm -q %{-p*} >/dev/null 2>&1; then rpm -q --qf '%%{version}' %{-p*} | awk -F '.' '{print $1}'; else echo %{-r*}; fi)
%kroko_n(p:r:) %(if rpm -q %{-p*} >/dev/null 2>&1; then rpm -q --qf '%%{version}' %{-p*} | awk -F '.' '{print $2}'; else echo %{-r*}; fi)