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+ License: <CAS_LICENSE_NAME>
31+ URL: < CAS_HOMEPAGE>
32+ Source0: https://github.com/Open-CAS/< CAS_NAME> /releases/download/v%{version }/%{name }-%{version }.tar.gz
33+ Packager: < PACKAGE_MAINTAINER>
34+ BuildRequires: coreutils
35+ BuildRequires: gawk
36+ BuildRequires: gcc
37+ BuildRequires: make
38+ BuildRequires: procps
39+ BuildRequires: python3
40+ BuildRequires: kernel = %{kver_pkg }
41+ BuildRequires: kernel-devel = %{kver_pkg }
42+ # Allow using different version of kernel-headers package (some distros requires it).
43+ BuildRequires: kernel-headers
44+ BuildRequires: < LIBELF_PKG>
45+ BuildRequires: < UTIL_PKG>
46+ Requires: < CAS_NAME> -modules-%{version }
47+ Requires: python3
48+ Requires: python3-PyYAML
49+ Requires: sed
4450%description
4551Open Cache Acceleration Software (Open CAS) is an open source project
4652encompassing block caching software libraries, adapters, tools and more.
@@ -65,7 +71,6 @@ This package contains only CAS kernel modules.
6571
6672%prep
6773%setup -q
68- sed -i ' s/@mandb -q/#@mandb -q/' {casadm,utils}/Makefile
6974
7075
7176%build
@@ -76,7 +81,7 @@ export KERNEL_DIR=/lib/modules/%{kver}/build/
7681
7782%install
7883rm -rf $RPM_BUILD_ROOT
79- /usr/bin/make install_files KERNEL_VERSION=%{kver } DESTDIR= $RPM_BUILD_ROOT
84+ /usr/bin/make install_files DESTDIR= $RPM_BUILD_ROOT KERNEL_VERSION=%{kver }
8085
8186
8287%post
@@ -113,7 +118,7 @@ if [[ ! "$ID_LIKE" =~ suse|sles ]]; then
113118 printf "%s \n" "${modules[@]}" | weak-modules --no-initramfs --add-modules
114119else
115120 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
121+ # run depmod for all kernel versions for which the modules installed
117122 depmod $version
118123 done
119124fi
176181
177182
178183%changelog
184+ * Mon Aug 25 2025 Rafal Stefanowski <rafal.stefanowski@huawei.com> - 25.03-1
179185* 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
186+ - Allow building RPM packages for different kernel versions
187+ - Update dependencies
183188* Mon Mar 21 2022 Rafal Stefanowski <rafal.stefanowski@intel.com> - 22.03-1
184189- Update modules destination directory and permissions
185190- Add license to modules package
0 commit comments