Blame SPECS/kpatch-patch.spec

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