File yggdrasil-go.spec of Package yggdrasil-go

# Generated by go2rpm 1.6.0
%bcond_without check

# https://github.com/yggdrasil-network/yggdrasil-go
%global goipath         github.com/yggdrasil-network/yggdrasil-go
Version:                0.5.6

%gometa

%global goname          yggdrasil-go

%global common_description %{expand:
An experiment in scalable routing as an encrypted IPv6 overlay network.}

%global golicenses      LICENSE
%global godocs          README.md CHANGELOG.md

Name:           %{goname}
Release:        1%{?dist}
Summary:        An experiment in scalable routing as an encrypted IPv6 overlay network

License:        LGPL-3.0-only
URL:            %{gourl}
Source0:        https://%{goipath}/archive/v%{version}/yggdrasil-go-%{version}.tar.gz
Source1:        yggdrasil.service
Source2:        yggdrasil-default-config.service
Source3:        yggdrasil.sysusers
Patch0:         yggdrasil-fix-paths.patch
BuildRequires:  go-rpm-macros
BuildRequires:  systemd-rpm-macros

%description
%{common_description}

%gopkg

%prep
%goprep
%patch0 -p1

%generate_buildrequires
%go_generate_buildrequires

%build
for cmd in cmd/* ; do
  %gobuild -o %{gobuilddir}/bin/$(basename $cmd) %{goipath}/$cmd
done
for cmd in contrib/ansible; do
  %gobuild -o %{gobuilddir}/bin/$(basename $cmd) %{goipath}/$cmd
done

%install
%gopkginstall
install -m 0755 -vd %{buildroot}%{_sysconfdir}/yggdrasil
install -m 0755 -vd %{buildroot}%{_sbindir}
install -m 0755 -vp %{gobuilddir}/bin/yggdrasil \
                    %{buildroot}%{_sbindir}/yggdrasil
install -m 0755 -vp %{gobuilddir}/bin/yggdrasilctl \
                    %{buildroot}%{_sbindir}/yggdrasilctl
install -m 0755 -vp %{gobuilddir}/bin/genkeys \
                    %{buildroot}%{_sbindir}/yggdrasil-genkeys
install -m 0755 -vd %{buildroot}%{_unitdir}
install -m 0644 -vp %{SOURCE1} %{buildroot}%{_unitdir}/
install -m 0644 -vp %{SOURCE2} %{buildroot}%{_unitdir}/
install -m 0755 -vd %{buildroot}%{_sysusersdir}
install -m 0644 -vp %{SOURCE3} %{buildroot}%{_sysusersdir}/yggdrasil.conf

%if %{with check}
%check
%gocheck
%endif

%pre
%sysusers_create_compat %{SOURCE3}

%post
%systemd_post yggdrasil.service

%preun
%systemd_preun yggdrasil.service

%postun
%systemd_postun_with_restart yggdrasil.service

%files
%license LICENSE
%doc README.md CHANGELOG.md
%dir %{_sysconfdir}/yggdrasil
%{_sbindir}/yggdrasil
%{_sbindir}/yggdrasilctl
%{_sbindir}/yggdrasil-genkeys
%{_unitdir}/yggdrasil*.service
%{_sysusersdir}/yggdrasil.conf

%gopkgfiles