File kvm_stat.spec of Package kvm_stat
#
# spec file for package kvm_stat
#
# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
Name: kvm_stat
%define version %(rpm -q --qf '%%{VERSION}' kernel-source)
Version: %{version}
Release: 0
Summary: Monitoring Tool for KVM guests
License: GPL-2.0-only
Group: System/Monitoring
URL: http://www.kernel.org/
BuildArch: noarch
BuildRequires: asciidoc
BuildRequires: kernel-source >= 5.2.0
BuildRequires: libxslt-tools
Requires: python3-curses
Recommends: logrotate
Recommends: kernel >= 5.2.0
Conflicts: qemu < 2.6.90
Conflicts: qemu-kvm < 2.6.90
BuildRoot: %{_tmppath}/%{name}-%{version}-build
# Patches 01 to 07 are for jsc#SLE-13784
Source1: logrotate.kvm_stat
Patch01: rework-command-line-sequence.patch
Patch02: switch-to-argparse.patch
Patch03: add-command-line-switch-s-to-update.patch
Patch04: add-command-line-switch-c-to-csv.patch
Patch05: add-command-line-switch-z-skip-zero-records.patch
Patch06: add-command-line-switch-L-to-log-file.patch
Patch07: add-sample-systemd-unit.patch
%define XXX This package provides a userspace tool "kvm_stat", which displays KVM vm exit \
information as a means of monitoring vm behavior. The data is taken from the\
KVM debugfs files or the vm tracepoints and outputs them as a curses ui or\
simple text.
%description
%{XXX}
%prep
# copy necessary files from kernel-source
(tar -C /usr/src/linux -c COPYING tools scripts) | tar -x
# Patches present upstream, since 5.7
%if "%(echo `echo -e "%{version}\\n5.7.0" | sort -V | head -n1 2> /dev/null`)" != "5.7.0"
%patch01 -p1
%patch02 -p1
%patch03 -p1
%patch04 -p1
%endif
# Patches present upstream, since 5.8
%if "%(echo `echo -e "%{version}\\n5.8.0" | sort -V | head -n1 2> /dev/null`)" != "5.8.0"
%patch05 -p1
%patch06 -p1
%patch07 -p1
%endif
%build
make -C tools/kvm/kvm_stat %{?_smp_mflags}
%install
# OBS checks don't like /usr/bin/env in script interpreter lines
sed -re '1 { s_^#! */usr/bin/env +/_#!/_ ; s_^#! */usr/bin/env +([^/])_#!/usr/bin/\1_ }' -i "tools/kvm/kvm_stat/kvm_stat"
make -C tools kvm_stat_install INSTALL_ROOT=%{buildroot}
install -D -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/kvm_stat
install -D -m 644 tools/kvm/kvm_stat/kvm_stat.service %{buildroot}%{_unitdir}/kvm_stat.service
install -d %{buildroot}%{_sbindir}
ln -sf service %{buildroot}%{_sbindir}/rckvm_stat
%pre
%service_add_pre kvm_stat.service
%post
%service_add_post kvm_stat.service
%preun
%service_del_preun kvm_stat.service
%postun
%service_del_postun kvm_stat.service
%files
%defattr(-, root, root)
%license COPYING
%{_unitdir}/kvm_stat.service
%config(noreplace) %{_sysconfdir}/logrotate.d/kvm_stat
%{_sbindir}/rckvm_stat
%{_bindir}/kvm_stat
%{_mandir}/man1/kvm_stat*
%changelog