File VictoriaLogs.spec of Package VictoriaLogs

#
# spec file for package VictoriaLogs
#
# Copyright (c) 2022 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 apps_to_build victoria-logs vlagent vlogscli

Name:           VictoriaLogs
Version:        1.37.2
Release:        0
Summary:        Fast and easy to use database for logs, which can efficiently handle terabytes of logs
License:        Apache-2.0
URL:            https://github.com/VictoriaMetrics/VictoriaLogs
Source0:        https://github.com/VictoriaMetrics/VictoriaLogs/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        victoria-logs.service
Source2:        victoria-logs-user.conf
BuildRequires:  golang(API) >= 1.25
BuildRequires:  go >= 1.25.2
BuildRequires:  golang-packaging
BuildRequires:  systemd-rpm-macros
BuildRequires:  sysuser-tools
BuildRequires:  xz
%sysusers_requires
%systemd_ordering

%description
VictoriaLogs is a fast easy to use database for logs.

Both the single-node and the cluster versions of VictoriaLogs are open source and free to use.



%prep
%autosetup -p1

%build
%sysusers_generate_pre %{SOURCE2} victoria-logs victoria-logs-user.conf
for i in %{apps_to_build}; do
  go build -mod=vendor -buildmode=pie -ldflags="-X 'github.com/VictoriaMetrics/VictoriaMetrics/lib/buildinfo.Version=${i}-%{version}'" -o $i ./app/$i
done

%check
for i in %{apps_to_build}; do
./$i -version
done

%pre -f victoria-logs.pre
%service_add_pre victoria-logs.service

%preun
%service_del_preun victoria-logs.service

%post
%service_add_post victoria-logs.service

%postun
%service_del_postun victoria-logs.service

%install
install -D -m 0755 -t %{buildroot}%{_sbindir} %{apps_to_build}
mkdir -p %{buildroot}%{_localstatedir}/lib/victoria-logs
install -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/victoria-logs.service
install -D -m 0644 %{SOURCE2} %{buildroot}%{_sysusersdir}/victoria-logs-user.conf

%files
%license LICENSE
%doc CODE_OF_CONDUCT.md CONTRIBUTING.md README.md
%{_sbindir}/*
%{_unitdir}/victoria-logs.service
%{_sysusersdir}/victoria-logs-user.conf
%attr(0755, victoria-logs, victoria-logs) %dir %{_localstatedir}/lib/victoria-logs

%changelog
openSUSE Build Service is sponsored by