File sysstat.spec of Package sysstat.39223

#
# spec file for package sysstat
#
# Copyright (c) 2024 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:           sysstat
Version:        12.0.2
Release:        0
Summary:        Sar and Iostat Commands for Linux
License:        GPL-2.0-or-later
Group:          System/Monitoring
URL:            https://github.com/sysstat/sysstat
Source:         https://github.com/sysstat/sysstat/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.xz
Source1:        isag.desktop
Source2:        sysstat.service
Source3:        90-sysstat.preset
# PATCH-FIX-OPENSUSE should be upstreamed
# add locking to scripts sa1 and sa2 (bnc#7861)
Patch0:         sysstat-8.1.6-sa1sa2lock.diff
# PATCH-FIX-OPENSUSE should be upstreamed
# use getpagesize() instead of kb_shift for hugetable archs
Patch2:         sysstat-8.0.4-pagesize.diff
# PATCH-FIX-UPSTREAM CVE-2018-19416 CVE-2018-19517 bsc#1117001 bsc#1117260
Patch3:         sysstat-12.0.2-CVE-2018-19416-and-CVE-2018-19517.patch
# PATCH-FIX-UPSTREAM bsc#1138767 L3: fix scaling issue with mtab symlinks and automounter
Patch4:         sysstat-mtab-symlinks-and-automounter.patch
# PATCH-FIX-UPSTREAM bsc#1150114 CVE-2019-16167 sysstat-CVE-2019-16167.patch
Patch5:         sysstat-CVE-2019-16167.patch
# PATCH-FIX-UPSTREAM CVE-2019-19725 bsc#159104 double free in check_file_actlst
Patch6:         sysstat-CVE-2019-19725.patch
# PATCH-FIX-OPENSUSE bsc#1174227 Workaround for iowait being decremented
Patch7:         sysstat-iowait-decr.patch
# PATCH-FIX-UPSTREAM bsc#1177747 Fix iostat -y switch results
Patch8:         sysstat-12.1.6-iostat-y-option.diff
# fix possible segfault in read_task_stats bsc#1194679
Patch9:         sysstat-fix-segfault-in-read_task_stats.patch
# PATCH-FIX-UPSTREAM
Patch10:        sysstat-CVE-2022-39377.patch
# PATCH-FIX-UPSTREAM
Patch11:        sysstat-CVE-2023-33204.patch
# PATCH-FIX-OPENSUSE PED#12914 find command option -H to be added in /usr/lib64/sa/sa2
Patch12:        sysstat-PED-12914.patch
BuildRequires:  findutils
BuildRequires:  gettext-runtime
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(systemd)
BuildRequires:  sed
BuildRequires:  systemd-rpm-macros
BuildRequires:  update-desktop-files
Requires:       procmail
Requires:       xz

%{?systemd_ordering}
%ifnarch s390 s390x
BuildRequires:  libsensors4-devel
%endif

%description
Sar and Iostat commands for Linux. The sar command collects and reports
system activity information. The iostat command reports CPU statistics
and I/O statistics for TTY devices and disks.  The information
collected by sar and iostat can be saved in a binary file for future
inspection. Both commands now support SMP machines when displaying CPU
utilization.

%package isag
Summary:        Interactive System Activity Grapher for sysstat
Group:          System/Monitoring
Requires:       gnuplot
Requires:       sysstat = %{version}
Requires:       tk

%description isag
This package includes the isag command, which graphically displays the
system activity data stored in a binary data produced by a sar command
from a sysstat package.

%prep
%autosetup -p1
cp %{SOURCE1} .
# remove date and time from objects
find ./ -name \*.c -exec sed -i -e 's: " compiled " __DATE__ " " __TIME__::g' {} \;

%build
export conf_dir="%{_sysconfdir}/sysstat"
export sa_lib_dir="%{_libdir}/sa"
export cron_owner=root
export LFLAGS="-L. -lsyscom"
export history="60"
export SADC_OPT="-S ALL"
%configure \
    --enable-install-cron \
    --disable-silent-rules \
    --enable-nls \
    --disable-man-group \
    --enable-copy-only \
    --disable-file-attr \
    --enable-debug-info \
%ifnarch s390 s390x
    --enable-sensors \
%endif
    --disable-stripping
make %{?_smp_mflags}

%install
mkdir -p %{buildroot}%{_localstatedir}/log/sa %{buildroot}%{_sbindir}
%make_install
install -D -m 0644 isag.desktop %{buildroot}%{_datadir}/applications/isag.desktop
install -D -m 0644 %{SOURCE3} %{buildroot}%{_presetdir}/90-sysstat.preset
%suse_update_desktop_file isag
cp contrib/isag/isag %{buildroot}%{_bindir}
cp contrib/isag/isag.1 %{buildroot}%{_mandir}/man1
rm -rf %{buildroot}%{_datadir}/doc/sysstat*
ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rcsysstat
%find_lang %{name}

%check
# Newer versions only have simulation tests
# make %%{?_smp_mflags} test

%pre
%service_add_pre sysstat.service sysstat-collect.service sysstat-collect.timer sysstat-summary.service sysstat-summary.timer

%post
%service_add_post sysstat.service sysstat-collect.service sysstat-collect.timer sysstat-summary.service sysstat-summary.timer
# Earlier versions used cron, remove leftover
rm -f /etc/cron.d/sysstat || :

%preun
%service_del_preun sysstat.service sysstat-collect.service sysstat-collect.timer sysstat-summary.service sysstat-summary.timer
[ "$1" -gt 0 ] || rm -rf %{_localstatedir}/log/sa/*

%postun
%if 0%{?suse_version} < 1500
%post isag
%desktop_database_post

%postun isag
%desktop_database_postun
%endif
%service_del_postun sysstat.service sysstat-collect.service sysstat-collect.timer sysstat-summary.service sysstat-summary.timer

%posttrans
if [ -x /bin/systemctl ] && systemctl --quiet is-system-running; then
    for timer in sysstat-collect.timer sysstat-summary.timer; do
        # Only apply preset if the unit is known to systemd
        # avoid errors if missing for some reason
        if systemctl list-unit-files | grep -q "^$timer"; then
            echo "Applying preset for $timer"
            systemctl preset --preset-mode=enable-only "$timer" || :
        fi
    done
fi

%files -f "%{name}.lang"
%license COPYING
%doc CHANGES CREDITS FAQ.md README.md
%{_mandir}/man1/*
%{_mandir}/man5/*
%{_mandir}/man8/*
%exclude %{_mandir}/man1/isag*
%dir %{_sysconfdir}/sysstat
%config(noreplace) %{_sysconfdir}/sysstat/sysstat
%attr(644,root,root) %config(noreplace) %{_sysconfdir}/sysstat/sysstat.ioconf
%{_bindir}/cifsiostat
%{_bindir}/iostat
%{_bindir}/mpstat
%{_bindir}/pidstat
%{_bindir}/sadf
%{_bindir}/sar
%{_bindir}/tapestat
%exclude %{_bindir}/isag
%{_libdir}/sa
%{_unitdir}/sysstat.service
%{_unitdir}/sysstat-collect.service
%{_unitdir}/sysstat-collect.timer
%{_unitdir}/sysstat-summary.service
%{_unitdir}/sysstat-summary.timer
%{_presetdir}/90-sysstat.preset
%dir %{_localstatedir}/log/sa
%{_sbindir}/rcsysstat

%files isag
%doc contrib/isag/README-isag
%{_mandir}/man1/isag*
%{_bindir}/isag
%{_datadir}/applications/isag.desktop

%changelog
openSUSE Build Service is sponsored by