Blame SPECS/kpatch-patch.spec

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