Blame SPECS/kpatch-patch.spec

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