File qbittorrent.spec of Package qbittorrent

#
# spec file for package qbittorrent
#
# Copyright (c) 2024 SUSE LLC
# Copyright (c) 2014 Mariusz Fik <fisiu@opensuse.org>.
#
# 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/
#


%if 0%{?sle_version} == 150500 || 0%{?sle_version} == 150600
%define _pyalt  11
%endif
%if 0%{?sle_version} == 150400
%define _pyalt  10
%endif

Name:           qbittorrent
Version:        4.6.4
Release:        0
Summary:        A BitTorrent client in Qt
License:        GPL-2.0-or-later
URL:            https://qbittorrent.org
Source:         https://downloads.sf.net/%{name}/%{name}-%{version}.tar.xz
Source1:        https://downloads.sf.net/%{name}/%{name}-%{version}.tar.xz.asc
Source2:        https://raw.githubusercontent.com/qbittorrent/qBittorrent/release-%{version}/5B7CC9A2.asc#/%{name}.keyring
Patch0:         harden_qbittorrent-nox@.service.patch
# PATCH-FIX-OPENSUSE qbittorrent-fix_boost_1.66_build.patch search for libboost_system.so and patch stacktrace function # aloisio@gmx.com
Patch2:         qbittorrent-fix_boost_1.66_build.patch
# PATCH-FIX-OPENSUSE qbittorrent-altpython.patch force newer python for the plugins -- aloisio@gmx.com
Patch3:         qbittorrent-altpython.patch
BuildRequires:  cmake >= 3.16
BuildRequires:  fdupes
BuildRequires:  hicolor-icon-theme
BuildRequires:  libboost_system-devel >= 1.66
BuildRequires:  pkgconfig
%if 0%{?suse_version} == 1500
BuildRequires:  gcc11
BuildRequires:  gcc11-c++
%endif
BuildRequires:  libqt5-qtbase-private-headers-devel
BuildRequires:  cmake(Qt5Concurrent)
BuildRequires:  cmake(Qt5Core) >= 5.15.2
BuildRequires:  cmake(Qt5DBus)
BuildRequires:  cmake(Qt5Gui)
BuildRequires:  cmake(Qt5LinguistTools)
BuildRequires:  cmake(Qt5Network)
BuildRequires:  cmake(Qt5Sql)
BuildRequires:  cmake(Qt5Svg)
BuildRequires:  cmake(Qt5Widgets)
BuildRequires:  cmake(Qt5Xml)
BuildRequires:  pkgconfig(libtorrent-rasterbar) >= 2.0.9
BuildRequires:  pkgconfig(openssl) >= 1.1.1
BuildRequires:  pkgconfig(systemd)
BuildRequires:  pkgconfig(zlib) >= 1.2.11
# For search engines.
Recommends:     python3%{_pyalt}

%description
qBittorrent is a bittorrent client programmed in C++ and Qt that
uses libtorrent-rasterbar.

It has a streaming-like function to let users download and play video
files, supports Unicode and has a bandwith scheduler.

%package nox
Summary:        A BitTorrent client in Qt, CLI version
%{?systemd_requires}

%description nox
qBittorrent is a bittorrent client programmed in C++ and Qt that
uses libtorrent-rasterbar. This subpackage contains a command-line
version.

%prep
%autosetup -p1
sed -e 's/__PYTHON_ALT__/python3%{?_pyalt:.%{_pyalt}}/' -i src/base/utils/foreignapps.cpp

%build
%if 0%{?suse_version} == 1500
export CC=gcc-11
export CXX=g++-11
%endif
for ui in nox gui; do
    [ "$ui" = nox ] && ui_opt="-DGUI=OFF" || ui_opt=
    %cmake \
      $ui_opt      \
      -DSYSTEMD=ON \
      -DSystemd_SERVICES_INSTALL_DIR=%{_unitdir}

    %cmake_build -j1
    cd ..
    mv build build.$ui
done

%install
for ui in nox gui; do
    mv build.$ui build
    %cmake_install
    mv build build.$ui
done

mkdir -p %{buildroot}%{_sbindir}/
ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-nox

%fdupes %{buildroot}%{_datadir}/

%preun nox
%service_del_preun %{name}-nox@.service

%pre nox
%service_add_pre %{name}-nox@.service

%postun nox
%service_del_postun %{name}-nox@.service

%post nox
%service_add_post %{name}-nox@.service

%files
%license COPYING
%doc AUTHORS Changelog README.md
%{_bindir}/%{name}
%{_datadir}/applications/org.qbittorrent.qBittorrent.desktop
%{_datadir}/icons/hicolor/*/apps/%{name}.*
%{_datadir}/icons/hicolor/*/status/%{name}-tray.png
%{_datadir}/icons/hicolor/scalable/status/%{name}-tray*.svg
%{_datadir}/metainfo/org.qbittorrent.qBittorrent.appdata.xml
%{_mandir}/man?/%{name}.?%{?ext_man}

%files nox
%license COPYING
%doc AUTHORS Changelog README.md
%{_bindir}/%{name}-nox
%{_sbindir}/rc%{name}-nox
%{_unitdir}/%{name}-nox@.service
%{_mandir}/man?/%{name}-nox.?%{?ext_man}

%changelog
openSUSE Build Service is sponsored by