%global _hardened_build 1
%define debug_package %{nil}

Name:		matterbridge
Version:	1.23.2
Release:	1%{?dist}
Summary:	Bridge to your chat channels
Group:		System/Library
License:	MIT
URL:		https://github.com/42wim/matterbridge
Source0:	matterbridge.service
BuildRequires:	golang


%description
Bridge between mattermost, IRC, gitter, xmpp, slack, discord, telegram,
rocket.chat, hipchat (via xmpp), steam, twitch, ssh-chat, zulip, whatsapp,
and matrix with REST API (mattermost not required!)


%prep
%setup -q -T -c %{name}-%{version}
export GOPATH=`pwd`
mkdir -p go/src/github.com/42wim/
cd go/src/github.com/42wim/
git clone https://github.com/42wim/matterbridge


%build
export GOPATH=`pwd`
cd go/src/github.com/42wim/matterbridge
git checkout v%{version}
go build -v -trimpath -ldflags "-extldflags -s -w -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -buildid "%{version}" -X 'main.Version="%{version}"' -X 'main.MakeVersion="%{release}"' -X 'main.githash="$(git log --pretty=format:'%h' -n 1)"'" -o matterbridge


%install
install -p -D -m 0644 %{SOURCE0} %{buildroot}%{_unitdir}/matterbridge.service
install -p -D -m 0555 go/src/github.com/42wim/matterbridge/matterbridge %{buildroot}%{_bindir}/matterbridge
install -p -D -m 0644 go/src/github.com/42wim/matterbridge/matterbridge.toml.sample %{buildroot}%{_sysconfdir}/matterbridge/matterbridge.toml


%post
%systemd_post matterbridge.service


%preun
%systemd_preun matterbridge.service


%postun
%systemd_postun matterbridge.service


%files
%doc
%config(noreplace) %{_sysconfdir}/matterbridge/matterbridge.toml
%{_unitdir}/matterbridge.service
%{_bindir}/matterbridge


%changelog
