11#
22# Copyright(c) 2020-2022 Intel Corporation
3+ # Copyright(c) 2025 Huawei Technologies
34# Copyright(c) 2025 Brian J. Murrell
45# SPDX-License-Identifier: BSD-3-Clause
56#
1314
1415%global __python %{__python3}
1516< DEBUG_PACKAGE>
16- %if 0%{!?kver:1 }
17- %define kver %(uname -r)
18- %endif
19- %define kver_base %{expand:%(kname= "%{kver }"; echo "${kname%.*}")}
20- %define kver_filename k%{expand:%(echo "%kver_base " | sed -r "y/-/_/;")}
21-
22-
23- Name: < CAS_NAME>
24- Version: < CAS_VERSION>
25- Release: 1%{?dist }
26- Summary: Open Cache Acceleration Software
27- Group: System
28- Vendor: Intel Corporation
29- License: <CAS_LICENSE_NAME>
30- URL: < CAS_HOMEPAGE>
31- Source0: https://github.com/Open-CAS/< CAS_NAME> /releases/download/v%{version }/%{name }-%{version }.tar.gz
32- Packager: < PACKAGE_MAINTAINER>
33- BuildRequires: coreutils
34- BuildRequires: gawk
35- BuildRequires: gcc
36- BuildRequires: kernel-core = %{kver_base }
37- BuildRequires: kernel-devel = %{kver_base }
38- BuildRequires: kernel-headers
39- BuildRequires: make
40- BuildRequires: python3
41- BuildRequires: elfutils-libelf-devel
42- BuildRequires: procps-ng
43- Requires: < CAS_NAME> -modules-%{version }, python3, sed, python3-PyYAML
17+ %define kver < KVER>
18+ # Following define takes kernel version, cuts everything after (and including)
19+ # second hyphen (-), and then cuts the architecture (including 'noarch') part.
20+ # It's the only package version variant that is accepted by RPM spec.
21+ %define kver_pkg %{expand:%(kpkg= "%{kver }"; for i in $(seq 2 $(grep -o '-' <<< $kpkg | grep -c .)); do kpkg= "${kpkg%%-*}"; done; kpkg= "${kpkg%%.$(uname -m)}"; echo "${kpkg%%.noarch }")}
22+ %define kver_filename k%{expand:%(echo "%{kver }" | sed -r "y/-/_/;")}
23+
24+
25+ Name: < CAS_NAME>
26+ Version: < CAS_VERSION>
27+ Release: 1%{?dist }
28+ Summary: Open Cache Acceleration Software
29+ Group: System
30+ Vendor: Intel Corporation
31+ License: <CAS_LICENSE_NAME>
32+ URL: < CAS_HOMEPAGE>
33+ Source0: https://github.com/Open-CAS/< CAS_NAME> /releases/download/v%{version }/%{name }-%{version }.tar.gz
34+ Packager: < PACKAGE_MAINTAINER>
35+ BuildRequires: coreutils
36+ BuildRequires: gawk
37+ BuildRequires: gcc
38+ BuildRequires: make
39+ BuildRequires: procps
40+ BuildRequires: python3
41+ BuildRequires: kernel = %{kver_pkg }
42+ BuildRequires: kernel-devel = %{kver_pkg }
43+ # Allow using different version of kernel-headers package (some distros requires it).
44+ BuildRequires: kernel-headers
45+ BuildRequires: < LIBELF_PKG>
46+ BuildRequires: < UTIL_PKG>
47+ Requires: < CAS_NAME> -modules-%{version }
48+ Requires: python3
49+ Requires: python3-PyYAML
50+ Requires: sed
4451%description
4552Open Cache Acceleration Software (Open CAS) is an open source project
4653encompassing block caching software libraries, adapters, tools and more.
@@ -65,7 +72,6 @@ This package contains only CAS kernel modules.
6572
6673%prep
6774%setup -q
68- sed -i ' s/@mandb -q/#@mandb -q/' {casadm,utils}/Makefile
6975
7076
7177%build
@@ -76,7 +82,7 @@ export KERNEL_DIR=/lib/modules/%{kver}/build/
7682
7783%install
7884rm -rf $RPM_BUILD_ROOT
79- /usr/bin/make install_files KERNEL_VERSION=%{kver } DESTDIR= $RPM_BUILD_ROOT
85+ /usr/bin/make install_files DESTDIR= $RPM_BUILD_ROOT KERNEL_VERSION=%{kver }
8086
8187
8288%post
@@ -113,7 +119,7 @@ if [[ ! "$ID_LIKE" =~ suse|sles ]]; then
113119 printf "%s \n" "${modules[@]}" | weak-modules --no-initramfs --add-modules
114120else
115121 for version in $(echo "${modules[@]}" | tr " " "\n" | cut -d"/" -f4 | sort | uniq); do
116- # run depmod for all kernel versions for which the modules installed
122+ # run depmod for all kernel versions for which the modules installed
117123 depmod $version
118124 done
119125fi
176182
177183
178184%changelog
185+ * Mon Aug 25 2025 Rafal Stefanowski <rafal.stefanowski@huawei.com> - 25.03-1
179186* Thu Aug 7 2025 Brian J. Murrell <brian@interlinx.bc.ca> - 25.03-1
180- - Make more portable:
181- - Allow external definition of kver
182- - Add missing BRs kernel-core, python3, elfutils-libelf-devel, procps-ng
187+ - Allow building RPM packages for different kernel versions
188+ - Update dependencies
183189* Mon Mar 21 2022 Rafal Stefanowski <rafal.stefanowski@intel.com> - 22.03-1
184190- Update modules destination directory and permissions
185191- Add license to modules package
0 commit comments