Blame SPECS/kpatch-patch.spec

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