Blame SPECS/kpatch-patch.spec

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