Blame SPECS/kpatch-patch.spec

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