Blame SPECS/kpatch-patch.spec

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