File rutorrent.spec of Package rutorrent
#
# spec file for package rutorrent
#
# 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 original_name ruTorrent
Name: rutorrent
Version: 5.2.10
Release: 0
Summary: Yet another web front-end for rTorrent
License: GPL-3.0-or-later
Group: Productivity/Networking/Web/Frontends
URL: https://github.com/Novik/%{original_name}
Source0: https://github.com/Novik/%{original_name}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1: apache.example.conf
Source2: apache.example.site.conf
BuildArch: noarch
BuildRequires: fdupes
# For SUSE & DEBBUILD - DEBIAN/UBUNTU
%if 0%{?sle_version} && 0%{?is_opensuse} || 0%{?suse_version} || "%{_vendor}" == "debbuild"
BuildRequires: apache2
%endif
#
# For FEDORA
%if 0%{?fedora}
BuildRequires: httpd
%endif
#
# For MAGEIA
%if 0%{?mageia}
BuildRequires: apache
%endif
#
# For SUSE & DEBBUILD - DEBIAN/UBUNTU
%if 0%{?sle_version} && 0%{?is_opensuse} || 0%{?suse_version} || "%{_vendor}" == "debbuild"
Requires: apache2
%endif
#
# For FEDORA
%if 0%{?fedora}
Requires: httpd
%endif
#
# For MAGEIA
%if 0%{?mageia}
Requires: apache
%endif
#
Requires: coreutils
Requires: gzip
Requires: php
Requires: php-curl
Recommends: php-cgi
Recommends: php-fpm
Obsoletes: %{name}-plugins <= 5.2.2
Provides: %{name}-plugins = %{version}-%{release}
%description
ruTorrent is a web-based front-end for the rTorrent BitTorrent client.
It provides a user-friendly interface to manage torrents,
leveraging PHP and web technologies for seamless integration with web servers.
%prep
%autosetup -n %{original_name}-%{version}
# Remove .github, .vscode, .gitignore and .gitmodules files and directories
rm -fdr ./{.github,.gitmodules,.vscode}
find . -type f -name ".gitignore" -exec rm -fdr {} \;
#
%build
# No build step required for this package
%install
# Install/copy all essentials
install -d "%{buildroot}/%{_sysconfdir}/webapps/%{name}/"
cp -a "./conf" -t "%{buildroot}/%{_sysconfdir}/webapps/%{name}/"
install -d "%{buildroot}/%{_datadir}/webapps/%{name}/"
cp -a "." -t "%{buildroot}/%{_datadir}/webapps/%{name}/"
#
# Remove the same files located elswhere
rm -rf "%{buildroot}/%{_datadir}/webapps/%{name}/conf"
rm -f "%{buildroot}%{_datadir}/webapps/%{name}/README.md"
rm -f "%{buildroot}%{_datadir}/webapps/%{name}/LICENSE.md"
#
# Install configuration samples from SOURCE to the SYSTEM
install -Dm644 %{SOURCE1} -t "%{buildroot}/%{_sysconfdir}/webapps/%{name}/"
install -Dm644 %{SOURCE2} -t "%{buildroot}/%{_sysconfdir}/webapps/%{name}/"
#
%check
# Look for and Possibly Remove Duplicates
# For DEB-Based Linux Distributions
%if "%{_vendor}" == "debbuild" || 0%{?debian} || 0%{?ubuntu}
fdupes -sr %{buildroot}/%{_datadir}/
fdupes -sr %{buildroot}/%{_sysconfdir}/
#
# For RPM-Based Linux Distributions
%else
%fdupes %{buildroot}/%{_datadir}/
%fdupes %{buildroot}/%{_sysconfdir}/
#
%endif
#
%post
# Change SYSTEM USER:GROUP of ruTorrent Profile
# For SUSE-Based Linux Distributions
%if 0%{?sle_version} && 0%{?is_opensuse} || 0%{?suse_version}
chown -R wwwrun:www %{_datadir}/webapps/%{name}/share/{settings,torrents,users}
%endif
#
# For FEDORA-Based Linux Distributions
%if 0%{?fedora} || 0%{?mageia}
chown -R apache:apache %{_datadir}/webapps/%{name}/share/{settings,torrents,users}
%endif
#
# For DEB-Based Linux Distributions
%if "%{_vendor}" == "debbuild" || 0%{?debian} || 0%{?ubuntu}
chown -R www-data:www-data %{_datadir}/webapps/%{name}/share/{settings,torrents,users}
%endif
#
%files
%license "LICENSE.md"
%doc "README.md"
%dir "%{_sysconfdir}/webapps/"
%dir "%{_sysconfdir}/webapps/%{name}/"
%dir "%{_sysconfdir}/webapps/%{name}/conf/"
%config %{_sysconfdir}/webapps/%{name}/conf/*
%config "%{_sysconfdir}/webapps/%{name}/conf/.htaccess"
%config %{_sysconfdir}/webapps/%{name}/{apache.example.conf,apache.example.site.conf}
%dir "%{_datadir}/webapps/"
%dir "%{_datadir}/webapps/%{name}/"
%{_datadir}/webapps/%{name}/*
%changelog