# # spec file for package loki # # Copyright (c) 2021 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: loki Version: 2.2.1+git.1617669398.babea82e Release: 0 Summary: Loki: like Prometheus, but for logs. License: Apache-2.0 Group: System/Monitoring URL: https://grafana.com/loki Source: %{name}-%{version}.tar.bz2 Source1: loki.service Source2: promtail.service Source3: sysconfig.loki Source4: sysconfig.promtail BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: golang-packaging BuildRequires: systemd-devel BuildRequires: golang(API) >= 1.15 Requires: group(loki) Requires: user(loki) Requires(post): %fillup_prereq %systemd_ordering %{go_nostrip} %description Loki is a horizontally-scalable, highly-available, multi-tenant log aggregation system inspired by Prometheus. This package contains the Loki server %package -n promtail Summary: Promtail Client Group: System/Monitoring Requires: group(loki) Requires: user(loki) %description -n promtail Loki is a horizontally-scalable, highly-available, multi-tenant log aggregation system inspired by Prometheus. This package contains the Promtail client. %prep %setup -q %{name}-%{version} %build %define buildpkg github.com/grafana/loki/pkg/build export CGO_ENABLED=0 export GOFLAGS="-mod=vendor -buildmode=pie -tags=netgo" export GOLDFLAGS="-s -w -X %{buildpkg}.Version=%{version} \ -X %{buildpkg}.Revision=%{release} \ -X %{buildpkg}.Branch=NA \ -X %{buildpkg}.BuildUser=NA \ -X %{buildpkg}.BuildDate=NA" go build -ldflags="$GOLDFLAGS" ./cmd/loki go build -ldflags="$GOLDFLAGS" ./cmd/logcli CGO_ENABLED=1 go build -ldflags="$GOLDFLAGS" ./cmd/promtail %install # Service files for Loki and promtail install -Dm644 %{SOURCE1} %{buildroot}%{_unitdir}/loki.service install -Dm644 %{SOURCE2} %{buildroot}%{_unitdir}/promtail.service install -Dm644 %{SOURCE3} %{buildroot}%{_fillupdir}/sysconfig.loki install -Dm644 %{SOURCE4} %{buildroot}%{_fillupdir}/sysconfig.promtail install -dm755 %{buildroot}%{_sbindir} ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcloki ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcpromtail # Config files install -Dm644 cmd/loki/loki-local-config.yaml \ %{buildroot}%{_sysconfdir}/loki/loki.yaml install -Dm644 cmd/promtail/promtail-local-config.yaml \ %{buildroot}%{_sysconfdir}/loki/promtail.yaml # Binaries install -dm755 %{buildroot}%{_bindir} install -Dm755 loki %{buildroot}%{_bindir} install -Dm755 promtail %{buildroot}%{_bindir} install -Dm755 logcli %{buildroot}%{_bindir} %pre %service_add_pre loki.service %post %fillup_only -n loki-server %service_add_post loki.service %preun %service_del_preun loki.service %postun %service_del_postun loki.service promtail.service %pre -n promtail %service_add_pre promtail.service %post -n promtail %fillup_only -n promtail %service_add_post promtail.service %preun -n promtail %service_del_preun promtail.service %postun -n promtail %service_del_postun promtail.service %files %license LICENSE %doc README.md %{_unitdir}/loki.service %{_fillupdir}/sysconfig.loki %{_bindir}/loki %{_bindir}/logcli %dir %{_sysconfdir}/loki %config(noreplace) %{_sysconfdir}/loki/loki.yaml %{_sbindir}/rcloki %files -n promtail %{_unitdir}/promtail.service %{_fillupdir}/sysconfig.promtail %{_bindir}/promtail %config(noreplace) %{_sysconfdir}/loki/promtail.yaml %{_sbindir}/rcpromtail %changelog