Blame SPECS/kpatch-patch.spec

498dbc
# Set to 1 if building an empty subscription-only package.
498dbc
%define empty_package		1
498dbc
498dbc
#######################################################
498dbc
# Only need to update these variables and the changelog
498dbc
%define kernel_ver	3.10.0-1160.102.1.el7
498dbc
%define kpatch_ver	0.9.2
498dbc
%define rpm_ver		0
498dbc
%define rpm_rel		0
498dbc
498dbc
%if !%{empty_package}
498dbc
# Patch sources below. DO NOT REMOVE THIS LINE.
498dbc
Source100:		XXX.patch
498dbc
#Source101:		YYY.patch
498dbc
# End of patch sources. DO NOT REMOVE THIS LINE.
498dbc
%endif
498dbc
498dbc
%define sanitized_rpm_rel	%{lua: print((string.gsub(rpm.expand("%rpm_rel"), "%.", "_")))}
498dbc
%define sanitized_kernel_ver	%{lua: print((string.gsub(string.gsub(rpm.expand("%kernel_ver"), ".el7", ""), "%.", "_")))}
498dbc
%define kernel_ver_arch	%{kernel_ver}.%{_arch}
498dbc
498dbc
Name:		kpatch-patch-%{sanitized_kernel_ver}
498dbc
Version:	%{rpm_ver}
498dbc
Release:	%{rpm_rel}.el7
498dbc
498dbc
%if %{empty_package}
498dbc
Summary:	Initial empty kpatch-patch for kernel-%{kernel_ver_arch}
498dbc
%else
498dbc
Summary:	Live kernel patching module for kernel-%{kernel_ver_arch}
498dbc
%endif
498dbc
498dbc
Group:		System Environment/Kernel
498dbc
License:	GPLv2
498dbc
ExclusiveArch:	x86_64 ppc64le
498dbc
498dbc
Conflicts:	%{name} < %{version}-%{release}
498dbc
498dbc
Provides:	kpatch-patch = %{kernel_ver_arch}
498dbc
Provides:	kpatch-patch = %{kernel_ver}
498dbc
498dbc
%if !%{empty_package}
498dbc
Requires:	systemd
498dbc
%endif
498dbc
Requires:	kpatch >= 0.4.0-3
498dbc
Requires:	kernel-uname-r = %{kernel_ver_arch}
498dbc
498dbc
%if !%{empty_package}
498dbc
BuildRequires:	gcc elfutils-devel rpmdevtools asciidoc bc hmaccalc m4 net-tools xmlto zlib-devel binutils-devel newt-devel python-devel perl(ExtUtils::Embed) bison audit-libs-devel numactl-devel pciutils-devel openssl gettext kernel-devel ncurses-devel hostname java-devel python-docutils
498dbc
BuildRequires:	kernel-devel = %{kernel_ver}
498dbc
BuildRequires:	kernel-debuginfo = %{kernel_ver}
498dbc
498dbc
%ifarch x86_64
498dbc
BuildRequires: pesign
498dbc
%endif
498dbc
498dbc
%ifarch ppc64le
498dbc
BuildRequires: gcc-plugin-devel
498dbc
%endif
498dbc
498dbc
Source0:	https://github.com/dynup/kpatch/archive/v%{kpatch_ver}.tar.gz
498dbc
498dbc
Source10:	kernel-%{kernel_ver}.src.rpm
498dbc
498dbc
# kpatch-build patches
498dbc
# Patch1: backport.patch
498dbc
Patch1: v0.9.2-backport-MR-1281-create-diff-object-add-suppo.patch
498dbc
Patch2: v0.9.2-backport-MR-1200-Make-sure-section-symbols-ex.patch
498dbc
498dbc
%global _dupsign_opts --keyname=rhelkpatch1
498dbc
498dbc
%define builddir	%{_builddir}/kpatch-%{kpatch_ver}
498dbc
%define kpatch		%{_sbindir}/kpatch
498dbc
%define kmoddir		%{_usr}/lib/kpatch/%{kernel_ver_arch}
498dbc
%define patchmodname	kpatch-%{sanitized_kernel_ver}-%{version}-%{sanitized_rpm_rel}
498dbc
%define patchmod	%{patchmodname}.ko
498dbc
498dbc
%define _missing_build_ids_terminate_build 1
498dbc
%define _find_debuginfo_opts -r
498dbc
%undefine _include_minidebuginfo
498dbc
%undefine _find_debuginfo_dwz_opts
498dbc
498dbc
%description
498dbc
This is a kernel live patch module which can be loaded by the kpatch
498dbc
command line utility to modify the code of a running kernel.  This patch
498dbc
module is targeted for kernel-%{kernel_ver}.
498dbc
498dbc
%prep
498dbc
%autosetup -n kpatch-%{kpatch_ver} -p1
498dbc
498dbc
%build
498dbc
kdevdir=/usr/src/kernels/%{kernel_ver_arch}
498dbc
vmlinux=/usr/lib/debug/lib/modules/%{kernel_ver_arch}/vmlinux
498dbc
498dbc
# kpatch-build
498dbc
make -C kpatch-build
498dbc
498dbc
# patch module
498dbc
for i in %{sources}; do
498dbc
	[[ $i == *.patch ]] && patch_sources="$patch_sources $i"
