File logfanoutd.spec of Package logfanoutd

#
# spec file for package logfanoutd
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


Name:           logfanoutd
Version:        0.2.4
Release:        0
Summary:        Simple log fanout HTTP server
License:        GPL-3.0-only
Group:          Productivity/Networking/Web/Servers
URL:            https://github.com/matwey/logfanoutd.git
Source:         logfanoutd-%{version}.tar.xz
BuildRequires:  check-devel >= 0.9.9
BuildRequires:  cmake >= 3.6
BuildRequires:  gcc
BuildRequires:  libcurl-devel
BuildRequires:  libmicrohttpd-devel >= 0.9.0
BuildRequires:  make
BuildRequires:  pkg-config
%if 0%{?suse_version} >= 1210
BuildRequires:  systemd-devel
BuildRequires:  pkgconfig(systemd)
%{?systemd_requires}
%endif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
logfanoutd is a simple HTTP server able to handle range requests as per RFC7233 powered by libmicrohttpd library.
Conventional text log file can be thought as of persistent message queue and then HTTP range requests can be used as mechanism of message consumption relying on client performance.
Range requests allow the multiple remote clients to fetch existing log file as well as to continuously request newly appended data with the pace which the client wishes.
Using libmicrohttpd allows to achieve low resource requirements for the server application.

%prep
%autosetup -p1

%build
%cmake
%cmake_build

%install
%cmake_install

%if 0%{?suse_version} >= 1210
%__install -D -m 0644 ./%{name}.service %{buildroot}%{_unitdir}/%{name}.service
%__install -D -m 0644 ./%{name}.socket %{buildroot}%{_unitdir}/%{name}.socket
mkdir -p %{buildroot}%{_sbindir}
ln -s /sbin/service %{buildroot}%{_sbindir}/rc%{name}
%endif

%check
%ctest

%if 0%{?suse_version} >= 1210
%pre
%service_add_pre %{name}.service %{name}.socket

%post
%service_add_post %{name}.service %{name}.socket

%preun
%service_del_preun %{name}.service %{name}.socket

%postun
%service_del_postun %{name}.service %{name}.socket
%endif

%files
%defattr(-,root,root)
%doc README.md LICENSE
%{_bindir}/logfanoutd
%if 0%{?suse_version} >= 1210
%{_unitdir}/%{name}.service
%{_unitdir}/%{name}.socket
%{_sbindir}/rc%{name}
%endif

%changelog
openSUSE Build Service is sponsored by