Blame SPECS/kpatch-patch.spec

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