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

Name:		mattermost-plugin-bigbluebutton
Version:	2.2.0
Release:	1%{?dist}
URL:            https://github.com/Salatfreak/mattermost-plugin-bigbluebutton
Summary:	BigBlueButton plugin for Mattermost
License:	Apache
BuildRequires:	golang
Requires:	mattermost


%description


%prep
%setup -q -T -c %{name}-%{version}
export GOPATH=`pwd`
go get -u -v github.com/pkg/errors
go get -u -v github.com/robfig/cron
go get -u -v github.com/segmentio/ksuid
mkdir -p src/github.com/blindsidenetworks/
pushd src/github.com/blindsidenetworks/
git clone https://github.com/blindsidenetworks/mattermost-plugin-bigbluebutton
popd
mkdir -p src/github.com/mattermost/
pushd src/github.com/mattermost/
git clone https://github.com/mattermost/mattermost-server
popd


%build
export GOPATH=`pwd`
export PATH="bin:"$PATH
cd src/github.com/blindsidenetworks/mattermost-plugin-bigbluebutton
pushd webapp
npm install
npm run build
popd
go build -o plugin.exe ./server


%install
mkdir -p %{buildroot}%{mattermost_home}/plugins/bigbluebutton/{server,webapp}
cp -rv src/github.com/blindsidenetworks/mattermost-plugin-bigbluebutton/plugin.json %{buildroot}%{mattermost_home}/plugins/bigbluebutton/
cp -rv src/github.com/blindsidenetworks/mattermost-plugin-bigbluebutton/plugin.exe %{buildroot}%{mattermost_home}/plugins/bigbluebutton/server/
cp -rv src/github.com/blindsidenetworks/mattermost-plugin-bigbluebutton/webapp/dist/bigbluebutton_bundle.js %{buildroot}%{mattermost_home}/plugins/bigbluebutton/webapp/


%files
%{mattermost_home}/plugins/bigbluebutton/plugin.json
%{mattermost_home}/plugins/bigbluebutton/server/plugin.exe
%{mattermost_home}/plugins/bigbluebutton/webapp/bigbluebutton_bundle.js


%changelog
