%global _hardened_build 1

Name         : mercury
Version      : 20220601
Release      : 1%{dist}
License      : MIT
URL          : https://github.com/kgaughan/mercury
Summary      : A Planet-style feed aggregator
Source0      : mercury@.service
Source1      : mercury@.timer
BuildRequires: golang
BuildRequires: git
Requires     : git


%description
Mercury is intended a replacement for Sam Ruby's Planet Venus.
A planet is a kind of feed aggregator.
It takes a list of newsfeeds (Atom, RSS, &c.), splices them together, and spits a set of HTML pages and/or a feed.


%prep
%setup -T -q -c %{name}-%{version}
export GOPATH=`pwd`
mkdir -p go/src/github.com/kgaughan
cd go/src/github.com/kgaughan
git clone https://github.com/kgaughan/mercury


%build
export GOPATH=`pwd`
export GO111MODULE=on
cd go/src/github.com/kgaughan/mercury
go build -v -ldflags "-extldflags -s -w -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -buildid "%{version}" -X 'main.Version="%{version}"' -X 'main.MakeVersion="%{release}"'"


%install
install -p -D -m 0644 %{SOURCE0} %{buildroot}%{_unitdir}/mercury@.service
install -p -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/mercury@.timer
mkdir -p %{buildroot}/%{_sysconfdir}/%{name}/
install -p -D -m 0644 go/src/github.com/kgaughan/mercury/mercury.toml %{buildroot}%{_sysconfdir}/%{name}/config.toml
cp -rv go/src/github.com/kgaughan/mercury/theme/ %{buildroot}%{_sysconfdir}/%{name}/theme/
install -p -D -m 0555 go/src/github.com/kgaughan/mercury/mercury %{buildroot}%{_bindir}/mercury


%post
%systemd_post mercury@.service


%preun
%systemd_preun mercury@.service


%postun
%systemd_postun mercury@.service


%files
%config(noreplace) %{_sysconfdir}/%{name}/config.toml
%config(noreplace) %{_sysconfdir}/%{name}/theme/
%{_bindir}/mercury
%{_unitdir}/mercury@.service
%{_unitdir}/mercury@.timer


%changelog
