Blame SPECS/kpatch-patch.spec

d058b5
# Set to 1 if building an empty subscription-only package.
d058b5
%define empty_package		1
d058b5
d058b5
#######################################################
d058b5
# Only need to update these variables and the changelog
d058b5
%define kernel_ver	4.18.0-193.14.3.el8_2
d058b5
%define kpatch_ver	0.9.1
d058b5
%define rpm_ver		0
d058b5
%define rpm_rel		0
d058b5
d058b5
%if !%{empty_package}
d058b5
# Patch sources below. DO NOT REMOVE THIS LINE.
d058b5
Source100:		XXX.patch
d058b5
#Source101:		YYY.patch
d058b5
# End of patch sources. DO NOT REMOVE THIS LINE.
d058b5
%endif
d058b5
d058b5
%define sanitized_rpm_rel	%{lua: print((string.gsub(rpm.expand("%rpm_rel"), "%.", "_")))}
d058b5
%define sanitized_kernel_ver   %{lua: print((string.gsub(string.gsub(rpm.expand("%kernel_ver"), '.el8_?\%d?', ""), "%.", "_")))}
d058b5
%define kernel_ver_arch        %{kernel_ver}.%{_arch}
d058b5
d058b5
Name:		kpatch-patch-%{sanitized_kernel_ver}
d058b5
Version:	%{rpm_ver}
d058b5
Release:	%{rpm_rel}%{?dist}
d058b5
d058b5
%if %{empty_package}
d058b5
Summary:	Initial empty kpatch-patch for kernel-%{kernel_ver_arch}
d058b5
%else
d058b5
Summary:	Live kernel patching module for kernel-%{kernel_ver_arch}
d058b5
%endif
d058b5
d058b5
Group:		System Environment/Kernel
d058b5
License:	GPLv2
d058b5
ExclusiveArch:	x86_64 ppc64le
d058b5
d058b5
Conflicts:	%{name} < %{version}-%{release}
d058b5
d058b5
Provides:	kpatch-patch = %{kernel_ver_arch}
d058b5
Provides:	kpatch-patch = %{kernel_ver}
d058b5
d058b5
%if !%{empty_package}
d058b5
Requires:	systemd
d058b5
%endif
d058b5
Requires:	kpatch >= 0.6.1-1
d058b5
Requires:	kernel-uname-r = %{kernel_ver_arch}
d058b5
d058b5
%if !%{empty_package}
d058b5
BuildRequires:	patchutils
d058b5
BuildRequires:	kernel-devel = %{kernel_ver}
d058b5
BuildRequires:	kernel-debuginfo = %{kernel_ver}
d058b5
d058b5
# kernel build requirements, generated from:
d058b5
#   % rpmspec -q --buildrequires kernel.spec | sort | awk '{print "BuildRequires:\t" $0}'
d058b5
# with arch-specific packages moved into conditional block
d058b5
BuildRequires:	asciidoc audit-libs-devel bash bc binutils binutils-devel bison bzip2 diffutils elfutils elfutils-devel findutils flex gawk gcc gettext git gzip hmaccalc hostname kmod m4 make ncurses-devel net-tools newt-devel numactl-devel openssl openssl-devel patch pciutils-devel perl-Carp perl-devel perl(ExtUtils::Embed) perl-generators perl-interpreter python3-devel python3-docutils redhat-rpm-config rpm-build sh-utils tar xmlto xz xz-devel zlib-devel java-devel kabi-dw
d058b5
d058b5
%ifarch x86_64
d058b5
BuildRequires:	pesign >= 0.10-4
d058b5
%endif
d058b5
d058b5
%ifarch ppc64le
d058b5
BuildRequires:	gcc-plugin-devel
d058b5
%endif
d058b5
d058b5
Source0:	https://github.com/dynup/kpatch/archive/v%{kpatch_ver}.tar.gz
d058b5
d058b5
Source10:	kernel-%{kernel_ver}.src.rpm
d058b5
d058b5
# kpatch-build patches
d058b5
Patch1: create-diff-object-ignore-altrinstr-aux-backport.patch
d058b5
d058b5
%global _dupsign_opts --keyname=rhelkpatch1
d058b5
d058b5
%define builddir	%{_builddir}/kpatch-%{kpatch_ver}
d058b5
%define kpatch		%{_sbindir}/kpatch
d058b5
%define kmoddir 	%{_usr}/lib/kpatch/%{kernel_ver_arch}
d058b5
%define kinstdir	%{_sharedstatedir}/kpatch/%{kernel_ver_arch}
d058b5
%define patchmodname	kpatch-%{sanitized_kernel_ver}-%{version}-%{sanitized_rpm_rel}
d058b5
%define patchmod	%{patchmodname}.ko
d058b5
d058b5
%define _missing_build_ids_terminate_build 1
d058b5
%define _find_debuginfo_opts -r
d058b5
%undefine _include_minidebuginfo
d058b5
%undefine _find_debuginfo_dwz_opts
d058b5
d058b5
%description
d058b5
This is a kernel live patch module which can be loaded by the kpatch
d058b5
command line utility to modify the code of a running kernel.  This patch
d058b5
module is targeted for kernel-%{kernel_ver}.
d058b5
d058b5
%prep
d058b5
%autosetup -n kpatch-%{kpatch_ver} -p1
d058b5
d058b5
%build
d058b5
kdevdir=/usr/src/kernels/%{kernel_ver_arch}
d058b5
vmlinux=/usr/lib/debug/lib/modules/%{kernel_ver_arch}/vmlinux
d058b5
d058b5
# kpatch-build
d058b5
make -C kpatch-build
d058b5
d058b5
# patch module
d058b5
for i in %{sources}; do
d058b5
	[[ $i == *.patch ]] && patch_sources="$patch_sources $i"
