File transmission.spec of Package transmission

#
# spec file for package transmission
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#


Name:           transmission
Version:        2.94
Release:        0
Summary:        A BitTorrent client with multiple UIs
License:        (GPL-2.0-only OR GPL-3.0-only) AND MIT
Group:          Productivity/Networking/Other
Url:            https://www.transmissionbt.com/
Source0:        https://github.com/%{name}/%{name}-releases/raw/master/%{name}-%{version}.tar.xz
Source1:        transmission-qt.desktop
Source2:        transmission-daemon-systemd
Source3:        README.openSUSE
# PATCH-FIX-UPSTREAM transmission-appdata.patch badshah400@gmail.com -- Add and install appdata files for both gtk and qt applications; enable translations for the gtk metainfo
Patch0:         transmission-appdata.patch
# PATCH-FIX-UPSTREAM transmission-systemd.patch dimstar@opensuse.org -- Fix build with systemd 232, patch taken from git
Patch1:         transmission-systemd.patch
# PATCH-FIX-UPSTREAM translmission-3rdparty-no-download.patch marguerite@opensuse.org do not update \
# 3rd-party dependencies from github during build, specify the SOURCE_DIR containing sources.
Patch2:         transmission-3rdparty-no-download.patch
BuildRequires:  cmake
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  intltool
BuildRequires:  libb64-devel
BuildRequires:  libcurl-devel
BuildRequires:  libevent-devel >= 2.0.0
BuildRequires:  libminiupnpc-devel
BuildRequires:  libqt5-linguist-devel
BuildRequires:  libqt5-qtbase-devel
BuildRequires:  libtool
BuildRequires:  openssl-devel >= 0.9.7
BuildRequires:  pkgconfig
BuildRequires:  update-desktop-files
BuildRequires:  pkgconfig(glib-2.0) >= 2.32.0
BuildRequires:  pkgconfig(gtk+-3.0) >= 3.4.0
BuildRequires:  pkgconfig(libsystemd) >= 209
BuildRequires:  pkgconfig(zlib) >= 1.2.3
Requires:       %{name}-common = %{version}
Requires(post): update-alternatives
Requires(postun): update-alternatives
Provides:       %{name}-ui = %{version}
%if 0%{?WITH_APPINDICATOR}
BuildRequires:  libappindicator3-devel >= 0.4.90
%endif

%description
Transmission is a BitTorrent client. It has GTK+ and Qt GUI clients,
a daemon for servers and headless use, and both can be remote
controlled by HTTP and the terminal. It supports Local Peer
Discovery, DHT, µTP, PEX and magnet links.

%package gtk
Summary:        GTK client for the "transmission" BitTorrent client
Group:          Productivity/Networking/Other
Requires:       %{name}-common = %{version}
# For canberra-gtk-play binary
Requires:       canberra-gtk-play
Requires(post): update-alternatives
Requires(postun): update-alternatives
Recommends:     %{name}-gtk-lang
Provides:       %{name}-ui = %{version}

%description gtk
Transmission is a BitTorrent client. It has GTK+ and Qt GUI clients,
a daemon for servers and headless use, and both can be remote
controlled by HTTP and the terminal. It supports Local Peer
Discovery, DHT, µTP, PEX and magnet links.

This package contains a graphical user interface to transmission.

%package qt
Summary:        Qt interface for the "transmission" BitTorrent client
Group:          Productivity/Networking/Other
Requires:       %{name}-common = %{version}
Requires(post): update-alternatives
Requires(postun): update-alternatives
Recommends:     %{name}-qt-lang
Provides:       %{name}-ui = %{version}

%description qt
Transmission is a BitTorrent client. It has GTK+ and Qt GUI clients,
a daemon for servers and headless use, and both can be remote
controlled by HTTP and the terminal. It supports Local Peer
Discovery, DHT, µTP, PEX and magnet links.

This package contains a graphical user interface to transmission.

