Skip to content

Commit 0585797

Browse files
author
Rafal Stefanowski
committed
pckgen: Allow building RPM packages for different kernel versions
- add --kernel-version option - add --mock option for 'mock' support to emulate building RPM packages on other distros to further improve choosing proper kernel version - update dependencies Signed-off-by: Rafal Stefanowski <rafal.stefanowski@huawei.com>
1 parent c782b05 commit 0585797

File tree

3 files changed

+203
-96
lines changed

3 files changed

+203
-96
lines changed

Makefile

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#
22
# Copyright(c) 2012-2022 Intel Corporation
33
# Copyright(c) 2024 Huawei Technologies
4-
# Copyright(c) 2025 Brian J. Murrell
54
# SPDX-License-Identifier: BSD-3-Clause
65
#
76

@@ -30,22 +29,11 @@ endif
3029
endif
3130
endif
3231

33-
ifneq ($(KERNEL_VERSION),)
34-
BUILD_ARGS=--kernel_version $(KERNEL_VERSION)
35-
endif
36-
37-
ifneq ($(MOCK_ROOT),)
38-
ifeq ($(KERNEL_VERSION),)
39-
$(error KERNEL_VERSION must be set when using MOCK_ROOT)
40-
endif
41-
BUILD_ARGS=--mock_root $(MOCK_ROOT) --kernel_version $(KERNEL_VERSION)
42-
endif
43-
4432
archives:
4533
@tools/pckgen.sh $(PWD) tar zip
4634

4735
rpm:
48-
@tools/pckgen.sh $(PWD) rpm --debug $(BUILD_ARGS)
36+
@tools/pckgen.sh $(PWD) rpm --debug
4937

5038
srpm:
5139
@tools/pckgen.sh $(PWD) srpm

tools/pckgen.d/rpm/CAS_NAME.spec

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
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
#
@@ -13,34 +14,39 @@
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
4551
Open Cache Acceleration Software (Open CAS) is an open source project
4652
encompassing 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
7883
rm -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
114119
else
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
119124
fi
@@ -176,10 +181,10 @@ fi
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

Comments
 (0)