Fix kpatch.spec

Prior to this commit, the kpatch.spec was not building because of #1042.
The kernel module is not built by default, but the spec was not updated accordingly.

With this commit, the kpatch.spec supports building the module or not using a %bcond.
Like the Makefile, it does not build the module by default.
This commit is contained in:
Romain Fihue 2020-05-05 09:29:31 +02:00
parent b99e2781ac
commit 205bc73fc9
1 changed files with 16 additions and 5 deletions

View File

@ -1,3 +1,9 @@
# needed for the kernel specific module
%define KVER %(uname -r)
# Don't build kpatch kernel module by default
%bcond_with kpatch_mod
Name: kpatch
Summary: Dynamic kernel patching
Version: 0.9.1
@ -9,11 +15,12 @@ Source0: %{name}-%{version}.tar.gz
Requires: kmod bash
BuildRequires: gcc kernel-devel elfutils elfutils-devel
%if %{with kpatch_mod}
BuildRequires: kernel-devel-uname-r = %{KVER}
BuildRequires: kernel-uname-r = %{KVER}
%endif
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
# needed for the kernel specific module
%define KVER %(uname -r)
%description
kpatch is a Linux dynamic kernel patching tool which allows you to patch a
running kernel without rebooting or restarting any processes. It enables
@ -47,6 +54,7 @@ having to wait for long-running tasks to complete, users to log off, or
for scheduled reboot windows. It gives more control over up-time without
sacrificing security or stability.
%if %{with kpatch_mod}
%package %{KVER}
Requires: %{name}
Summary: Dynamic kernel patching
@ -58,17 +66,18 @@ having to wait for long-running tasks to complete, users to log off, or
for scheduled reboot windows. It gives more control over up-time without
sacrificing security or stability.
%endif
%prep
%setup -q
%build
make %{_smp_mflags}
make %{_smp_mflags} %{?with_kpatch_mod: BUILDMOD=yes KPATCH_BUILD=/lib/modules/%{KVER}/build}
%install
rm -rf %{buildroot}
make install PREFIX=/%{_usr} DESTDIR=%{buildroot}
make install PREFIX=/%{_usr} DESTDIR=%{buildroot} %{?with_kpatch_mod: BUILDMOD=yes KPATCH_BUILD=/lib/modules/%{KVER}/build}
%clean
rm -rf %{buildroot}
@ -81,9 +90,11 @@ rm -rf %{buildroot}
%{_usr}/lib/systemd/system/*
%{_sysconfdir}/init/kpatch.conf
%if %{with kpatch_mod}
%files %{KVER}
%defattr(-,root,root,-)
%{_usr}/lib/kpatch/%{KVER}
%endif
%files build
%defattr(-,root,root,-)