%package common
Summary:        Common data for the "transmission" BitTorrent client
Group:          Productivity/Networking/Other
Requires:       %{name}-ui = %{version}
BuildArch:      noarch

%description common
Transmission is a BitTorrent client. It has GTK+ and Qt GUI clients,
a daemon for servers and headless use, and both can be remote
controlled by HTTP and the terminal. It supports Local Peer
Discovery, DHT, µTP, PEX and magnet links.

%package daemon
Summary:        Daemon for the "transmission" BitTorrent client
Group:          Productivity/Networking/Other
%{?systemd_requires}

%description daemon
Transmission is a BitTorrent client. It has GTK+ and Qt GUI clients,
a daemon for servers and headless use, and both can be remote
controlled by HTTP and the terminal. It supports Local Peer
Discovery, DHT, µTP, PEX and magnet links.

%lang_package -n %{name}-gtk
%lang_package -n %{name}-qt

%prep
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
cp %{SOURCE3} .
# required by patch2
mv third-party/libnatpmp third-party/natpmp
mv third-party/libutp third-party/utp

%build
export CFLAGS="%{optflags} -fPIC"
export CXXFLAGS="%{optflags} -fPIC"
%cmake \
%if 0%{?WITH_APPINDICATOR}
        -DWITH_LIBAPPINDICATOR=ON \
%endif
        -DENABLE_QT=ON \
        -DUSE_QT5=ON \
        -DUSE_SYSTEM_B64=ON \
        -DENABLE_CLI=ON
make %{?_smp_mflags}

%install
%cmake_install
install -D -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/transmission-daemon.service
install -d %{buildroot}%{_sbindir}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rctransmission-daemon
mkdir -p %{buildroot}%{_localstatedir}/lib/transmission
# create targets for transmission below /etc/alternatives/
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
ln -s -f %{_sysconfdir}/alternatives/transmission %{buildroot}/%{_bindir}/transmission
ln -s -f %{_sysconfdir}/alternatives/transmission.1.gz %{buildroot}/%{_mandir}/man1/transmission.1.gz
# fix doc
rm -rf %{buildroot}%{_datadir}/doc/transmission
%find_lang transmission-gtk %{?no_lang_C}
%find_lang transmission transmission-qt.lang --with-qt --without-mo %{?no_lang_C}
%suse_update_desktop_file transmission-gtk
%suse_update_desktop_file -i transmission-qt
%fdupes %{buildroot}

%check
%ctest

%pre daemon
getent group transmission >/dev/null || groupadd -r transmission
getent passwd transmission >/dev/null || \
    useradd -r -g transmission -d %{_localstatedir}/lib/transmission -s /sbin/nologin \
    -c "Transmission BT daemon user" transmission
%service_add_pre transmission-daemon.service

%post daemon
%service_add_post transmission-daemon.service

%preun daemon
%service_del_preun transmission-daemon.service

%postun daemon
%service_del_postun transmission-daemon.service

%post
update-alternatives --install %{_bindir}/transmission           transmission      %{_bindir}/transmission-cli 5         \
                    --slave   %{_mandir}/man1/transmission.1.gz transmission.1.gz %{_mandir}/man1/transmission-cli.1.gz

%post gtk
update-alternatives --install %{_bindir}/transmission           transmission      %{_bindir}/transmission-gtk 15        \
                    --slave   %{_mandir}/man1/transmission.1.gz transmission.1.gz %{_mandir}/man1/transmission-gtk.1.gz
%desktop_database_post

%post qt
update-alternatives --install %{_bindir}/transmission           transmission      %{_bindir}/transmission-qt 10         \
                    --slave   %{_mandir}/man1/transmission.1.gz transmission.1.gz %{_mandir}/man1/transmission-qt.1.gz
%if 0%{?suse_version} < 1500
%desktop_database_post

%post common
%icon_theme_cache_post
%endif

