Blame SPECS/kpatch-patch.spec

c2d3bd
# Set to 1 if building an empty subscription-only package.
c2d3bd
%define empty_package		1
c2d3bd
c2d3bd
#######################################################
c2d3bd
# Only need to update these variables and the changelog
c2d3bd
%define kernel_ver	5.14.0-162.18.1.el9_1
c2d3bd
%define kpatch_ver	0.9.7
c2d3bd
%define rpm_ver		0
c2d3bd
%define rpm_rel		0
c2d3bd
c2d3bd
%if !%{empty_package}
c2d3bd
# Patch sources below. DO NOT REMOVE THIS LINE.
c2d3bd
Source100:		XXX.patch
c2d3bd
#Source101:		YYY.patch
c2d3bd
# End of patch sources. DO NOT REMOVE THIS LINE.
c2d3bd
%endif
c2d3bd
c2d3bd
%define sanitized_rpm_rel	%{lua: print((string.gsub(rpm.expand("%rpm_rel"), "%.", "_")))}
c2d3bd
%define sanitized_kernel_ver   %{lua: print((string.gsub(string.gsub(rpm.expand("%kernel_ver"), '.el9_?\%d?', ""), "%.", "_")))}
c2d3bd
%define kernel_ver_arch        %{kernel_ver}.%{_arch}
c2d3bd
c2d3bd
Name:		kpatch-patch-%{sanitized_kernel_ver}
c2d3bd
Version:	%{rpm_ver}
c2d3bd
Release:	%{rpm_rel}%{?dist}
c2d3bd
c2d3bd
%if %{empty_package}
c2d3bd
Summary:	Initial empty kpatch-patch for kernel-%{kernel_ver_arch}
c2d3bd
%else
c2d3bd
Summary:	Live kernel patching module for kernel-%{kernel_ver_arch}
c2d3bd
%endif
c2d3bd
c2d3bd
Group:		System Environment/Kernel
c2d3bd
License:	GPLv2
c2d3bd
ExclusiveArch:	x86_64 ppc64le
c2d3bd
c2d3bd
Conflicts:	%{name} < %{version}-%{release}
c2d3bd
c2d3bd
Provides:	kpatch-patch = %{kernel_ver_arch}
c2d3bd
Provides:	kpatch-patch = %{kernel_ver}
c2d3bd
c2d3bd
%if !%{empty_package}
c2d3bd
Requires:	systemd
c2d3bd
%endif
c2d3bd
Requires:	kpatch >= 0.6.1-1
c2d3bd
Requires:	kernel-uname-r = %{kernel_ver_arch}
c2d3bd
c2d3bd
%if !%{empty_package}
c2d3bd
BuildRequires:	patchutils
c2d3bd
BuildRequires:	kernel-devel = %{kernel_ver}
c2d3bd
BuildRequires:	kernel-debuginfo = %{kernel_ver}
c2d3bd
c2d3bd
# kernel build requirements, generated from:
c2d3bd
#   % rpmspec -q --buildrequires kernel.spec | sort | awk '{print "BuildRequires:\t" $0}'
c2d3bd
# with arch-specific packages moved into conditional block
c2d3bd
BuildRequires:	bash
c2d3bd
BuildRequires:	bc
c2d3bd
BuildRequires:	binutils
c2d3bd
BuildRequires:	bison
c2d3bd
BuildRequires:	bpftool
c2d3bd
BuildRequires:	bzip2
c2d3bd
BuildRequires:	coreutils
c2d3bd
BuildRequires:	diffutils
c2d3bd
BuildRequires:	dwarves
c2d3bd
BuildRequires:	elfutils
c2d3bd
BuildRequires:	elfutils-devel
c2d3bd
BuildRequires:	findutils
c2d3bd
BuildRequires:	flex
c2d3bd
BuildRequires:	gawk
c2d3bd
BuildRequires:	gcc
c2d3bd
BuildRequires:	gcc-c++
c2d3bd
BuildRequires:	gcc-plugin-devel
c2d3bd
BuildRequires:	git-core
c2d3bd
BuildRequires:	glibc-static
c2d3bd
BuildRequires:	gzip
c2d3bd
BuildRequires:	hmaccalc
c2d3bd
BuildRequires:	hostname
c2d3bd
BuildRequires:	kernel-rpm-macros >= 185-9
c2d3bd
BuildRequires:	kmod
c2d3bd
BuildRequires:	m4
c2d3bd
BuildRequires:	make
c2d3bd
BuildRequires:	net-tools
c2d3bd
BuildRequires:	nss-tools
c2d3bd
BuildRequires:	openssl
c2d3bd
BuildRequires:	openssl-devel
c2d3bd
BuildRequires:	patch
c2d3bd
BuildRequires:	perl-Carp
c2d3bd
BuildRequires:	perl-devel
c2d3bd
BuildRequires:	perl-generators
c2d3bd
BuildRequires:	perl-interpreter
c2d3bd
BuildRequires:	python3-devel
c2d3bd
BuildRequires:	redhat-rpm-config
c2d3bd
BuildRequires:	rpm-build
c2d3bd
BuildRequires:	system-sb-certs
c2d3bd
BuildRequires:	tar
c2d3bd
BuildRequires:	which
c2d3bd
BuildRequires:	xz
c2d3bd
c2d3bd
%ifarch x86_64
c2d3bd
BuildRequires:	pesign >= 0.10-4
c2d3bd
%endif
c2d3bd
c2d3bd
Source0:	https://github.com/dynup/kpatch/archive/v%{kpatch_ver}.tar.gz
c2d3bd
c2d3bd
Source10:	kernel-%{kernel_ver}.src.rpm
c2d3bd
c2d3bd
# kpatch-build patches
c2d3bd
Patch1: v0.9.7-backport-MR-1314-create-diff-object-fix-__UNI.patch
c2d3bd
Patch2: v0.9.7-backport-MR-1315-Static-call-fixes.patch
c2d3bd
c2d3bd
%global _dupsign_opts --keyname=rhelkpatch1
c2d3bd
c2d3bd
%define builddir	%{_builddir}/kpatch-%{kpatch_ver}
c2d3bd
%define kpatch		%{_sbindir}/kpatch
c2d3bd
%define kmoddir 	%{_usr}/lib/kpatch/%{kernel_ver_arch}
c2d3bd
%define kinstdir	%{_sharedstatedir}/kpatch/%{kernel_ver_arch}
c2d3bd
%define patchmodname	kpatch-%{sanitized_kernel_ver}-%{version}-%{sanitized_rpm_rel}
c2d3bd
%define patchmod	%{patchmodname}.ko
c2d3bd
c2d3bd
%define _missing_build_ids_terminate_build 1
c2d3bd
%define _find_debuginfo_opts -r
c2d3bd
%undefine _include_minidebuginfo
c2d3bd
%undefine _find_debuginfo_dwz_opts
c2d3bd
c2d3bd
%description
c2d3bd
This is a kernel live patch module which can be loaded by the kpatch
c2d3bd
command line utility to modify the code of a running kernel.  This patch
c2d3bd
module is targeted for kernel-%{kernel_ver}.
c2d3bd
c2d3bd
%prep
c2d3bd
%autosetup -n kpatch-%{kpatch_ver} -p1
c2d3bd
c2d3bd
%build
c2d3bd
kdevdir=/usr/src/kernels/%{kernel_ver_arch}
c2d3bd
vmlinux=/usr/lib/debug/lib/modules/%{kernel_ver_arch}/vmlinux
c2d3bd
c2d3bd
# kpatch-build
c2d3bd
make -C kpatch-build
c2d3bd
c2d3bd
# patch module
c2d3bd
for i in %{sources}; do
c2d3bd
	[[ $i == *.patch ]] && patch_sources="$patch_sources $i"
