%global debug_package   %{nil}

Name:           deepin-system-monitor
Version:        5.9.31

Release:        2
Summary:        A more user-friendly system monitor
License:        GPLv3
URL:            https://github.com/linuxdeepin/deepin-system-monitor
Source0:        %{name}-%{version}.tar.gz
Patch0:         0001-procps-ng-update-4.0.0.patch
Patch1:         0002-Remove-all-symbol-table-and-relocation-information-f.patch
Patch2:         0003-feat-add-build-option-to-disable-wayland-support.patch
Patch3:         0001-fix-build-error.patch

BuildRequires:  qt5-devel
BuildRequires:  cmake

BuildRequires:  dtkwidget-devel
BuildRequires:  dtkcore-devel
BuildRequires:  pkgconfig(dtkgui)

BuildRequires:  procps-ng-devel
BuildRequires:  pkgconfig(xcb)
BuildRequires:  pkgconfig(xcb-util)
BuildRequires:  pkgconfig(x11)
BuildRequires:  pkgconfig(xext)
BuildRequires:  pkgconfig(xtst)
BuildRequires:  xcb-util-wm-devel
# BuildRequires:  pkgconfig(Qt5DBus)
# BuildRequires:  pkgconfig(Qt5Gui)
# BuildRequires:  pkgconfig(Qt5Network)
# BuildRequires:  pkgconfig(Qt5Widgets)
# BuildRequires:  pkgconfig(Qt5X11Extras)
# BuildRequires:  qt5-linguist
BuildRequires:  libpcap-devel
BuildRequires:  libcap-devel
# BuildRequires:  ncurses-devel
BuildRequires:  desktop-file-utils
BuildRequires:  libappstream-glib
BuildRequires:  deepin-gettext-tools
BuildRequires:  qt5-qtbase-private-devel
# BuildRequires:  qt5-qtmultimedia-devel
# BuildRequires:  dtkcore-devel >= 5.1
BuildRequires:  libicu-devel
BuildRequires:  libnl3-devel
BuildRequires:  systemd-devel
BuildRequires:  dde-qt-dbus-factory-devel
BuildRequires:  gsettings-qt-devel
BuildRequires:  kf5-kwayland-devel
BuildRequires:  dde-dock-devel
BuildRequires:  wayland-devel
# BuildRequires:  pkgconfig(libnl-route-3)
#Requires:       hicolor-icon-theme
Recommends:     deepin-manual

%description
%{summary}.

%prep
%autosetup -p1

sed -i 's:/usr/lib/:%{_libdir}/:' deepin-system-monitor-plugin/CMakeLists.txt
sed -i 's:/usr/lib/x86_64-linux-gnu/qt5/bin/:%{_qt5_bindir}/:' \
    deepin-system-monitor-daemon/translations/translate_generation.sh \
    deepin-system-monitor-plugin/translations/translate_generation.sh


%build
sed -i "s|^cmake_minimum_required.*|cmake_minimum_required(VERSION 3.0)|" $(find . -name "CMakeLists.txt")
%cmake  \
    -DCMAKE_BUILD_TYPE=Release  \
    -DUSE_DEEPIN_WAYLAND=OFF

%make_build

%install
%make_install INSTALL_ROOT="%buildroot"

# %check
# desktop-file-validate %{buildroot}%{_datadir}/applications/%{name}.desktop ||:
#appstream-util validate-relax --nonet %{buildroot}%{_datadir}/appdata/*.appdata.xml

%post
if command -v setcap > /dev/null; then
	if setcap cap_net_raw,cap_dac_read_search,cap_sys_ptrace+ep /usr/bin/deepin-system-monitor;then
		chmod u-s /usr/bin/deepin-system-monitor
	else
		echo "Setcap failed, falling back to setuid"
		chmod u+s /usr/bin/deepin-system-monitor
	fi
else
	echo "Setcap is not installed, falling back to setuid"
	chmod u+s /usr/bin/deepin-system-monitor
fi 

%files
%doc README.md
%license LICENSE
%caps(cap_kill,cap_net_raw,cap_dac_read_search,cap_sys_ptrace=+ep) %{_bindir}/%{name}
%{_bindir}/%{name} 
%{_datadir}/applications/%{name}.desktop
#%%{_datadir}/icons/hicolor/scalable/apps/%{name}.svg
%{_datadir}/%{name}/translations/*.qm
%{_datadir}/polkit-1/actions/com.deepin.pkexec.deepin-system-monitor.policy
%{_datadir}/deepin-manual/manual-assets/application/deepin-system-monitor/system-monitor/*
%{_datadir}/glib-2.0/schemas/
%{_libdir}/dde-dock/plugins/libdeepin-system-monitor-plugin.so
%{_datadir}/%{name}-plugin/
%{_bindir}/%{name}-plugin-popup
%{_datadir}/dbus-1/services/
%{_datadir}/%{name}-plugin-popup/
%{_bindir}/%{name}-daemon
%{_sysconfdir}/xdg/autostart
%{_datadir}/%{name}-daemon/


%changelog
* Fri Apr 12 2024 liuzhilin <liuzhilin@uniontech.com> - 5.9.31-2
- fix-build-error

* Mon Jul 24 2023 leeffo <liweiganga@uniontech.com> - 5.9.31-1
- upgrade to version 5.9.31

* Mon Apr 10 2023 liweiganga <liweiganga@uniontech.com> - 5.8.28-1
- update: update to 5.8.28

* Thu Apr 06 2023 yangxianzhao <yangxianzhao@uniontech.com> - 5.8.11-6
- Fix incomplete display of the system monitor when the resolution is 1020 * 768

* Wed Mar 15 2023 liweiganga <liweiganga@uniontech.com> - 5.8.11-5
- feat: fix strip

* Fri Feb 10 2023 liweiganga <liweiganga@uniontech.com> - 5.8.11-4
- feat: update changes due to procps-ng upgrade

* Wed Dec 21 2022 liweigang <liweiganga@uniontech.com> - 5.8.11-3
- enable debuginfo for fix strip

* Fri Nov 11 2022 liweigang <liweiganga@uniontech.com> - 5.8.11-2
- feat: procps-ng update 4.0.0

* Tue Jul 19 2022 konglidong <konglidong@uniontech.com> - 5.8.11-1
- update to 5.8.11

* Tue Feb 08 2022 liweigang <liweiganga@uniontech.com> - 5.6.11.13-3
- fix build error

* Thu Jul 29 2021 weidong <weidong@uniontech.com> - 5.6.11.13-2
- Fix gcc10.3 compilation deepin-system-monitor failed 

* Wed Jul 07 2021 weidong <weidong@uniontech.com> - 5.6.11.13-1
- Update to 5.6.11.13

* Thu Jul 30 2020 openEuler Buildteam <buildteam@openeuler.org> - 5.6.1-1
- Package init
