File mission-center.spec of Package mission-center

#
# spec file for package mission-center
#
# Copyright (c) 2025 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/

%define _lto_cflags %{nil}
%define nvtop_ver 339ee0b10a64ec51f43d27357b0068a40f16e9e4
%define nvtop_dir subprojects/magpie/platform-linux/3rdparty/nvtop


Name:           mission-center
Version:        1.0.x
Release:        0
Summary:        Monitor your CPU, Memory, Disk, Network and GPU usage
License:        GPL-3.0-or-later
URL:            https://gitlab.com/mission-center-devs/mission-center
Source0:        %{name}-%{version}.tar.xz
# cd mission-center
# cargo vendor -s subprojects/magpie/Cargo.toml -s subprojects/magpie/platform-linux/Cargo.toml
Source1:        vendor.tar.xz
# https://github.com/Syllo/nvtop/archive/339ee0b10a64ec51f43d27357b0068a40f16e9e4.tar.gz
Source2:        nvtop-%nvtop_ver.tar.gz 
Provides:       bundled(mission-center-magpie)
Provides:       bundled(nvtop) = 3.2.0
BuildRequires:  meson >= 0.63
BuildRequires:  cargo
BuildRequires:  cmake
BuildRequires:  gcc
BuildRequires:  gcc-c++
BuildRequires:  pkgconfig(protobuf)
BuildRequires:  pkgconfig(python3)
BuildRequires:  python3-sqlite3
BuildRequires:  pkgconfig(libdrm)
BuildRequires:  pkgconfig(gbm)
BuildRequires:  pkgconfig(libudev)
BuildRequires:  pkgconfig(gtk4)
BuildRequires:  pkgconfig(egl)
BuildRequires:  libadwaita-devel
BuildRequires:  desktop-file-utils
BuildRequires:  blueprint-compiler
BuildRequires:  cargo-packaging
BuildRequires:  gettext
BuildRequires:  desktop-file-utils
BuildRequires:  libappstream-glib8
BuildRequires:  libxml2-tools
BuildRequires:  patch
Recommends:     nethogs

%description
Monitor your CPU, Memory, Disk, Network and GPU usage

%prep
%autosetup -p1 -n %{name}-%{version}

# Enable vendored sources/deps
mkdir .cargo
cat <<EOF>>.cargo/config
[source.crates-io]
replace-with = "vendored-sources"

[source.vendored-sources]
directory = "vendor"
EOF

# vendor
tar xJf %{SOURCE1}
# nvtop
tar xzf %{SOURCE2}
pushd nvtop-%nvtop_ver
for p in ../%nvtop_dir/patches/*.patch
do
  patch -p1 < $p
done
popd

mkdir -p x86_64-suse-linux/subprojects/magpie/src/debug/build/native/
mv nvtop-%nvtop_ver x86_64-suse-linux/subprojects/magpie/src/debug/build/native/

%build
export CARGO_NET_OFFLINE=true
%meson
%meson_build

%install
%meson_install
%find_lang missioncenter

%check
desktop-file-validate %{buildroot}/%{_datadir}/applications/io.missioncenter.MissionCenter.desktop
%meson_test

# https://gitlab.com/mission-center-devs/mission-center/-/wikis/Home/Nethogs
%post
if  command -v nethogs 2>&1 >/dev/null
then
     setcap "cap_net_admin,cap_net_raw,cap_dac_read_search,cap_sys_ptrace+pe" "$(which nethogs)"
fi


%files -f missioncenter.lang
%doc README.md
%license COPYING
%{_datadir}/missioncenter/
%{_datadir}/applications/io.missioncenter.MissionCenter.desktop
%{_datadir}/metainfo/io.missioncenter.MissionCenter.metainfo.xml
%{_datadir}/glib-2.0/schemas/io.missioncenter.MissionCenter.gschema.xml
%{_datadir}/icons/hicolor/scalable/apps/io.missioncenter.MissionCenter.svg
%{_datadir}/icons/hicolor/symbolic/apps/io.missioncenter.MissionCenter-symbolic.svg
%{_bindir}/missioncenter-magpie
%{_bindir}/missioncenter


%changelog
openSUSE Build Service is sponsored by