Blame SPECS/kpatch-patch.spec

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