File tailscale.spec of Package tailscale

#
# spec file for package tailscale
#
# Copyright (c) 2023 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 commit 77c732357bd891ff062b8aeeac5489f85315f261
%define import_path tailscale.com/cmd/tailscale
Name:           tailscale
Version:        1.48.0
Release:        0
Group:          Productivity/Networking/Security
Summary:        The easiest, most secure way to use WireGuard and 2FA
License:        BSD-3-Clause
URL:            https://github.com/tailscale/tailscale
Source:         %{name}-%{version}.tar
Source1:        vendor.tar.zst
Source2:        tailscaled.service
Source3:        tailscaled.defaults
BuildRequires:  golang-packaging
BuildRequires:  git
BuildRequires:  zstd
BuildRequires:  glibc
BuildRequires:  golang(API) = 1.21

%description
Tailscale is a Manager which creates a Mesh network with the help of Wireguard.

This is only the client, which requires an account on tailscale.com. An alternative is hosting your own
Headscale (self hosted solution).

%prep
%autosetup -a1

%build
go build -v -buildmode=pie -mod=vendor -ldflags "-s -w -X tailscale.com/version.shortStamp=%{version} -X tailscale.com/version.gitCommitStamp=%{commit}" -o tailscale ./cmd/tailscale
go build -v -buildmode=pie -mod=vendor -ldflags "-s -w -X tailscale.com/version.shortStamp=%{version} -X tailscale.com/version.gitCommitStamp=%{commit}" -o tailscaled ./cmd/tailscaled

%install
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_sbindir}
mkdir -p %{buildroot}%{_sysconfdir}/default
mkdir -p %{buildroot}%{_prefix}/lib/systemd/system
install -Dm755 tailscale %{buildroot}%{_bindir}
install -Dm755 tailscaled %{buildroot}%{_sbindir}
install -Dm644 %{SOURCE3} %{buildroot}%{_sysconfdir}/default/tailscaled
install -Dm644 %{SOURCE2} %{buildroot}%{_prefix}/lib/systemd/system/tailscaled.service

%service_add_pre %{name}d.service

%post
%service_add_post %{name}d.service

%postun
%service_del_postun %{name}d.service



%files
%{_bindir}/tailscale
%{_sbindir}/tailscaled
%config %{_sysconfdir}/default/tailscaled
%{_prefix}/lib/systemd/system/tailscaled.service
%license LICENSE
%doc README.md

%changelog
openSUSE Build Service is sponsored by