File atop.spec of Package atop

%define realname atop
%define realver  2.9.0
%define srcext   tar.gz

# turn off the generation of debuginfo rpm  (RH9) ??
%global debug_package %{nil}

# Common info
Name:          %{realname}
Version:       %{realver}
Release:       %{?extraver:0.}1%{?dist}
License:       GPL-2.0
Group:         System/Monitoring
URL:           http://www.atoptool.nl/
Summary:       Advanced System and Process Monitor

# Packages needed to define _unitdir
%if 0%{?suse_version} >= 1230
BuildRequires: systemd-rpm-macros
Requires:      systemd
%endif
%if 0%{?rhel} >= 7
BuildRequires: systemd
Requires:      systemd
%endif

# Install-time parameters
Requires:      logrotate

# Build-time parameters
BuildRequires: ncurses-devel
BuildRequires: zlib-devel
%if 0%{?suse_version}
BuildRequires: -post-build-checks
BuildRequires: fdupes
%endif
BuildRoot:     %{_tmppath}/%{name}-root
Source:        http://www.atoptool.nl/download/%{realname}-%{realver}%{?extraver}.%{srcext}

%description
Atop is an ASCII full-screen performance monitor for Linux that is capable of
reporting the activity of all processes (even if processes have finished during
the interval), daily logging of system and process activity for long-term
analysis, highlighting overloaded system resources by using colors, etc. At
regular intervals, it shows system-level activity related to the CPU, memory,
swap, disks (including LVM) and network layers, and for every process (and
thread) it shows e.g. the CPU utilization, memory growth, disk utilization,
priority, username, state, and exit code.

In combination with the optional kernel module netatop, it even shows network
activity per process/thread.

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{realver}%{?extraver}
%{__sed} -ri '/chmod|chown/ d' Makefile

%build
%{__make} %{?_smp_mflags} \
 CFLAGS="%{optflags} %{?gcc_lto}" \
 CXXFLAGS="%{optflags} %{?gcc_lto}" \
 LDFLAGS="-Wl,--as-needed -Wl,--strip-all %{?gcc_lto} %{!?sles_version:-ltinfo}"

%install
%if 0%{?_unitdir:1}
%{__make} install DESTDIR=%{buildroot} SYSDPATH=%{?_unitdir}
%else
%{__make} sysvinstall DESTDIR=%{buildroot}
%endif
%if ! 0%{?_unitdir:1}
%if "%{expand:%_vendor}" == "suse"
%{__ln_s} %{_initrddir}/atop     %{buildroot}%{_sbindir}/rcatop
%{__ln_s} %{_initrddir}/atopacct %{buildroot}%{_sbindir}/rcatopacct
%endif
%endif
%if 0%{?suse_version}
%fdupes %{buildroot}%{_bindir}
%endif

%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}

%files
%defattr(-,root,root)
%license COPYING
%doc AUTHORS README
%{_sysconfdir}/default/atop
%{_bindir}/*
%{_sbindir}/*
%if 0%{?_unitdir:1}
%{_unitdir}/*
%dir /usr/lib/systemd/system-sleep
/usr/lib/systemd/system-sleep/atop-pm.sh
%else
/etc/init.d/atop
/etc/init.d/atopacct
%endif
%doc %{_mandir}/man1/*
%doc %{_mandir}/man5/*
%doc %{_mandir}/man8/*

%changelog
openSUSE Build Service is sponsored by