From ec1e6aa230e81c4305b634b7d3ebc59468087fc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20F=C3=B6rster?= Date: Fri, 28 Nov 2025 13:45:03 +0100 Subject: [PATCH] [app-admin/loki] interim version, not really tested. --- app-admin/loki/Manifest | 1 + app-admin/loki/files/loki.confd | 5 +++ app-admin/loki/files/loki.initd | 11 ++++++ app-admin/loki/files/loki.service | 17 ++++++++ app-admin/loki/loki-2.9.10.ebuild | 65 +++++++++++++++++++++++++++++++ app-admin/loki/metadata.xml | 14 +++++++ 6 files changed, 113 insertions(+) create mode 100644 app-admin/loki/Manifest create mode 100644 app-admin/loki/files/loki.confd create mode 100644 app-admin/loki/files/loki.initd create mode 100644 app-admin/loki/files/loki.service create mode 100644 app-admin/loki/loki-2.9.10.ebuild create mode 100644 app-admin/loki/metadata.xml diff --git a/app-admin/loki/Manifest b/app-admin/loki/Manifest new file mode 100644 index 0000000..2430ac9 --- /dev/null +++ b/app-admin/loki/Manifest @@ -0,0 +1 @@ +DIST loki-2.9.10.tar.gz 46118052 BLAKE2B 44543f1df61b47e5815251ac05e6b4bdbfee86f39f6f4ecfcb122e9d4eb631b581890a67f68a43c272695ab493707de76d47289aab87078eb08f7b37403fc6ba SHA512 d9c1bbdbd7c04de6ea61de269a3eeb015e1342cfef5567b91a04324f586ce16d24462a9fe56b8c5c1376b677da229768653b41623b092aa4ca6a057d4667edfe diff --git a/app-admin/loki/files/loki.confd b/app-admin/loki/files/loki.confd new file mode 100644 index 0000000..850fa53 --- /dev/null +++ b/app-admin/loki/files/loki.confd @@ -0,0 +1,5 @@ +# The loki config file +LOKI_CONF="/etc/loki/loki-local-config.yaml" + +# Add any extra options to pass to loki to this setting. +#LOKI_OPTS="" diff --git a/app-admin/loki/files/loki.initd b/app-admin/loki/files/loki.initd new file mode 100644 index 0000000..dd5bd96 --- /dev/null +++ b/app-admin/loki/files/loki.initd @@ -0,0 +1,11 @@ +#!/sbin/openrc-run + +configfile="${LOKI_CONF:-/etc/loki/loki-local-config.yaml}" + +command=/usr/bin/loki +command_args="-config.file=${configfile} + ${LOKI_OPTS}" +command_background=yes +command_user=loki:grafana +make_pidfile=yes +pidfile=/var/run/loki.pid diff --git a/app-admin/loki/files/loki.service b/app-admin/loki/files/loki.service new file mode 100644 index 0000000..83abce5 --- /dev/null +++ b/app-admin/loki/files/loki.service @@ -0,0 +1,17 @@ +[Unit] +Description=Loki +Wants=network-online.target +After=network-online.target + +[Service] +User=loki +Group=grafana +Type=simple +Restart=on-failure +EnvironmentFile=/etc/conf.d/loki +Environment=LOKI_CONF=/etc/loki/loki-local-config.yaml +ExecStart=/usr/bin/loki -config.file=${LOKI_CONF} ${LOKI_OPTS} +PIDFile=/run/loki.pid + +[Install] +WantedBy=multi-user.target diff --git a/app-admin/loki/loki-2.9.10.ebuild b/app-admin/loki/loki-2.9.10.ebuild new file mode 100644 index 0000000..72cd95c --- /dev/null +++ b/app-admin/loki/loki-2.9.10.ebuild @@ -0,0 +1,65 @@ +# Copyright 1999-2025 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit go-module systemd + +DESCRIPTION="Like Prometheus, but for logs." +HOMEPAGE="https://grafana.com/loki" +SRC_URI="https://github.com/grafana/loki/archive/v${PV}.tar.gz -> ${P}.tar.gz" + +LICENSE="Apache-2.0" +SLOT="0" +KEYWORDS="~amd64" + +IUSE="+server tools systemd" + +RESTRICT="mirror strip" + +RDEPEND="acct-group/grafana + acct-user/${PN}" +DEPEND="${RDEPEND}" + +src_compile() { + BUILD_VERSION="${PV}" + BUILD_REVISION="${PV}" + BUILD_USER="${P}" + BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` + + VPREFIX="github.com/grafana/${PN}/vendor/github.com/prometheus/common/version" + + EGO_LDFLAGS="-s -w -X ${VPREFIX}.Version=${BUILD_VERSION} -X ${VPREFIX}.Revision=${BUILD_REVISION} -X ${VPREFIX}.BuildUser=${BUILD_USER} -X ${VPREFIX}.BuildDate=${BUILD_DATE}" + + if use server; then + einfo "Building cmd/${PN}/${PN}..." + CGO_ENABLED=0 go build -ldflags "-extldflags \"-static\" ${EGO_LDFLAGS}" -tags netgo -mod vendor -o cmd/${PN}/${PN} ./cmd/${PN} || die + fi + if use tools; then + einfo "Building cmd/logcli/logcli..." + CGO_ENABLED=0 go build -ldflags "-extldflags \"-static\" ${EGO_LDFLAGS}" -tags netgo -mod vendor -o cmd/logcli/logcli ./cmd/logcli || die + einfo "Building cmd/${PN}-canary/${PN}-canary..." + CGO_ENABLED=0 go build -ldflags "-extldflags \"-static\" ${EGO_LDFLAGS}" -tags netgo -mod vendor -o cmd/${PN}-canary/${PN}-canary ./cmd/${PN}-canary || die + fi +} + +src_install() { + if use server; then + dobin "${S}/cmd/${PN}/${PN}" + + newconfd "${FILESDIR}/${PN}.confd" "${PN}" + newinitd "${FILESDIR}/${PN}.initd" "${PN}" + use systemd && systemd_newunit "${FILESDIR}"/${PN}.service ${PN}.service + + insinto "/etc/${PN}" + doins "${S}/cmd/${PN}/${PN}-local-config.yaml" + keepdir "/etc/${PN}" + keepdir "/var/lib/${PN}" + fowners ${PN}:grafana "/etc/${PN}" + fowners ${PN}:grafana "/var/lib/${PN}" + fi + if use tools; then + dobin "${S}/cmd/logcli/logcli" + dobin "${S}/cmd/${PN}-canary/${PN}-canary" + fi +} diff --git a/app-admin/loki/metadata.xml b/app-admin/loki/metadata.xml new file mode 100644 index 0000000..6bff9f1 --- /dev/null +++ b/app-admin/loki/metadata.xml @@ -0,0 +1,14 @@ + + + + + Build the fluent-bit plugin to publish from app-admin/fluent-bit + Build the promtail log gathering agent + Build the loki server + Build the loki tools logcli and loki-canary + + + grafana/loki + + \ No newline at end of file