d058b5
done
d058b5
export CACHEDIR="%{builddir}/.kpatch"
d058b5
kpatch-build/kpatch-build -n %{patchmodname} -r %{SOURCE10} -v $vmlinux --skip-cleanup $patch_sources || { cat "${CACHEDIR}/build.log"; exit 1; }
d058b5
d058b5
d058b5
%install
d058b5
installdir=%{buildroot}/%{kmoddir}
d058b5
install -d $installdir
d058b5
install -m 755 %{builddir}/%{patchmod} $installdir
d058b5
d058b5
d058b5
%files
d058b5
%{_usr}/lib/kpatch
d058b5
d058b5
d058b5
%post
d058b5
%{kpatch} install -k %{kernel_ver_arch} %{kmoddir}/%{patchmod}
d058b5
chcon -t modules_object_t %{kinstdir}/%{patchmod}
d058b5
sync
d058b5
if [[ %{kernel_ver_arch} = $(uname -r) ]]; then
d058b5
	cver="%{rpm_ver}_%{rpm_rel}"
d058b5
	pname=$(echo "kpatch_%{sanitized_kernel_ver}" | sed 's/-/_/')
d058b5
d058b5
	lver=$({ %{kpatch} list | sed -nr "s/^${pname}_([0-9_]+)\ \[enabled\]$/\1/p"; echo "${cver}"; } | sort -V | tail -1)
d058b5
d058b5
	if [ "${lver}" != "${cver}" ]; then
d058b5
		echo "WARNING: at least one loaded kpatch-patch (${pname}_${lver}) has a newer version than the one being installed."
d058b5
		echo "WARNING: You will have to reboot to load a downgraded kpatch-patch"
d058b5
	else
d058b5
		%{kpatch} load %{patchmod}
d058b5
	fi
d058b5
fi
d058b5
exit 0
d058b5
d058b5
d058b5
%postun
d058b5
%{kpatch} uninstall -k %{kernel_ver_arch} %{patchmod}
d058b5
sync
d058b5
exit 0
d058b5
d058b5
%else
d058b5
%description
d058b5
This is an empty kpatch-patch package which does not contain any real patches.
d058b5
It is only a method to subscribe to the kpatch stream for kernel-%{kernel_ver}.
d058b5
d058b5
%files
d058b5
%doc
d058b5
%endif
d058b5
d058b5
%changelog
d058b5
* Thu Jul 23 2020 Joe Lawrence <joe.lawrence@redhat.com> [0-0.el8]
d058b5
- An empty patch to subscribe to kpatch stream for kernel-4.18.0-193.14.3.el8_2 [1859449]