%global debug_package %{nil}

Summary:    Modern full-featured (and hopefully) secure gopher daemon
Name:       gophernicus
Version:    3.1.1
Release:    1%{?dist}
License:    BSD
URL:        https://github.com/gophernicus/gophernicus
Source0     https://github.com/gophernicus/gophernicus/archive/v%{version}.tar.gz#/%name-%version.tar.gz

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

%description
Modern full-featured (and hopefully) secure gopher daemon.

%prep
%autosetup 
./configure --prefix=%{_prefix} \
            --bindir=%{_bindir} \
            --sbindir=%{_sbindir} \
            --mandir=%{_mandir} \
            --listener=systemd

%build
%make_build

%install
# Makefile installs to system directly. We wil do it manually
install -D -m 0644 init/%{name}.env $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/%{name}
install -D -m 0755 src/%{name} $RPM_BUILD_ROOT/%{_sbindir}/%{name}
install -D -m 0644 gophermap.sample $RPM_BUILD_ROOT/%{_var}/gopher/gophermap
install -d $RPM_BUILD_ROOT/%{_unitdir}
install -m 0644 init/%{name}.socket init/%{name}@.service $RPM_BUILD_ROOT/%{_unitdir}/

%post
%systemd_post gophernicus.socket

%preun
%systemd_preun gophernicus.socket

%postun
%systemd_postun_with_restart gophernicus.socket

%files
%license LICENSE
%doc README.* INSTALL.md changelog
%{_sysconfdir}/sysconfig/%{name}
%{_sbindir}/%{name}
%{_unitdir}/%{name}*
%dir %attr(0755,root,root) %{_var}/gopher
%config %{_var}/gopher/gophermap

%changelog
* Tue Apr 05 2022 Greg Wildman <greg@techno.co.za> - 3.1.1-1
- Update version

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