Blame SPECS/kpatch-patch.spec

c96eb4
# Set to 1 if building an empty subscription-only package.
c96eb4
%define empty_package		1
c96eb4
c96eb4
#######################################################
c96eb4
# Only need to update these variables and the changelog
c96eb4
%define kernel_ver	5.14.0-162.23.1.el9_1
c96eb4
%define kpatch_ver	0.9.7
c96eb4
%define rpm_ver		0
c96eb4
%define rpm_rel		0
c96eb4
c96eb4
%if !%{empty_package}
c96eb4
# Patch sources below. DO NOT REMOVE THIS LINE.
c96eb4
Source100:		XXX.patch
c96eb4
#Source101:		YYY.patch
c96eb4
# End of patch sources. DO NOT REMOVE THIS LINE.
c96eb4
%endif
c96eb4
c96eb4
%define sanitized_rpm_rel	%{lua: print((string.gsub(rpm.expand("%rpm_rel"), "%.", "_")))}
c96eb4
%define sanitized_kernel_ver   %{lua: print((string.gsub(string.gsub(rpm.expand("%kernel_ver"), '.el9_?\%d?', ""), "%.", "_")))}
c96eb4
%define kernel_ver_arch        %{kernel_ver}.%{_arch}
c96eb4
c96eb4
Name:		kpatch-patch-%{sanitized_kernel_ver}
c96eb4
Version:	%{rpm_ver}
c96eb4
Release:	%{rpm_rel}%{?dist}
c96eb4
c96eb4
%if %{empty_package}
c96eb4
Summary:	Initial empty kpatch-patch for kernel-%{kernel_ver_arch}
c96eb4
%else
c96eb4
Summary:	Live kernel patching module for kernel-%{kernel_ver_arch}
c96eb4
%endif
c96eb4
c96eb4
Group:		System Environment/Kernel
c96eb4
License:	GPLv2
c96eb4
ExclusiveArch:	x86_64 ppc64le
c96eb4
c96eb4
Conflicts:	%{name} < %{version}-%{release}
c96eb4
c96eb4
Provides:	kpatch-patch = %{kernel_ver_arch}
c96eb4
Provides:	kpatch-patch = %{kernel_ver}
c96eb4
c96eb4
%if !%{empty_package}
c96eb4
Requires:	systemd
c96eb4
%endif
c96eb4
Requires:	kpatch >= 0.6.1-1
c96eb4
Requires:	kernel-uname-r = %{kernel_ver_arch}
c96eb4
c96eb4
%if !%{empty_package}
c96eb4
BuildRequires:	patchutils
c96eb4
BuildRequires:	kernel-devel = %{kernel_ver}
c96eb4
BuildRequires:	kernel-debuginfo = %{kernel_ver}
c96eb4
c96eb4
# kernel build requirements, generated from:
c96eb4
#   % rpmspec -q --buildrequires kernel.spec | sort | awk '{print "BuildRequires:\t" $0}'
c96eb4
# with arch-specific packages moved into conditional block
c96eb4
BuildRequires:	bash
c96eb4
BuildRequires:	bc
c96eb4
BuildRequires:	binutils
c96eb4
BuildRequires:	bison
c96eb4
BuildRequires:	bpftool
c96eb4
BuildRequires:	bzip2
c96eb4
BuildRequires:	coreutils
c96eb4
BuildRequires:	diffutils
c96eb4
BuildRequires:	dwarves
c96eb4
BuildRequires:	elfutils
c96eb4
BuildRequires:	elfutils-devel
c96eb4
BuildRequires:	findutils
c96eb4
BuildRequires:	flex
c96eb4
BuildRequires:	gawk
c96eb4
BuildRequires:	gcc
c96eb4
BuildRequires:	gcc-c++
c96eb4
BuildRequires:	gcc-plugin-devel
c96eb4
BuildRequires:	git-core
c96eb4
BuildRequires:	glibc-static
c96eb4
BuildRequires:	gzip
c96eb4
BuildRequires:	hmaccalc
c96eb4
BuildRequires:	hostname
c96eb4
BuildRequires:	kernel-rpm-macros >= 185-9
c96eb4
BuildRequires:	kmod
c96eb4
BuildRequires:	m4
c96eb4
BuildRequires:	make
c96eb4
BuildRequires:	net-tools
c96eb4
BuildRequires:	nss-tools
c96eb4
BuildRequires:	openssl
c96eb4
BuildRequires:	openssl-devel
c96eb4
BuildRequires:	patch
c96eb4
BuildRequires:	perl-Carp
c96eb4
BuildRequires:	perl-devel
c96eb4
BuildRequires:	perl-generators
c96eb4
BuildRequires:	perl-interpreter
c96eb4
BuildRequires:	python3-devel
c96eb4
BuildRequires:	redhat-rpm-config
c96eb4
BuildRequires:	rpm-build
c96eb4
BuildRequires:	system-sb-certs
c96eb4
BuildRequires:	tar
c96eb4
BuildRequires:	which
c96eb4
BuildRequires:	xz
c96eb4
c96eb4
%ifarch x86_64
c96eb4
BuildRequires:	pesign >= 0.10-4
c96eb4
%endif
c96eb4
c96eb4
Source0:	https://github.com/dynup/kpatch/archive/v%{kpatch_ver}.tar.gz
c96eb4
c96eb4
Source10:	kernel-%{kernel_ver}.src.rpm
c96eb4
c96eb4
# kpatch-build patches
c96eb4
Patch1: v0.9.7-backport-MR-1314-create-diff-object-fix-__UNI.patch
c96eb4
Patch2: v0.9.7-backport-MR-1315-Static-call-fixes.patch
c96eb4
c96eb4
%global _dupsign_opts --keyname=rhelkpatch1
c96eb4
c96eb4
%define builddir	%{_builddir}/kpatch-%{kpatch_ver}
c96eb4
%define kpatch		%{_sbindir}/kpatch
c96eb4
%define kmoddir 	%{_usr}/lib/kpatch/%{kernel_ver_arch}
c96eb4
%define kinstdir	%{_sharedstatedir}/kpatch/%{kernel_ver_arch}
c96eb4
%define patchmodname	kpatch-%{sanitized_kernel_ver}-%{version}-%{sanitized_rpm_rel}
c96eb4
%define patchmod	%{patchmodname}.ko
c96eb4
c96eb4
%define _missing_build_ids_terminate_build 1
c96eb4
%define _find_debuginfo_opts -r
c96eb4
%undefine _include_minidebuginfo
c96eb4
%undefine _find_debuginfo_dwz_opts
c96eb4
c96eb4
%description
c96eb4
This is a kernel live patch module which can be loaded by the kpatch
c96eb4
command line utility to modify the code of a running kernel.  This patch
c96eb4
module is targeted for kernel-%{kernel_ver}.
c96eb4
c96eb4
%prep
c96eb4
%autosetup -n kpatch-%{kpatch_ver} -p1
c96eb4
c96eb4
%build
c96eb4
kdevdir=/usr/src/kernels/%{kernel_ver_arch}
c96eb4
vmlinux=/usr/lib/debug/lib/modules/%{kernel_ver_arch}/vmlinux
c96eb4
c96eb4
# kpatch-build
c96eb4
make -C kpatch-build
c96eb4
c96eb4
# patch module
c96eb4
for i in %{sources}; do
c96eb4
	[[ $i == *.patch ]] && patch_sources="$patch_sources $i"
