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

Name:		mattermost-plugin-memes
Version:	1.0.0
Release:	1%{?dist}
Summary:	Plugin for Mattermost to have Memes
License:	Apache
BuildRequires:	golang
Requires:	mattermost


%description


%prep
%setup -q -T -c %{name}-%{version}
export GOPATH=`pwd`
mkdir -p src/github.com/mattermost/
cd src/github.com/mattermost/
git clone https://github.com/mattermost/mattermost-server
git clone https://github.com/mattermost/mattermost-webapp
git clone https://github.com/mattermost/mattermost-plugin-memes
sed -i 's|darwin/amd64 linux/amd64 windows/amd64|linux/amd64 linux/ppc64 linux/ppc64le|' mattermost-plugin-memes/Makefile
sed -i '/tar -czvf dist\/mattermost-memes-plugin-darwin-amd64.tar.gz/d' mattermost-plugin-memes/Makefile
sed -i '/tar -czvf dist\/mattermost-memes-plugin-linux-amd64.tar.gz/d' mattermost-plugin-memes/Makefile
sed -i '/tar -czvf dist\/mattermost-memes-plugin-windows-amd64.tar.gz/d' mattermost-plugin-memes/Makefile
sed -i '/rm -rf dist\/intermediate/d' mattermost-plugin-memes/Makefile


%build
export GOPATH=`pwd`
export PATH="bin:"$PATH
cd src/github.com/mattermost/mattermost-plugin-memes
make


%install
mkdir -p %{buildroot}%{mattermost_home}/plugins/memes/
cp -rv src/github.com/mattermost/mattermost-plugin-memes/dist/intermediate/* %{buildroot}%{mattermost_home}/plugins/memes/
cp -rv src/github.com/mattermost/mattermost-plugin-memes/plugin.yaml %{buildroot}%{mattermost_home}/plugins/memes/
sed -i 's/plugin.exe/plugin_linux_amd64/' %{buildroot}%{mattermost_home}/plugins/memes/plugin.yaml


%files
%{mattermost_home}/plugins/memes/plugin.yaml
%{mattermost_home}/plugins/memes/plugin_linux_amd64
%{mattermost_home}/plugins/memes/plugin_linux_ppc64
%{mattermost_home}/plugins/memes/plugin_linux_ppc64le

%changelog
