Blame SPECS/kpatch-patch.spec

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