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

Name:		mattermost-plugin-statuspage
Version:	0.0.7
Release:	1%{?dist}
URL:            https://github.com/cpanato/mattermost-plugin-statuspage
Summary:	Plugin for Mattermost and StatusPage
License:	Apache
Patch1:		mattermost-plugin-github-arch-make.patch
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/cpanato/
cd src/github.com/cpanato/
#git clone https://github.com/mattermost/mattermost-server
#git clone https://github.com/mattermost/mattermost-webapp
git clone https://github.com/cpanato/mattermost-plugin-statuspage
#%patch1 -p0


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


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


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

%changelog
