Blame SPECS/kpatch-patch.spec

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