Blame SPECS/kpatch-patch.spec

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