%define debug_package %{nil}

Name		: ergo
Version		: 2.7.0
Release		: 1%{?dist}
Summary		: A modern IRC server (daemon/ircd) written in Go
Group		: System/Web
License		: MIT License
URL		: https://gohugo.io/
Source0		: ergo.service
BuildRequires	: golang
BuildRequires	: git
Requires	: git

%description


%prep
%setup -T -q -c %{name}-%{version}
mkdir -p go/src/github.com/ergochat/
cd go/src/github.com/ergochat/
git clone https://github.com/ergochat/ergo


%build
export GOPATH=`pwd`/go
export GO111MODULE=on
cd go/src/github.com/ergochat/ergo
git checkout tags/v%{version}
export SHORTCOMMIT=$(git rev-parse --short HEAD)
export BUILDDATE=$(date +%Y%m%d)
%ifarch ppc64
export CGO_ENABLED=1
%endif
go build -v -ldflags "-extldflags -s -w -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -buildid "%{version}" -X 'main.commit="$SHORTCOMMIT"'" -o ergo
%ifarch ppc64
unset CGO_ENABLED
%endif


%install
install -p -D -m 0555 go/src/github.com/ergochat/ergo/ergo %{buildroot}%{_bindir}/ergo
install -p -D -m 0644 go/src/github.com/ergochat/ergo/default.yaml %{buildroot}%{_sysconfdir}/ergo/ircd.yaml
install -p -D -m 0644 %{SOURCE0} %{buildroot}%{_unitdir}/ergo.service


%post
%systemd_post ergo.service


%preun
%systemd_preun ergo.service


%postun
%systemd_postun ergo.service


%files
%doc
%{_bindir}/ergo
%{_sysconfdir}/ergo/ircd.yaml
%{_unitdir}/ergo.service


%changelog
