Blame SPECS/kpatch-patch.spec

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