Package rain: Specfile

%define _unpackaged_files_terminate_build 1

%global import_path github.com/cenkalti/rain

Name: rain
Version: 2.3.0
Release: alt2
Summary: Rain is the main BitTorrent client used at put.io
License: MIT
Group: Networking/File transfer
Url: https://pkg.go.dev/github.com/cenkalti/rain
Vcs: https://github.com/cenkalti/rain

Source0: %name-%version.tar
Source1: vendor.tar
Source2: rain.service

Conflicts: bsd-games

BuildRequires(pre): rpm-build-golang
BuildRequires(pre): rpm-macros-systemd
BuildRequires: golang

%description
Rain is the main BitTorrent client used at put.io. It is designed to handle
hundreds of torrents while using low system resources. The main difference from
other clients is that Rain uses a separate peer port for each torrent. This
allows Rain to download same torrent for multiple accounts in same private
tracker and keep reporting their ratio correctly.

%prep
%setup -a 1
install %SOURCE2 .

%build
export BUILDDIR="$PWD/.gopath"
export IMPORT_PATH="%import_path"
export GOPATH="$BUILDDIR:%go_path"
export LDFLAGS="-X %import_path/torrent.Version=%version"

%golang_prepare

cd .gopath/src/%import_path

%golang_build .

%install
export BUILDDIR="$PWD/.gopath"
export IMPORT_PATH="%import_path"
export GOPATH="$BUILDDIR:%go_path"
export IGNORE_SOURCES=1

%golang_install
install -Dm 644 %name.service %buildroot%_user_unitdir/%name.service

%post
%systemd_user_post rain.service

%postun
%systemd_user_postun_with_restart rain.service

%pre
%systemd_user_preun rain.service

%preun
%systemd_user_postun rain.service

%files
%doc LICENSE README.md
%_bindir/%name
%_user_unitdir/%name.service

%changelog
* Thu Apr 02 2026 Vladislav Glinkin <smasher@altlinux.org> 2.3.0-alt2
- Added systemd user service

* Tue Mar 24 2026 Vladislav Glinkin <smasher@altlinux.org> 2.3.0-alt1
- New version

* Fri Sep 05 2025 Vladislav Glinkin <smasher@altlinux.org> 2.2.1-alt1
- 1.12.12 -> 2.2.1

* Mon Oct 23 2023 Vladislav Glinkin <smasher@altlinux.org> 1.12.12-alt2
- Added 'Conflicts: bsd-games' to the .spec file

* Fri Oct 20 2023 Vladislav Glinkin <smasher@altlinux.org> 1.12.12-alt1
- Initial build for ALT