Skip to content

Commit 3150c3f

Browse files
Merge pull request #1674 from brianjmurrell/build-rpm-with-mock
Allow bulding RPMs with mock
2 parents a6b8c09 + 0585797 commit 3150c3f

File tree

4 files changed

+220
-58
lines changed

4 files changed

+220
-58
lines changed

casadm/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,12 @@ clean:
169169
distclean: clean
170170

171171
install: install_files
172+
@mandb -q
172173

173174
install_files:
174175
@echo "Installing casadm"
175176
@install -m 755 -D $(TARGET) $(DESTDIR)$(BINARY_PATH)/$(TARGET)
176177
@install -m 644 -D $(TARGET).8.gz $(DESTDIR)/usr/share/man/man8/$(TARGET).8.gz
177-
@mandb -q
178178

179179
uninstall:
180180
@echo "Uninstalling casadm"

tools/pckgen.d/rpm/CAS_NAME.spec

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#
22
# Copyright(c) 2020-2022 Intel Corporation
3+
# Copyright(c) 2025 Huawei Technologies
4+
# Copyright(c) 2025 Brian J. Murrell
35
# SPDX-License-Identifier: BSD-3-Clause
46
#
57

@@ -12,22 +14,39 @@
1214

1315
%global __python %{__python3}
1416
<DEBUG_PACKAGE>
15-
%define kver %(uname -r)
16-
%define kver_filename k%{expand:%(kname="%{kver}"; echo "${kname%.*}" | sed -r "y/-/_/;")}
17-
18-
19-
Name: <CAS_NAME>
20-
Version: <CAS_VERSION>
21-
Release: 1%{?dist}
22-
Summary: Open Cache Acceleration Software
23-
Group: System
24-
Vendor: Intel Corporation
25-
License: <CAS_LICENSE_NAME>
26-
URL: <CAS_HOMEPAGE>
27-
Source0: https://github.com/Open-CAS/<CAS_NAME>/releases/download/v%{version}/%{name}-%{version}.tar.gz
28-
Packager: <PACKAGE_MAINTAINER>
29-
BuildRequires: coreutils, gawk, gcc, kernel-devel, kernel-headers, make
30-
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
3150
%description
3251
Open Cache Acceleration Software (Open CAS) is an open source project
3352
encompassing block caching software libraries, adapters, tools and more.
@@ -55,13 +74,14 @@ This package contains only CAS kernel modules.
5574

5675

5776
%build
77+
export KERNEL_DIR=/lib/modules/%{kver}/build/
5878
./configure
5979
<MAKE_BUILD>
6080

6181

6282
%install
6383
rm -rf $RPM_BUILD_ROOT
64-
/usr/bin/make install_files DESTDIR=$RPM_BUILD_ROOT
84+
/usr/bin/make install_files DESTDIR=$RPM_BUILD_ROOT KERNEL_VERSION=%{kver}
6585

6686

6787
%post
@@ -98,7 +118,7 @@ if [[ ! "$ID_LIKE" =~ suse|sles ]]; then
98118
printf "%s\n" "${modules[@]}" | weak-modules --no-initramfs --add-modules
99119
else
100120
for version in $(echo "${modules[@]}" | tr " " "\n" | cut -d"/" -f4 | sort | uniq); do
101-
# run depmod for all kernel versions for which the modules installed
121+
# run depmod for all kernel versions for which the modules installed
102122
depmod $version
103123
done
104124
fi
@@ -161,6 +181,10 @@ fi
161181

162182

163183
%changelog
184+
* Mon Aug 25 2025 Rafal Stefanowski <rafal.stefanowski@huawei.com> - 25.03-1
185+
* Thu Aug 7 2025 Brian J. Murrell <brian@interlinx.bc.ca> - 25.03-1
186+
- Allow building RPM packages for different kernel versions
187+
- Update dependencies
164188
* Mon Mar 21 2022 Rafal Stefanowski <rafal.stefanowski@intel.com> - 22.03-1
165189
- Update modules destination directory and permissions
166190
- Add license to modules package

0 commit comments

Comments
 (0)