Blame SPECS/kpatch-patch.spec

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