%define mattermost_user mattermost
%define mattermost_group mattermost
%define mattermost_home /var/lib/mattermost
%define debug_package %{nil}
%define mp3wasmversion 0.1.6

Name:		mattermost-plugin-skype4business
Version:	0.1.2
Release:	1%{?dist}
URL:            https://github.com/streamer45/mattermost-plugin-voice
Summary:	Plugin for Mattermost for Voice Messaging
License:	MIT
BuildRequires:	golang
Requires:	mattermost


%description


%prep
%setup -q -T -c %{name}-%{version}
export GOPATH=`pwd`
go get -u -v github.com/golang/dep/cmd/dep
mkdir -p src/github.com/mattermost/
cd src/github.com/mattermost/
git clone https://github.com/mattermost/mattermost-plugin-skype4business


%build
export GOPATH=`pwd`
export PATH="bin:"$PATH
export GO111MODULE=on
cd src/github.com/mattermost/mattermost-plugin-skype4business
go mod download
go build -ldflags '-extldflags -s -w -buildid %{version}' -o plugin.exe ./server
pushd webapp
npm install
npm run build
popd


%install
mkdir -p %{buildroot}%{mattermost_home}/plugins/skype4business/{server,webapp}/dist/
cp -rv src/github.com/mattermost/mattermost-plugin-skype4business/plugin.json %{buildroot}%{mattermost_home}/plugins/skype4business/
sed 's/"executables": {/"executables": { "server\/dist\/plugin.exe"/' -i %{buildroot}%{mattermost_home}/plugins/skype4business/plugin.json
sed '/"darwin-amd64"/d' -i %{buildroot}%{mattermost_home}/plugins/skype4business/plugin.json
sed '/"linux-amd64"/d' -i %{buildroot}%{mattermost_home}/plugins/skype4business/plugin.json
sed '/"windows-amd64"/d' -i %{buildroot}%{mattermost_home}/plugins/skype4business/plugin.json
cp -rv src/github.com/mattermost/mattermost-plugin-skype4business/plugin.exe %{buildroot}%{mattermost_home}/plugins/skype4business/server/dist/
cp -rv src/github.com/mattermost/mattermost-plugin-skype4business/webapp/dist/main.js %{buildroot}%{mattermost_home}/plugins/skype4business/webapp/dist/


%files
%{mattermost_home}/plugins/skype4business/plugin.json
%{mattermost_home}/plugins/skype4business/server/dist/plugin.exe
%{mattermost_home}/plugins/skype4business/webapp/dist/main.js


%changelog
