%global debug_package %{nil}

Summary:    Robust, reliable open-source gopher server
Name:       motsognir
Version:    1.0.13
Release:    1%{?dist}
License:    GPLv3
URL:        http://motsognir.sourceforge.net/
Source0:    https://sourceforge.net/projects/%{name}/files/v%{version}/%{name}-%{version}.tar.xz/download#/%name-%version.tar.xz
Source1:    %{name}.service
Source2:    %{name}@.service
Source3:    %{name}.readme

# Change paths to suit multiple config files (virtual host)
Patch0:     %{name}-%{version}-paths.patch

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

%description
The Motsognir gopher server is meant to be used for small projects
(like home servers), but should scale well on bigger architectures as well.
All the configuration is done via a single configuration file, which has very
reasonable defaults. That makes Motsognir easily maintainable, and allows the
administrator to have a full knowledge of what features are allowed/enabled on
the server, and what's not. Motsognir supports server-side CGI applications
and PHP scripts, is plainly compatible with UTF-8 filesystems, and is entirely
written in ANSI C without external dependencies.

%prep
%autosetup -p1

%build
%make_build

%install
%make_install
install -d $RPM_BUILD_ROOT/%{_var}/gopher

# We are not using old init.d style script
mkdir -p $RPM_BUILD_ROOT/%{_unitdir}
cp %SOURCE1 %SOURCE2 $RPM_BUILD_ROOT/%{_unitdir}
cp %SOURCE3 README.RHEL.Fedora

%post
%systemd_post motsognir.service
%systemd_post motsognir@\*.service

%preun
%systemd_preun motsognir.service
%systemd_preun motsognir@\*.service

%postun
%systemd_postun_with_restart motsognir.service
%systemd_postun_with_restart motsognir@\*.service

%files
%doc motsognir.conf motsognir-extmap.conf changes.txt manual.pdf README*
%dir %attr(0750,root,root) %{_sysconfdir}/%{name}
%config(noreplace) %attr(0640,root,root) %{_sysconfdir}/%{name}/%{name}.conf
%{_sbindir}/%{name}
%{_mandir}/man?/%{name}*
%{_unitdir}/%{name}*
%dir %attr(0755,root,root) %{_var}/gopher

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

* Sat Aug 08 2020 Greg Wildman <greg@techno.co.za> - 1.0.12-2
- Add systemd boilerplate to handle services

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