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

Name:		mattermost-plugin-rssfeed
Version:	0.2.0
Release:	1%{?dist}
URL:            https://github.com/wbernest/mattermost-plugin-rssfeed
Summary:	Plugin for Mattermost and RSS feed
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/wbernest/
cd src/github.com/wbernest/
git clone https://github.com/wbernest/mattermost-plugin-rssfeed


%build
export GOPATH=`pwd`
export PATH="bin:"$PATH
export GO111MODULE=on
cd src/github.com/wbernest/mattermost-plugin-rssfeed
pushd server
#$GOPATH/bin/dep ensure
#pushd vendor/github.com/mattermost/
#rm -rf mattermost-server
#git clone https://github.com/mattermost/mattermost-server
#popd
go build -ldflags '-extldflags -s -w -buildid %{version}' -o plugin.exe
popd


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


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


%changelog