c2d3bd
done
c2d3bd
export CACHEDIR="%{builddir}/.kpatch"
c2d3bd
kpatch-build/kpatch-build -n %{patchmodname} -r %{SOURCE10} -v $vmlinux --skip-cleanup $patch_sources || { cat "${CACHEDIR}/build.log"; exit 1; }
c2d3bd
c2d3bd
c2d3bd
%install
c2d3bd
installdir=%{buildroot}/%{kmoddir}
c2d3bd
install -d $installdir
c2d3bd
install -m 755 %{builddir}/%{patchmod} $installdir
c2d3bd
c2d3bd
c2d3bd
%files
c2d3bd
%{_usr}/lib/kpatch
c2d3bd
c2d3bd
c2d3bd
%post
c2d3bd
%{kpatch} install -k %{kernel_ver_arch} %{kmoddir}/%{patchmod}
c2d3bd
chcon -t modules_object_t %{kinstdir}/%{patchmod}
c2d3bd
sync
c2d3bd
if [[ %{kernel_ver_arch} = $(uname -r) && "${LEAPP_IPU_IN_PROGRESS}" != "8to9" ]]; then
c2d3bd
	cver="%{rpm_ver}_%{rpm_rel}"
c2d3bd
	pname=$(echo "kpatch_%{sanitized_kernel_ver}" | sed 's/-/_/')
c2d3bd
c2d3bd
	lver=$({ %{kpatch} list | sed -nr "s/^${pname}_([0-9_]+)\ \[enabled\]$/\1/p"; echo "${cver}"; } | sort -V | tail -1)
c2d3bd
c2d3bd
	if [ "${lver}" != "${cver}" ]; then
c2d3bd
		echo "WARNING: at least one loaded kpatch-patch (${pname}_${lver}) has a newer version than the one being installed."
c2d3bd
		echo "WARNING: You will have to reboot to load a downgraded kpatch-patch"
c2d3bd
	else
c2d3bd
		%{kpatch} load %{patchmod}
c2d3bd
	fi
c2d3bd
fi
c2d3bd
exit 0
c2d3bd
c2d3bd
c2d3bd
%postun
c2d3bd
%{kpatch} uninstall -k %{kernel_ver_arch} %{patchmod}
c2d3bd
sync
c2d3bd
exit 0
c2d3bd
c2d3bd
%else
c2d3bd
%description
c2d3bd
This is an empty kpatch-patch package which does not contain any real patches.
c2d3bd
It is only a method to subscribe to the kpatch stream for kernel-%{kernel_ver}.
c2d3bd
c2d3bd
%files
c2d3bd
%doc
c2d3bd
%endif
c2d3bd
c2d3bd
%changelog
c2d3bd
* Thu Feb 09 2023 Linqing Lu <lilu@redhat.com> [0-0.el9]
c2d3bd
- An empty patch to subscribe to kpatch stream for kernel-5.14.0-162.18.1.el9_1 [2168756]