Blame SPECS/kpatch-patch.spec

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