Blame SPECS/kpatch-patch.spec

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