Blame SPECS/kpatch-patch.spec

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