Blame SPECS/kpatch-patch.spec

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