File rqbit.spec of Package rqbit

#
# spec file for package rqbit
#
# 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/
#


%bcond_without check
Name:           rqbit
Version:        8.1.1
Release:        0
Summary:        A BitTorrent client in Rust
License:        Apache-2.0
Group:          Productivity/Networking/File-Sharing
URL:            https://github.com/ikatson/rqbit
Source0:        %{url}/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        vendor.tar.zst
Source2:        desktop-node_modules.tar.xz
Source3:        webui-node_modules.tar.xz
BuildRequires:  cargo >= 1.81.0
BuildRequires:  cargo-packaging
#uildRequires:  cargo-tauri
BuildRequires:  pkgconfig(openssl)
BuildRequires:  pkgconfig(gtk+-3.0)
BuildRequires:  pkgconfig(libsoup-3.0)
BuildRequires:  pkgconfig(webkit2gtk-4.1)
BuildRequires:  nodejs-common
BuildRequires:  npm-default
BuildRequires:  python3
ExclusiveArch:  %{rust_arches}

%description
rqbit is a bittorrent client written in Rust. Has HTTP API and Web UI, and
can be used as a library.

%package        desktop
Summary:        A bittorrent client in Rust (desktop app)
Group:          Productivity/Networking/File-Sharing
Requires:       hicolor-icon-theme

%description    desktop
rqbit is a bittorrent client written in Rust. Has HTTP API and Web UI, and
can be used as a library.

%package        bash-completion
Summary:        Bash completion for %{name}
Group:          System/Shells
Requires:       bash-completion
Supplements:    (%{name} and bash)
BuildArch:      noarch

%description    bash-completion
Bash command line completion support for %{name}.

%package        fish-completion
Summary:        Fish Completion for %{name}
Group:          System/Shells
Requires:       fish
Supplements:    (%{name} and fish)
BuildArch:      noarch

%description    fish-completion
Fish command line completion support for %{name}.

%package        zsh-completion
Summary:        Zsh Completion for %{name}
Group:          System/Shells
Requires:       zsh
Supplements:    (%{name} and zsh)
BuildArch:      noarch

%description    zsh-completion
ZSH command line completion support for %{name}.

%prep
%autosetup -p1 -a1
tar xf %{SOURCE2}
tar xf %{SOURCE3}

%build
%{cargo_build} --all
for shell in bash fish zsh ; do
    RUST_LOG=off target/release/%{name} completions $shell > %{name}.$shell
done

%install
#%%{cargo_install}
install -Dm 0755 target/release/%{name} target/release/%{name}-desktop -t %{buildroot}%{_bindir}/
install -Dm 0644 %{name}.bash %{buildroot}%{_datadir}/bash-completion/completions/%{name}
install -Dm 0644 %{name}.zsh %{buildroot}%{_datadir}/zsh/site-functions/_%{name}
install -Dm 0644 %{name}.fish %{buildroot}%{_datadir}/fish/vendor_completions.d/%{name}.fish

for i in 32 128; do
    install -Dm 0644  desktop/src-tauri/icons/$i\x$i.png %{buildroot}%{_datadir}/icons/hicolor/$i\x$i/apps/%{name}-desktop.png
done
install -Dm 0644  desktop/src-tauri/icons/icon.png %{buildroot}%{_datadir}/icons/hicolor/512x512/apps/%{name}-desktop.png

install -dm 755 %{buildroot}%{_datadir}/applications
cat > %{buildroot}%{_datadir}/applications/%{name}-desktop.desktop <<-EOF
[Desktop Entry]
Categories=Network;FileTransfer;P2P;
Comment=rqbit torrent client
Exec=%{name}-desktop
Icon=%{name}-desktop
Name=%{name}-desktop
Terminal=false
Type=Application
EOF

%if %{with check}
%check
%{cargo_test} || true
%endif

%files
%doc DEV-GUIDE.md README.md TODO.md
%{_bindir}/%{name}
%license LICENSE

%files desktop
%doc README.md
%{_bindir}/%{name}-desktop
%{_datadir}/applications/%{name}-desktop.desktop
%{_datadir}/icons/hicolor/*/apps/%{name}-desktop.??g
%license LICENSE

%files bash-completion
%dir %{_datadir}/bash-completion/
%dir %{_datadir}/bash-completion/completions
%{_datadir}/bash-completion/completions/%{name}

%files fish-completion
%dir %{_datadir}/fish
%dir %{_datadir}/fish/vendor_completions.d
%{_datadir}/fish/vendor_completions.d/%{name}.fish

%files zsh-completion
%dir %{_datadir}/zsh/
%dir %{_datadir}/zsh/site-functions
%{_datadir}/zsh/site-functions/_%{name}

%changelog
openSUSE Build Service is sponsored by