File srtrelay.spec of Package srtrelay

#
# spec file for package srtrelay
#
# Copyright (c) 2024 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/
#

%global home_dir %{_localstatedir}/lib/%{name}
%global services %{name}.service

Name:           srtrelay
Version:        0
Release:        0
Summary:        Streaming-Relay for the SRT-protocol 
License:        MIT
URL:            https://github.com/voc/srtrelay.git
Source0:        %{name}-%{version}.tar.zst 
Source1:        vendor.tar.zst
Source2:        srtrelay.sysusers
Source3:        srtrelay.service
BuildRequires:  golang(API)
BuildRequires:  golang-packaging
BuildRequires:  pkgconfig(srt)
BuildRequires:  pkgconfig(systemd)
BuildRequires:  sysuser-shadow
BuildRequires:  sysuser-tools
%{?systemd_ordering}
%{?sysusers_requires}
%description
Use at your own risk.

%prep
%autosetup -p1 -a 1

%build
go build -mod=vendor -buildmode=pie -o srtrelay
%sysusers_generate_pre %{SOURCE2} %{name} %{name}.conf

%install
install -D -m 0755 srtrelay %{buildroot}%{_bindir}/srtrelay
install -D -m 0750 -d       %{buildroot}%{_sysconfdir}/%{name}/
install -D -m 0750 -d       %{buildroot}%{home_dir}
install -D -m 0640 config.toml.example %{buildroot}%{_sysconfdir}/%{name}/config.toml
install -D -m 644 %{SOURCE2}                  %{buildroot}%{_sysusersdir}/%{name}.conf
install -D -m 644 %{SOURCE3}                  %{buildroot}%{_unitdir}/%{services}

%pre -f %{name}.pre
%service_add_pre %{services}

%preun
%service_del_preun %{services}

%post
%service_add_post %{services}

%postun
%if %{with apparmor}
%apparmor_reload %{_sysconfdir}/apparmor.d/%{name}
%endif
%service_del_postun %{services}

%files
%license LICENSE
%doc README.md
%doc docs/*.md
%{_bindir}/srtrelay
%config(noreplace) %attr(-,root,%{name}) %{_sysconfdir}/%{name}/
%attr(-,%{name},%{name}) %{home_dir}
%{_sysusersdir}/%{name}.conf
%{_unitdir}/%{services}

%changelog
openSUSE Build Service is sponsored by