%postun
# Note: we don't use "$1 -eq 0", to avoid issues if the package gets renamed
if [ ! -f %{_bindir}/transmission-cli ]; then
  update-alternatives --remove transmission %{_bindir}/transmission-cli
fi

%postun gtk
# Note: we don't use "$1 -eq 0", to avoid issues if the package gets renamed
if [ ! -f %{_bindir}/transmission-gtk ]; then
  update-alternatives --remove transmission %{_bindir}/transmission-gtk
fi
%if 0%{?suse_version} < 1500
%desktop_database_postun
%endif

%postun qt
# Note: we don't use "$1 -eq 0", to avoid issues if the package gets renamed
if [ ! -f %{_bindir}/transmission-qt ]; then
  update-alternatives --remove transmission %{_bindir}/transmission-qt
fi
%if 0%{?suse_version} < 1500
%desktop_database_postun

%postun common
%icon_theme_cache_postun
%endif

%files
%doc AUTHORS NEWS README README.openSUSE
%doc extras/rpc-spec.txt extras/send-email-when-torrent-done.sh
%license COPYING
%{_bindir}/%{name}-cli
%{_bindir}/%{name}-create
%{_bindir}/%{name}-edit
%{_bindir}/%{name}-remote
%{_bindir}/%{name}-show
%{_mandir}/man1/%{name}-cli.1*
%{_mandir}/man1/%{name}-create.1*
%{_mandir}/man1/%{name}-edit.1*
%{_mandir}/man1/%{name}-remote.1*
%{_mandir}/man1/%{name}-show.1*
# Update-Alternative managed
%{_bindir}/%{name}
%{_mandir}/man1/%{name}.1%{?ext_man}
%ghost %{_sysconfdir}/alternatives/%{name}
%ghost %{_sysconfdir}/alternatives/%{name}.1.gz

%files daemon
%doc AUTHORS NEWS README README.openSUSE
%license COPYING
%dir %{_localstatedir}/lib/%{name}
%{_mandir}/man1/%{name}-daemon.1*
%{_bindir}/%{name}-daemon
%{_sbindir}/rc%{name}-daemon
%{_unitdir}/%{name}-daemon.service
%attr(-,transmission,transmission)%{_localstatedir}/lib/transmission/

%files -n %{name}-gtk-lang -f %{name}-gtk.lang

%files gtk
%doc AUTHORS NEWS README README.openSUSE
%license COPYING
%{_bindir}/%{name}-gtk
%{_datadir}/applications/%{name}-gtk.desktop
%{_mandir}/man1/%{name}-gtk.1*
# Update-Alternative managed
%{_bindir}/%{name}
%{_mandir}/man1/%{name}.1%{?ext_man}
%ghost %{_sysconfdir}/alternatives/%{name}
%ghost %{_sysconfdir}/alternatives/%{name}.1.gz
%dir %{_datadir}/appdata
%{_datadir}/appdata/%{name}-gtk.appdata.xml

%files -n %{name}-qt-lang -f %{name}-qt.lang
%dir %{_datadir}/%{name}/translations

%files qt
%doc AUTHORS NEWS README README.openSUSE
%license COPYING
%{_bindir}/%{name}-qt
%{_datadir}/applications/%{name}-qt.desktop
%{_mandir}/man1/%{name}-qt.1*
# Update-Alternative managed
%{_bindir}/%{name}
%{_mandir}/man1/%{name}.1%{?ext_man}
%ghost %{_sysconfdir}/alternatives/%{name}
%ghost %{_sysconfdir}/alternatives/%{name}.1.gz
%dir %{_datadir}/appdata
%{_datadir}/appdata/%{name}-qt.appdata.xml

%files common
%{_datadir}/%{name}/
%{_datadir}/icons/*/*/apps/%{name}.*
%exclude %{_datadir}/%{name}/translations

%changelog
openSUSE Build Service is sponsored by