File fluent-bit.spec of Package fluent-bit

#
# spec file for package fluent-bit
#
# Copyright (c) 2023 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/
#


%define _distconfdir %{_prefix}%{_sysconfdir}
Name:           fluent-bit
Version:        4.0.3
Release:        0
Summary:        Fast data collector for Linux
License:        Apache-2.0
Group:          System/Daemons
URL:            https://fluentbit.io/
Source0:        https://github.com/fluent/%{name}/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        fluent-bit.service
BuildRequires:  bison >= 3
BuildRequires:  cmake >= 3.20
BuildRequires:  flex
BuildRequires:  gcc-c++
BuildRequires:  git
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(cunit)
BuildRequires:  pkgconfig(jansson)
BuildRequires:  pkgconfig(libcares)
BuildRequires:  pkgconfig(libevent)
BuildRequires:  pkgconfig(liblzma)
BuildRequires:  pkgconfig(libnghttp2)
BuildRequires:  pkgconfig(libpq)
BuildRequires:  pkgconfig(libsystemd)
BuildRequires:  pkgconfig(libxml-2.0)
BuildRequires:  pkgconfig(luajit)
BuildRequires:  pkgconfig(openssl) >= 1.1.1
BuildRequires:  pkgconfig(rdkafka)
BuildRequires:  pkgconfig(yaml-0.1)
BuildRequires:  pkgconfig(zlib)
%if 0%{?suse_version} >= 1600
BuildRequires:  execstack
BuildRequires:  pkgconfig(libnghttp3)
BuildRequires:  pkgconfig(libngtcp2)
%endif
%ifnarch ppc %{arm}
BuildRequires:  pkgconfig(jemalloc)
%endif

%description
Fluent Bit is a high performance and multi platform Log Forwarder.

%prep
%setup -q

%build
##
## build ####################################################
##
%cmake \
    -DFLB_ALL=On\
    -DFLB_PREFER_SYSTEM_LIBS=On\
    -DFLB_RELEASE=On\
    -DFLB_SECURITY=On\
    -DFLB_SHARED_LIB=Off\
    -DFLB_WASM_STACK_PROTECT=On
%cmake_build

%install
##
## install ##################################################
##
%cmake_install

install -d -m755 %{buildroot}%{_bindir}/
install -d -m755 %{buildroot}%{_sysconfdir}/%{name}
install -d -m755 %{buildroot}%{_unitdir}

install -c -m644 %{SOURCE1} %{buildroot}%{_unitdir}/fluent-bit.service

install -D -m 0644 %{buildroot}%{_distconfdir}/%{name}/fluent-bit.conf %{buildroot}%{_sysconfdir}/%{name}/fluent-bit.conf
install -D -m 0644 %{buildroot}%{_distconfdir}/%{name}/parsers.conf %{buildroot}%{_sysconfdir}/%{name}/parsers.conf
install -D -m 0644 %{buildroot}%{_distconfdir}/%{name}/plugins.conf %{buildroot}%{_sysconfdir}/%{name}/plugins.conf

install -d -m755 %{buildroot}%{_sbindir}/
ln -s service %{buildroot}%{_sbindir}/rc%{name}

# remove unnecessary "Installed (but unpackaged) file(s)"
rm  -rf %{buildroot}%{_includedir}
rm  %{buildroot}%{_distconfdir}/%{name}/%{name}.conf
rm  %{buildroot}%{_distconfdir}/%{name}/parsers.conf
rm  %{buildroot}%{_distconfdir}/%{name}/plugins.conf
%if 0%{?suse_version} > 1500
    rm %{buildroot}/lib/systemd/system/fluent-bit.service
%endif
# Fix rpmlint issue with executable stack in TW
%if 0%{?suse_version} >= 1600
    execstack -c %{buildroot}%{_bindir}/%{name}
%endif

%preun
%service_del_preun fluent-bit.service

%postun
%service_del_postun fluent-bit.service

%pre
%service_add_pre fluent-bit.service

%post
%service_add_post fluent-bit.service

%files
##
## file list ################################################
##
%{_sbindir}/rcfluent-bit
%{_bindir}/fluent-bit
%{_unitdir}/fluent-bit.service
%dir %{_sysconfdir}/fluent-bit
%config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
%config(noreplace) %{_sysconfdir}/%{name}/parsers.conf
%config(noreplace) %{_sysconfdir}/%{name}/plugins.conf

%changelog
openSUSE Build Service is sponsored by