498dbc
done
498dbc
export CACHEDIR="%{builddir}/.kpatch"
498dbc
kpatch-build/kpatch-build -n %{patchmodname} -r %{SOURCE10} -v $vmlinux --skip-cleanup $patch_sources || { cat "${CACHEDIR}/build.log"; exit 1; }
498dbc
498dbc
498dbc
%install
498dbc
installdir=%{buildroot}/%{kmoddir}
498dbc
install -d $installdir
498dbc
install -m 755 %{builddir}/%{patchmod} $installdir
498dbc
498dbc
498dbc
%files
498dbc
%{_usr}/lib/kpatch
498dbc
498dbc
498dbc
%post
498dbc
if [[ %{kernel_ver_arch} = $(uname -r) ]]; then
498dbc
	cver="%{rpm_ver}_%{rpm_rel}"
498dbc
	pname=$(echo "kpatch_%{sanitized_kernel_ver}" | sed 's/-/_/')
498dbc
498dbc
	lver=$({ %{kpatch} list | sed -nr "s/^${pname}_([0-9_]+)\ \[enabled\]$/\1/p"; echo "${cver}"; } | sort -V | tail -1)
498dbc
498dbc
	if [ "${lver}" != "${cver}" ]; then
498dbc
		echo "WARNING: at least one loaded kpatch-patch (${pname}_${lver}) has a newer version than the one being installed."
498dbc
		echo "WARNING: You will have to reboot to load a downgraded kpatch-patch"
498dbc
	else
498dbc
		%{kpatch} load %{kmoddir}/%{patchmod}
498dbc
	fi
498dbc
fi
498dbc
%{kpatch} install -k %{kernel_ver_arch} %{kmoddir}/%{patchmod}
498dbc
sync
498dbc
exit 0
498dbc
498dbc
498dbc
%postun
498dbc
%{kpatch} uninstall -k %{kernel_ver_arch} %{patchmod}
498dbc
sync
498dbc
exit 0
498dbc
498dbc
%else
498dbc
%description
498dbc
This is an empty kpatch-patch package which does not contain any real patches.
498dbc
It is only a method to subscribe to the kpatch stream for kernel-%{kernel_ver}.
498dbc
498dbc
%files
498dbc
%doc
498dbc
%endif
498dbc
498dbc
%changelog
498dbc
* Mon Sep 25 2023 Yannick Cote <ycote@redhat.com> [0-0.el7]
498dbc
- An empty patch to subscribe to kpatch stream for kernel-3.10.0-1160.102.1.el7 [RHEL-9239]