Blame SPECS/kpatch-patch.spec

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