Name:           yggdrasil-go
Version:        0.4.7
Release:        1%{?dist}
Summary:        Scalable routing as an encrypted IPv6 overlay network

License:        LGPLv3
URL:            https://yggdrasil-network.github.io
Source:         https://github.com/yggdrasil-network/yggdrasil-go/archive/refs/tags/v%{version}.zip

Obsoletes: yggdrasil <= %{version}
Provides:           %{name} = %{version}

%{?systemd_requires}
BuildRequires:  systemd golang >= 1.13 git

%if 0%{?suse_version}
BuildRequires:  unzip
%endif

Requires(pre):  shadow-utils

%description
Yggdrasil is an early-stage implementation of a fully end-to-end
encrypted IPv6 network. It is lightweight, self-arranging, supported on
multiple platforms and allows pretty much any IPv6-capable application
to communicate securely with other Yggdrasil nodes. Yggdrasil does not
require you to have IPv6 Internet connectivity - it also works over IPv4.

%define debug_package %{nil}

%pre
getent group yggdrasil >/dev/null || groupadd -r yggdrasil
exit 0

%prep
%setup -qn yggdrasil-go-%{version}

%build
export PKGNAME="%{name}"
export PKGVER="%{version}"
export GOPROXY="https://proxy.golang.org,direct"
./build -t -p -l "-linkmode=external"

%install
rm -rf %{buildroot}
install -m 0755 -D yggdrasil %{buildroot}/%{_bindir}/yggdrasil
install -m 0755 -D yggdrasilctl %{buildroot}/%{_bindir}/yggdrasilctl
install -m 0755 -D contrib/systemd/yggdrasil.service %{buildroot}/%{_sysconfdir}/systemd/system/yggdrasil.service

%files
%license LICENSE
%{_bindir}/yggdrasil
%{_bindir}/yggdrasilctl
%{_sysconfdir}/systemd/system/yggdrasil.service

%post
%systemd_post yggdrasil.service

%preun
%systemd_preun yggdrasil.service

%postun
%systemd_postun_with_restart yggdrasil.service

%changelog
* Sat Dec 31 2022 Fhiss <fhiss@ro.ru> - 0.4.7-1
- New yggdrasil 0.4.7 build
* Mon Nov 7 2022 Fhiss <fhiss@ro.ru> - 0.4.6-1
- New yggdrasil 0.4.6 build
* Sun Jul 31 2022 Fhiss <fhiss@ro.ru> - 0.4.4-1
- New yggdrasil 0.4.4 build