## START: Set by rpmautospec
## (rpmautospec version 0.7.2)
## RPMAUTOSPEC: autochangelog
## END: Set by rpmautospec

%global goipath     github.com/majestrate/XD

Version:			0.4.6
%gometa

%global golicenses	LICENSE
%global godocs		docs/readme.md docs/en/readme.md docs/fr/readme.md docs/ru/readme.md
%global common_description %{expand:
BitTorrent Client written in GO (as a joke)
}

Name:				%{goname}
Release:			1%{?dist}
Summary:			meme bittorrent client
URL:				%{gourl}
License:			MIT

Source0:			%{gosource}
Source1:			xd-vendor.tar.gz
Source2:			torrents.ini
Source3:			xd-daemon.service

# Required by TestSHA
BuildRequires:		perl-Digest-SHA
BuildRequires:		systemd-rpm-macros

%description
%{common_description}

%gopkg

Provides:			bundled(golang(github.com/kr/fs)) = 0.1.0
Provides:			bundled(golang(github.com/github.com/mattn/kinako)) = 0.0.0-20170717041458-332c0a7e205a
Provides:			bundled(golang(github.com/pkg/sftp)) = 1.13.5
Provides:			bundled(golang(github.com/zeebo/bencode)) = 1.0.0
Provides:			bundled(golang(github.com/x/crypto)) = 0.17.0
Provides:			bundled(golang(github.com/x/sys)) = 0.15.0
Provides:			bundled(golang(gopkg.in/leonelquinteros/gotext.v1)) = 1.3.1


%package -n xd
Summary:			meme bittorrent client
Requires:			(i2pd or i2pd-git)

%description -n xd
%{common_description}


%prep
%goprep

# Restore vendors
tar xvf %{SOURCE1} -C .

%generate_buildrequires

%build
# Prepare web UI
%{__make} webui

# Build xd
%gobuild "-tags='webui'" -o %{gobuilddir}/bin/xd

%install
%gopkginstall

install -m 0755 -vd %{buildroot}%{_bindir}
install -m 0755 -vp %{gobuilddir}/bin/xd %{buildroot}%{_bindir}/
ln -s xd %{buildroot}%{_bindir}/xd-cli

install -m 0755 -vd %{buildroot}%{_sharedstatedir}/xd
install -m 0644 -vp %{SOURCE2} %{buildroot}%{_sharedstatedir}/xd/

install -m 0755 -vd %{buildroot}%{_unitdir}
install -m 0644 -vp %{SOURCE3} %{buildroot}%{_unitdir}/

%check
%gocheck

%gopkgfiles

%files -n xd
%license LICENSE
%doc docs/en/readme.md
%{_bindir}/xd
%{_bindir}/xd-cli
%{_sharedstatedir}/xd
%config(noreplace) %{_sharedstatedir}/xd/torrents.ini
%{_unitdir}/xd-daemon.service


%changelog
## START: Generated by rpmautospec
* Sat Sep 14 2024 Luca Magrone <luca@magrone.cc> - 0.4.6-1
- Initial package release
## END: Generated by rpmautospec