Blame SPECS/kpatch-patch.spec

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