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

Name:		mattermost-plugin-jitsi
Version:	1.0.1
Release:	1%{?dist}
Summary:	Plugin for Mattermost and Jitsi
License:	Apache
BuildRequires:	golang
Requires:	mattermost


%description


%prep
%setup -q -T -c %{name}-%{version}
export GOPATH=`pwd`
mkdir -p src/github.com/seansackowitz/
cd src/github.com/seansackowitz/
git clone https://github.com/seansackowitz/mattermost-plugin-jitsi


%build
export GOPATH=`pwd`
export PATH="bin:"$PATH
cd src/github.com/seansackowitz/mattermost-plugin-jitsi
#git checkout tags/v%{version}
pushd webapp
npm install
npm run build
popd
pushd server
go get github.com/Masterminds/glide
$GOPATH/bin/glide install
pushd vendor/github.com/mattermost/
rm -rf mattermost-server
git clone https://github.com/mattermost/mattermost-server
popd
popd
go build -o plugin.exe ./server


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


%files
%{mattermost_home}/plugins/jitsi/plugin.json
%{mattermost_home}/plugins/jitsi/server/plugin.exe
%{mattermost_home}/plugins/jitsi/webapp/jitsi_bundle.js


%changelog
