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

Name:		mattermost-plugin-remind
Version:	0.4.4
Release:	1%{?dist}
URL:            https://github.com/scottleedavis/mattermost-plugin-remind/
Summary:	Plugin for Mattermost and Remind
License:	Apache
BuildRequires:	golang
Requires:	mattermost


%description


%prep
%setup -q -T -c %{name}-%{version}
export GOPATH=`pwd`
go get -u -v github.com/gorilla/mux
mkdir -p src/github.com/mattermost/
mkdir -p src/github.com/scottleedavis/
pushd src/github.com/mattermost
git clone https://github.com/mattermost/mattermost-server
popd
pushd src/github.com/scottleedavis/
git clone https://github.com/scottleedavis/mattermost-plugin-remind
popd



%build
export GOPATH=`pwd`
export PATH="bin:"$PATH
cd src/github.com/scottleedavis/mattermost-plugin-remind
go build -o plugin.exe ./server


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


%files
%{mattermost_home}/plugins/com.github.scottleedavis.mattermost-plugin-remind/plugin.json
%{mattermost_home}/plugins/com.github.scottleedavis.mattermost-plugin-remind/server/plugin.exe
%{mattermost_home}/plugins/com.github.scottleedavis.mattermost-plugin-remind/assets/


%changelog
