Blame SPECS/kpatch-patch.spec

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