Blame SPECS/kpatch-patch.spec

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