## START: Set by rpmautospec
## (rpmautospec version 0.6.3)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 2;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

%bcond_without tests

%global appstream_id io.github.syllo.nvtop

Name:           nvtop
Version:        3.1.0
Release:        %autorelease
Summary:        GPU process monitoring for various devices

# BSD-3-Clause: include/ini.h, src/ini.c
# LGPL-2.1-or-later: include/list.h - this combines into GPL-3.0-or-later
# some cmake modules are BSD-3-Clause or MIT but those are not shipped out
License:        GPL-3.0-or-later and BSD-3-Clause
URL:            https://github.com/Syllo/nvtop
Source:         %{url}/archive/%{version}/%{name}-%{version}.tar.gz
# these might be upstreamable
Patch0:         %{name}-fix-icon-path.diff
Patch1:         %{name}-fix-appstream-path.diff
# these can be upstreamed
# https://github.com/Syllo/nvtop/pull/278
Patch2:         %{name}-fix-icon-in-appstream.diff
# https://github.com/Syllo/nvtop/pull/279
Patch3:         %{name}-fix-screenshot-urls-in-appstream.diff
Patch4:         %{name}-fix-linking.patch

BuildRequires:  cmake >= 3.10
BuildRequires:  desktop-file-utils
BuildRequires:  libappstream-glib
BuildRequires:  gcc-c++
BuildRequires:  pkgconfig(libdrm)
BuildRequires:  pkgconfig(libsystemd)
BuildRequires:  pkgconfig(ncursesw)
%if %{with tests}
%if 0%{?el8}
# EL8 gtest doesn't ship pkgconfig
BuildRequires:  gtest-devel
%else
BuildRequires:  pkgconfig(gtest)
%endif
%endif
Requires:       hicolor-icon-theme

%description
Nvtop stands for Neat Videocard TOP, a (h)top like task monitor for various GPUs
including AMD, Apple, Huawei, Intel, NVIDIA and Qualcomm. It can handle multiple
GPUs and print information about them in a htop familiar way.


%prep
%autosetup -p1


%build
%if %{with tests}
%cmake -DBUILD_TESTING=ON
%else
%cmake
%endif
%cmake_build


%install
%cmake_install


%check
desktop-file-validate %{buildroot}/%{_datadir}/applications/%{name}.desktop
appstream-util validate-relax --nonet %{buildroot}%{_metainfodir}/%{appstream_id}.metainfo.xml
%if %{with tests}
%ctest
%endif


%files
%license COPYING
%doc README.markdown
%{_bindir}/%{name}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/scalable/apps/%{name}.svg
%{_mandir}/man1/%{name}.1*
%{_metainfodir}/%{appstream_id}.metainfo.xml


%changelog
## START: Generated by rpmautospec
* Wed Apr 24 2024 Peter Robinson <pbrobinson@gmail.com> - 3.1.0-2
- add patch to fix linking

* Wed Apr 24 2024 Peter Robinson <pbrobinson@gmail.com> - 3.1.0-1
- Update to 3.1.0, tweak description

* Thu Jan 25 2024 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.2-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Sun Jan 21 2024 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Mon Jun 26 2023 Michel Alexandre Salim <salimma@fedoraproject.org> - 3.0.2-1
- Update to 3.0.2 (closes: rhbz#2214065)

* Thu Feb 09 2023 Michel Alexandre Salim <salimma@fedoraproject.org> - 3.0.1-1
- Update to 3.0.1

* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Thu Nov 03 2022 Michel Alexandre Salim <salimma@fedoraproject.org> - 3.0.0-1
- Initial Fedora package
## END: Generated by rpmautospec