Blame SPECS/kpatch-patch.spec

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