%global debug_package %{nil}

Summary:    A mini gopher server
Name:       mgod
Version:    1.1
Release:    1%{?dist}
License:    GPLv3
URL:        https://port70.net/
Source0:    https://port70.net/?9mgod/%{name}-%{version}.tar.gz
Source1:    mgod.socket
Source2:    mgod@.service
Source3:    mgod.sysconfig

%{?systemd_requires}
BuildRequires:    systemd
BuildRequires:    gcc
BuildRequires:    ctags

%description
A mini gopher server. Written in C, no dependencies, no fuss.
A CGI-based HTTP gateway is also provided (also in C;
calls the mgod executable directly, no networking).

%prep
%autosetup

%build
%make_build

%install
install -D -m 0644 %SOURCE3 $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/%{name}
install -D -m 0755 %{name} $RPM_BUILD_ROOT/%{_sbindir}/%{name}
install -d $RPM_BUILD_ROOT/%{_unitdir}
install -m 0644 %SOURCE1 %SOURCE2 $RPM_BUILD_ROOT/%{_unitdir}/
install -d $RPM_BUILD_ROOT/%{_var}/gopher

%post
%systemd_post mgod.socket

%preun
%systemd_preun mgod.socket

%postun
%systemd_postun_with_restart mgod.socket

%files
%doc README COPYING
%{_sysconfdir}/sysconfig/%{name}
%{_sbindir}/%{name}
%{_unitdir}/%{name}*
%dir %attr(0755,root,root) %{_var}/gopher

%changelog
* Sat Aug 08 2020 Greg Wildman <greg@techno.co.za> - 1.1-1
- Initial spec.