File mautrix-discord.spec of Package mautrix-discord

#
# spec file for package mautrix-discord
#
# Copyright (c) 2022 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/
#


Name:           mautrix-discord
Version:        0.7.5+git.0.40a6992
Release:        0
Summary:        A Matrix-Discord puppeting bridge
License:        AGPL-3.0-only
URL:            https://go.mau.fi/mautrix-discord
Source0:        %{name}-%{version}.tar.gz
Source1:        vendor.tar.gz
Source2:        %{name}.service
Source3:        %{name}.sysusers
Source4:        README.SUSE
BuildRequires:  golang(API) >= 1.22
BuildRequires:  pkgconfig(olm)
BuildRequires:  libstdc++-devel
BuildRequires:  sysuser-tools
%sysusers_requires

%description
A Matrix-Discord puppeting bridge based on discordgo.

%prep
%autosetup -a1

%build
mkdir bin
export GOFLAGS="$GOFLAGS -buildmode=pie -mod=vendor"
go build -ldflags "-s -w" -o "bin/" -v .

%sysusers_generate_pre %{SOURCE3} %{name} %{name}.conf

%install
cp %{SOURCE4} .
install -D -m 0644 %{SOURCE3} %{buildroot}%{_sysusersdir}/%{name}.conf
#Binary
install -d %{buildroot}%{_sbindir}
install -D bin/%{name} %{buildroot}%{_sbindir}/%{name}
#Config
install -d %{buildroot}%{_sysconfdir}/%{name}
sed -i 's|filename: .\/logs|filename: %{_localstatedir}\/log\/%{name}|g' example-config.yaml
install -D example-config.yaml %{buildroot}%{_sysconfdir}/%{name}/example-config.yaml
#Storage
install -d %{buildroot}%{_localstatedir}/lib/%{name}
#Unit
install -d -m 755 %{buildroot}%{_unitdir}
install -m 444 %{SOURCE2} %{buildroot}%{_unitdir}
#Logdir
install -d %{buildroot}%{_localstatedir}/log/%{name}

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

%post
%service_add_post %{name}.service

%preun
%service_del_preun %{name}.service

%postun
%service_del_postun %{name}.service

%files
%license LICENSE
%doc README.md README.SUSE ROADMAP.md
%{_sbindir}/%{name}
%{_unitdir}/%{name}.service
%{_sysusersdir}/%{name}.conf
%attr(750,%{name},%{name}) %{_sysconfdir}/%{name}
%attr(640,%{name},%{name}) %config %{_sysconfdir}/%{name}/example-config.yaml
%attr(750,%{name},%{name}) %{_localstatedir}/log/%{name}
%attr(750,%{name},%{name}) %{_localstatedir}/lib/%{name}

%changelog

openSUSE Build Service is sponsored by