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

Name:		mattermost-plugin-matterpoll
Version:	1.0.3
Release:	1%{?dist}
Summary:	Plugin for Mattermost and Github
License:	Apache
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/matterpoll/
cd src/github.com/matterpoll/
git clone https://github.com/matterpoll/matterpoll


%build
export GOPATH=`pwd`
export PATH="bin:"$PATH
cd src/github.com/matterpoll/matterpoll
pushd server
$GOPATH/bin/dep ensure
popd
go build -o plugin.exe ./server


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



%files
%{mattermost_home}/plugins/matterpoll/plugin.json
%{mattermost_home}/plugins/matterpoll/server/plugin.exe

%changelog
