Blame SPECS/kpatch-patch.spec

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