File qbittorrent.spec of Package qbittorrent

%define realname qbittorrent
%define realver  4.2.0
%define srcext   tar.xz

%define qt_req_ver 5.9.0

# turn off the generation of debuginfo rpm  (RH9) ??
%global debug_package %{nil}

%if 0%{?suse_version} < 1500 && 0%{?rhel} < 8
%define cxx11abi -D_GLIBCXX_USE_CXX11_ABI=0
%endif

# Common info
Name:          %{realname}
Version:       %{realver}
Release:       wiz%{?extraver:0.}1%{?dist}
License:       GPL-2.0
Group:         Productivity/Networking/File-Sharing
URL:           http://www.qbittorrent.org/
Summary:       A BitTorrent client in Qt4

# Build-time parameters
BuildRequires: gcc-c++
BuildRequires: cmake >= 3.9
BuildRequires: pkgconfig
BuildRequires: xz
BuildRequires: boost-devel >= 1.40
BuildRequires: openssl-devel >= 1.0
BuildRequires: pkgconfig(Qt5Core)    >= %{qt_req_ver}
BuildRequires: pkgconfig(Qt5DBus)    >= %{qt_req_ver}
BuildRequires: pkgconfig(Qt5Gui)     >= %{qt_req_ver}
BuildRequires: pkgconfig(Qt5Network) >= %{qt_req_ver}
BuildRequires: pkgconfig(Qt5Svg)     >= %{qt_req_ver}
BuildRequires: pkgconfig(Qt5Widgets) >= %{qt_req_ver}
BuildRequires: pkgconfig(Qt5Xml)     >= %{qt_req_ver}
BuildRequires: pkgconfig(QJson) >= 0.8.1
BuildRequires: libqt5-linguist-devel
BuildRequires: pkgconfig(libtorrent-rasterbar) >= 1.1.10
BuildRequires: pkgconfig(zlib) >= 1.2.5.2
BuildRequires: pkgconfig(systemd)
%if 0%{?suse_version}
BuildRequires: fdupes
%endif
BuildRoot:     %{_tmppath}/%{name}-root
Source:        http://sourceforge.net/projects/qbittorrent/files/qbittorrent/%{realname}-%{realver}/%{realname}-%{realver}%{?extraver}.%{srcext}

%description
An advanced and multi-platform BitTorrent client with a nice Qt4 user interface
as well as a Web UI for remote control and an integrated search engine.
qBittorrent aims to meet the needs of most users while using as little CPU
and memory as possible.

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{realver}%{?extraver}
%{__sed} -ri 's|:(/lang/qbittorrent_)|%{_datadir}/%{name}\1|' src/app/application.cpp
# Fix error: 'ParsingResultTypeId' defined but not used [-Werror=unused-variable]
%{__sed} -ri '/^const int ParsingResultTypeId/ d' src/base/rss/private/rss_parser.cpp

%build
export PATH=$PATH:%{_libdir}/qt5/bin
%{__mkdir} build
cd build
cmake .. \
 -DCMAKE_INSTALL_PREFIX=%{_prefix} \
 -DCMAKE_BUILD_TYPE=Release \
 -DCMAKE_CXX_FLAGS_RELEASE="${CFLAGS} %{?gcc_lto}" \
 -DCMAKE_C_FLAGS_RELEASE="${CFLAGS} %{?gcc_lto}" \
 -DCMAKE_EXE_LINKER_FLAGS_RELEASE="-Wl,--as-needed -Wl,--strip-all %{?gcc_lto}" \
 -DCMAKE_MODULE_LINKER_FLAGS_RELEASE="-Wl,--as-needed -Wl,--strip-all %{?gcc_lto}" \
 -DCMAKE_SHARED_LINKER_FLAGS_RELEASE="-Wl,--as-needed -Wl,--strip-all %{?gcc_lto} ${CURSES_LIB}" \
 -DSYSTEMD=YES \
 -DDBUS=YES
%{__make} %{?_smp_mflags}

%install
%{__make} -C build install DESTDIR=%{buildroot}
%{__install} -d -m755 %{buildroot}%{_datadir}/%{name}/lang
%{__install} -m644 build/src/lang/*.qm %{buildroot}%{_datadir}/%{name}/lang/
%if 0%{?suse_version}
%fdupes %{buildroot}%{_datadir}/
%endif
%find_lang %{name} --with-qt

%clean
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}

%files -f %{name}.lang
%defattr(-,root,root)
%attr(0644,root,root) %doc AUTHORS COPYING NEWS README.md TODO
%{_bindir}/qbittorrent
%{_datadir}/applications/org.qbittorrent.qBittorrent.desktop
%{_datadir}/icons/hicolor/
%dir %{_datadir}/metainfo
%{_datadir}/metainfo/org.qbittorrent.qBittorrent.appdata.xml
%dir %{_datadir}/%{name}/lang/
%dir %{_datadir}/%{name}/
%attr(0644,root,root) %doc %{_mandir}/man1/*

%changelog
openSUSE Build Service is sponsored by