c96eb4
done
c96eb4
export CACHEDIR="%{builddir}/.kpatch"
c96eb4
kpatch-build/kpatch-build -n %{patchmodname} -r %{SOURCE10} -v $vmlinux --skip-cleanup $patch_sources || { cat "${CACHEDIR}/build.log"; exit 1; }
c96eb4
c96eb4
c96eb4
%install
c96eb4
installdir=%{buildroot}/%{kmoddir}
c96eb4
install -d $installdir
c96eb4
install -m 755 %{builddir}/%{patchmod} $installdir
c96eb4
c96eb4
c96eb4
%files
c96eb4
%{_usr}/lib/kpatch
c96eb4
c96eb4
c96eb4
%post
c96eb4
%{kpatch} install -k %{kernel_ver_arch} %{kmoddir}/%{patchmod}
c96eb4
chcon -t modules_object_t %{kinstdir}/%{patchmod}
c96eb4
sync
c96eb4
if [[ %{kernel_ver_arch} = $(uname -r) && "${LEAPP_IPU_IN_PROGRESS}" != "8to9" ]]; then
c96eb4
	cver="%{rpm_ver}_%{rpm_rel}"
c96eb4
	pname=$(echo "kpatch_%{sanitized_kernel_ver}" | sed 's/-/_/')
c96eb4
c96eb4
	lver=$({ %{kpatch} list | sed -nr "s/^${pname}_([0-9_]+)\ \[enabled\]$/\1/p"; echo "${cver}"; } | sort -V | tail -1)
c96eb4
c96eb4
	if [ "${lver}" != "${cver}" ]; then
c96eb4
		echo "WARNING: at least one loaded kpatch-patch (${pname}_${lver}) has a newer version than the one being installed."
c96eb4
		echo "WARNING: You will have to reboot to load a downgraded kpatch-patch"
c96eb4
	else
c96eb4
		%{kpatch} load %{patchmod}
c96eb4
	fi
c96eb4
fi
c96eb4
exit 0
c96eb4
c96eb4
c96eb4
%postun
c96eb4
%{kpatch} uninstall -k %{kernel_ver_arch} %{patchmod}
c96eb4
sync
c96eb4
exit 0
c96eb4
c96eb4
%else
c96eb4
%description
c96eb4
This is an empty kpatch-patch package which does not contain any real patches.
c96eb4
It is only a method to subscribe to the kpatch stream for kernel-%{kernel_ver}.
c96eb4
c96eb4
%files
c96eb4
%doc
c96eb4
%endif
c96eb4
c96eb4
%changelog
c96eb4
* Fri Mar 24 2023 Yannick Cote <ycote@redhat.com> [0-0.el9]
c96eb4
- An empty patch to subscribe to kpatch stream for kernel-5.14.0-162.23.1.el9_1 [2181596]