From 25fda6cdfceb122f90ec8b410d1b8fff073a9880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20F=C3=B6rster?= Date: Thu, 25 Sep 2025 10:44:07 +0200 Subject: [PATCH] [www-apps/grafana] add --- acct-group/grafana/Manifest | 1 + www-apps/grafana/Manifest | 4 + .../files/grafana-12.1.1-node-22.18.0.patch | 131 +++++++++++++++ www-apps/grafana/files/grafana.conf | 2 + www-apps/grafana/files/grafana.confd | 7 + www-apps/grafana/files/grafana.initd | 29 ++++ www-apps/grafana/files/grafana.service | 25 +++ www-apps/grafana/grafana-12.1.1.ebuild | 153 ++++++++++++++++++ 8 files changed, 352 insertions(+) create mode 100644 acct-group/grafana/Manifest create mode 100644 www-apps/grafana/Manifest create mode 100644 www-apps/grafana/files/grafana-12.1.1-node-22.18.0.patch create mode 100644 www-apps/grafana/files/grafana.conf create mode 100644 www-apps/grafana/files/grafana.confd create mode 100644 www-apps/grafana/files/grafana.initd create mode 100644 www-apps/grafana/files/grafana.service create mode 100644 www-apps/grafana/grafana-12.1.1.ebuild diff --git a/acct-group/grafana/Manifest b/acct-group/grafana/Manifest new file mode 100644 index 0000000..361d2ae --- /dev/null +++ b/acct-group/grafana/Manifest @@ -0,0 +1 @@ +EBUILD grafana-0.ebuild 187 BLAKE2B 65b45233eb369ff1b596d1e690ee49ab6cc8be002040638eca27b4efcf80d48b8f89f03f76ed9a52c093414c014d35d1c33c2fd0a6ad220826598c281f908255 SHA512 26ec5f315fcd362d5858e553c8bd03c41bd630979a070fc769cad3b0a85cdc83247a797b11fe46dca01946032c72c82babcb859c391c438baf88d4b9d2820c76 diff --git a/www-apps/grafana/Manifest b/www-apps/grafana/Manifest new file mode 100644 index 0000000..9986863 --- /dev/null +++ b/www-apps/grafana/Manifest @@ -0,0 +1,4 @@ +DIST grafana-12.1.1-vendor.tar.xz 57327732 BLAKE2B b384a1b2df8982c4ec350a249594cc9936d762b1376da63c37b05c8bf8cc4ab3c4896110c4b99da5bd65928cd82115ba5afdf0bbcbe354dc203883220bf4037d SHA512 721a9a0704e998d37abed7375cc48d9b3187bd578a64fa8bddfee00be079721a8aa9f6389738573fd3de5bcb3f5f7fc9dc1d743b8067ca3e749a51646ae45d5c +DIST grafana-12.1.1-vendor_yarn.tar.xz 314824256 BLAKE2B e5bf29d04e52a838c25624d50da4a0177ab918e95e027bd6ef4a7f55a25c6c77fc6a354d2d1364aa0467531b0cb9a0b47bc1019d136eeadbf6ee67b019fda9a2 SHA512 77dc62e64a41b48888842278ebd7fc6c45b83fc856d97300d5337bdf3365cd4e7489935567da5f85e294d3eb413ba9b7a60eb683debc39ea6ee424afbda4ed0f +DIST grafana-12.1.1.tar.gz 40131521 BLAKE2B c9a2507c1111402916bd0e0cb42816eb056ca6dd443c7a85651b8564d7ecb93aef90c26d96ac58973199d3e91cf813d7eadbc9d24690dcce25dc29f2cd29c226 SHA512 3df8b4ada36c490062759f7c157f9e5b203db4ca4d7002f2e347797dc0c528f499beec1a65782d91c85c04efbea28ecef43d6ba4bf85080bc4a4d7068ea02379 +DIST yarn-4.9.2.cjs 3005024 BLAKE2B b7d02b8ca523e48b4cd7430640acca2f81cce8737a5f14dabe7c8aae8584a4130edc72f997ca75ce010cae2739bb52a5fae47461102088311d2ef3b7e8625f8d SHA512 1fc009bc09d13cfd0e19efa44cbfc2b9cf6ca61482725eb35bbc5e257e093ebf4130db6dfe15d604ff4b79efd8e1e8e99b25fa7d0a6197c9f9826358d4d65c3c diff --git a/www-apps/grafana/files/grafana-12.1.1-node-22.18.0.patch b/www-apps/grafana/files/grafana-12.1.1-node-22.18.0.patch new file mode 100644 index 0000000..090b3db --- /dev/null +++ b/www-apps/grafana/files/grafana-12.1.1-node-22.18.0.patch @@ -0,0 +1,131 @@ +From 481caac25da9fcf329833a8730d0b43db486fe82 Mon Sep 17 00:00:00 2001 +From: Matt Cowley +Date: Wed, 9 Jul 2025 17:54:00 +0100 +Subject: [PATCH] Plugin Configs: Fix Env types (#107908) + +(cherry picked from commit 21f305c6a0e242463f5219cc6944fb880ea809f0) +--- + e2e/test-plugins/grafana-extensionstest-app/webpack.config.ts | 4 ++-- + e2e/test-plugins/grafana-test-datasource/webpack.config.ts | 4 ++-- + packages/grafana-plugin-configs/webpack.config.ts | 2 +- + public/app/plugins/datasource/azuremonitor/webpack.config.ts | 4 ++-- + .../datasource/grafana-pyroscope-datasource/webpack.config.ts | 4 ++-- + public/app/plugins/datasource/jaeger/webpack.config.ts | 4 ++-- + public/app/plugins/datasource/mssql/webpack.config.ts | 4 ++-- + 7 files changed, 13 insertions(+), 13 deletions(-) + +diff --git a/e2e/test-plugins/grafana-extensionstest-app/webpack.config.ts b/e2e/test-plugins/grafana-extensionstest-app/webpack.config.ts +index 6268c183d3553..564555396a5e4 100644 +--- a/e2e/test-plugins/grafana-extensionstest-app/webpack.config.ts ++++ b/e2e/test-plugins/grafana-extensionstest-app/webpack.config.ts +@@ -1,5 +1,5 @@ + import CopyWebpackPlugin from 'copy-webpack-plugin'; +-import grafanaConfig from '@grafana/plugin-configs/webpack.config.ts'; ++import grafanaConfig, { type Env } from '@grafana/plugin-configs/webpack.config.ts'; + import { mergeWithCustomize, unique } from 'webpack-merge'; + import { type Configuration } from 'webpack'; + +@@ -19,7 +19,7 @@ function skipFiles(f: string): boolean { + return true; + } + +-const config = async (env: Record): Promise => { ++const config = async (env: Env): Promise => { + const baseConfig = await grafanaConfig(env); + const customConfig = { + plugins: [ +diff --git a/e2e/test-plugins/grafana-test-datasource/webpack.config.ts b/e2e/test-plugins/grafana-test-datasource/webpack.config.ts +index 6268c183d3553..564555396a5e4 100644 +--- a/e2e/test-plugins/grafana-test-datasource/webpack.config.ts ++++ b/e2e/test-plugins/grafana-test-datasource/webpack.config.ts +@@ -1,5 +1,5 @@ + import CopyWebpackPlugin from 'copy-webpack-plugin'; +-import grafanaConfig from '@grafana/plugin-configs/webpack.config.ts'; ++import grafanaConfig, { type Env } from '@grafana/plugin-configs/webpack.config.ts'; + import { mergeWithCustomize, unique } from 'webpack-merge'; + import { type Configuration } from 'webpack'; + +@@ -19,7 +19,7 @@ function skipFiles(f: string): boolean { + return true; + } + +-const config = async (env: Record): Promise => { ++const config = async (env: Env): Promise => { + const baseConfig = await grafanaConfig(env); + const customConfig = { + plugins: [ +diff --git a/packages/grafana-plugin-configs/webpack.config.ts b/packages/grafana-plugin-configs/webpack.config.ts +index 86c1d1eafc992..c1bfc469d7b5b 100644 +--- a/packages/grafana-plugin-configs/webpack.config.ts ++++ b/packages/grafana-plugin-configs/webpack.config.ts +@@ -31,7 +31,7 @@ function skipFiles(f: string): boolean { + return true; + } + +-type Env = { ++export type Env = { + [key: string]: true | string | Env; + }; + +diff --git a/public/app/plugins/datasource/azuremonitor/webpack.config.ts b/public/app/plugins/datasource/azuremonitor/webpack.config.ts +index 301bafbd1f90f..875ef0a489376 100644 +--- a/public/app/plugins/datasource/azuremonitor/webpack.config.ts ++++ b/public/app/plugins/datasource/azuremonitor/webpack.config.ts +@@ -1,9 +1,9 @@ + import type { Configuration } from 'webpack'; + import { merge } from 'webpack-merge'; + +-import grafanaConfig from '@grafana/plugin-configs/webpack.config.ts'; ++import grafanaConfig, { type Env } from '@grafana/plugin-configs/webpack.config.ts'; + +-const config = async (env: Record): Promise => { ++const config = async (env: Env): Promise => { + const baseConfig = await grafanaConfig(env); + + return merge(baseConfig, { +diff --git a/public/app/plugins/datasource/grafana-pyroscope-datasource/webpack.config.ts b/public/app/plugins/datasource/grafana-pyroscope-datasource/webpack.config.ts +index 7a579fa172b60..f48f8b1a69353 100644 +--- a/public/app/plugins/datasource/grafana-pyroscope-datasource/webpack.config.ts ++++ b/public/app/plugins/datasource/grafana-pyroscope-datasource/webpack.config.ts +@@ -1,6 +1,6 @@ +-import config from '@grafana/plugin-configs/webpack.config.ts'; ++import config, { type Env } from '@grafana/plugin-configs/webpack.config.ts'; + +-const configWithFallback = async (env: Record) => { ++const configWithFallback = async (env: Env) => { + const response = await config(env); + if (response !== undefined && response.resolve !== undefined) { + response.resolve.fallback = { +diff --git a/public/app/plugins/datasource/jaeger/webpack.config.ts b/public/app/plugins/datasource/jaeger/webpack.config.ts +index 9ff90fccf0c3d..0346a64c5f22e 100644 +--- a/public/app/plugins/datasource/jaeger/webpack.config.ts ++++ b/public/app/plugins/datasource/jaeger/webpack.config.ts +@@ -1,10 +1,10 @@ + import { createRequire } from 'node:module'; + +-import config from '@grafana/plugin-configs/webpack.config.ts'; ++import config, { type Env } from '@grafana/plugin-configs/webpack.config.ts'; + + const require = createRequire(import.meta.url); + +-const configWithFallback = async (env: Record) => { ++const configWithFallback = async (env: Env) => { + const response = await config(env); + if (response !== undefined && response.resolve !== undefined) { + response.resolve.fallback = { +diff --git a/public/app/plugins/datasource/mssql/webpack.config.ts b/public/app/plugins/datasource/mssql/webpack.config.ts +index af2e94ddecf42..8a119f88315bd 100644 +--- a/public/app/plugins/datasource/mssql/webpack.config.ts ++++ b/public/app/plugins/datasource/mssql/webpack.config.ts +@@ -1,9 +1,9 @@ + import type { Configuration } from 'webpack'; + import { merge } from 'webpack-merge'; + +-import grafanaConfig from '@grafana/plugin-configs/webpack.config.ts'; ++import grafanaConfig, { type Env } from '@grafana/plugin-configs/webpack.config.ts'; + +-const config = async (env: Record): Promise => { ++const config = async (env: Env): Promise => { + const baseConfig = await grafanaConfig(env); + + return merge(baseConfig, { diff --git a/www-apps/grafana/files/grafana.conf b/www-apps/grafana/files/grafana.conf new file mode 100644 index 0000000..7dc98e1 --- /dev/null +++ b/www-apps/grafana/files/grafana.conf @@ -0,0 +1,2 @@ +#Type Path Mode UID GID Age Argument +d /run/~PN_S~ 0755 grafana grafana - - diff --git a/www-apps/grafana/files/grafana.confd b/www-apps/grafana/files/grafana.confd new file mode 100644 index 0000000..05a3ab7 --- /dev/null +++ b/www-apps/grafana/files/grafana.confd @@ -0,0 +1,7 @@ +GRAFANA_CONFIG="/etc/~PN_S~/grafana.ini" +GRAFANA_DATADIR="/var/lib/~PN_S~" +GRAFANA_LOGDIR="/var/log/~PN_S~" + +GRAFANA_OPTS="-config=${GRAFANA_CONFIG} \ + cfg:default.paths.data=${GRAFANA_DATADIR} \ + cfg:default.paths.logs=${GRAFANA_LOGDIR}" diff --git a/www-apps/grafana/files/grafana.initd b/www-apps/grafana/files/grafana.initd new file mode 100644 index 0000000..5d5eb4a --- /dev/null +++ b/www-apps/grafana/files/grafana.initd @@ -0,0 +1,29 @@ +#!/sbin/openrc-run +# Copyright 1999-2022 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +description="The open-source platform for monitoring and observability" + +: ${GRAFANA_USER:=grafana} +: ${GRAFANA_DATADIR:=/var/lib/~PN_S~} +: ${GRAFANA_LOGDIR:=/var/log/~PN_S~} +: ${GRAFANA_TERMTIMEOUT:="TERM/20/KILL/5"} +: ${SSD_OPTS:="-d /usr/share/~PN_S~ -w 1000"} + +name="Grafana" +command="/usr/bin/~PN_S~-server" +command_args="${GRAFANA_OPTS}" +command_user="${GRAFANA_USER}" +command_background=true +pidfile="/run/${SVCNAME}.pid" +required_files="${GRAFANA_CONFIG}" +retry="${GRAFANA_TERMTIMEOUT}" +start_stop_daemon_args="${SSD_OPTS}" + +depend() { + need localmount net +} + +start_pre() { + checkpath -d -m 0750 -o "${GRAFANA_USER}" "${GRAFANA_DATADIR}" "${GRAFANA_LOGDIR}" +} diff --git a/www-apps/grafana/files/grafana.service b/www-apps/grafana/files/grafana.service new file mode 100644 index 0000000..48d12ca --- /dev/null +++ b/www-apps/grafana/files/grafana.service @@ -0,0 +1,25 @@ +[Unit] +Description=Grafana - The open-source platform for monitoring and observability +Documentation=http://docs.grafana.org +Wants=network-online.target +After=network-online.target + +[Service] +User=grafana +Group=grafana +Type=simple +Restart=on-failure +RuntimeDirectory=~PN_S~ +WorkingDirectory=/usr/share/~PN_S~ +ExecStart=/usr/libexec/~PN_S~/grafana-server \ + --config=/etc/~PN_S~/grafana.ini \ + --pidfile=/run/~PN_S~/grafana.pid \ + cfg:default.paths.logs=/var/log/~PN_S~ \ + cfg:default.paths.data=/var/lib/~PN_S~ \ + cfg:default.paths.plugins=/var/lib/~PN_S~/plugins +LimitNOFILE=10000 +TimeoutStopSec=20 +UMask=0027 + +[Install] +WantedBy=multi-user.target diff --git a/www-apps/grafana/grafana-12.1.1.ebuild b/www-apps/grafana/grafana-12.1.1.ebuild new file mode 100644 index 0000000..d9be4ef --- /dev/null +++ b/www-apps/grafana/grafana-12.1.1.ebuild @@ -0,0 +1,153 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit check-reqs go-module systemd tmpfiles + +MY_PV=${PV/_beta/-beta} +S=${WORKDIR}/${PN}-${MY_PV} + +DESCRIPTION="The open-source platform for monitoring and observability" +HOMEPAGE="https://grafana.com" +yarn_version="4.9.2" + +## building vendor and yarn vendors (@WilliamH - ping me!) +# >> git clone https://github.com/grafana/grafana -b v /tmp/grafana +# >> cd /tmp/grafana && version=`git describe --tags | sed -E "s/v([0-9.]+)/\1/g"` +# >> GOWORK=off go mod vendor && go work vendor && mkdir grafana-${version} && mv vendor grafana-${version}/vendor +# >> tar -caf grafana-${version}-vendor.tar.xz grafana-${version}/vendor +# >> echo -e "enableMirror: true\ncacheFolder: ./vendor_yarn" >> .yarnrc.yml +# >> CYPRESS_INSTALL_BINARY=0 yarn set version 4.9.2 +# >> CYPRESS_INSTALL_BINARY=0 yarn cache clean --mirror && yarn install +# >> mv vendor_yarn grafana-${version}/vendor_yarn +# >> tar -caf grafana-${version}-vendor_yarn.tar.xz grafana-${version}/vendor_yarn + +SRC_URI=" + https://github.com/grafana/grafana/archive/v${MY_PV}.tar.gz -> ${P}.tar.gz + https://people.znc.in/~dessa/gentoo-dessa/distfiles/${CATEGORY}/${PN}/${PN}-${PV}-vendor.tar.xz + https://people.znc.in/~dessa/gentoo-dessa/distfiles/${CATEGORY}/${PN}/${PN}-${PV}-vendor_yarn.tar.xz + https://repo.yarnpkg.com/${yarn_version}/packages/yarnpkg-cli/bin/yarn.js -> yarn-${yarn_version}.cjs +" +LICENSE="AGPL-3.0 Apache-2.0 BSD-2 BSD-3 BSD-4 BSL-1.0 ImageMagick ISC LGPL-3.0 MIT MPL-2.0 OpenSSL Zlib" +SLOT="12/"${PV} +KEYWORDS="~amd64" +IUSE="systemd" +RESTRICT="test" # Tests not wroking (a proper fix would take to long) + +# needed for webpack (nodejs) +CHECKREQS_MEMORY="8G" + +DEPEND="!www-apps/${PN}-bin + acct-group/${PN} + acct-user/${PN} + media-libs/fontconfig + net-libs/nodejs[icu] + sys-apps/yarn + >=dev-lang/go-1.20 + >=dev-go/wire-0.6.0" + +PN_S="${PN}-${SLOT%/*}" + +PATCHES=( + "${FILESDIR}/${PN}-12.1.1-node-22.18.0.patch" +) + +src_prepare() { + sed -i "s:;reporting_enabled = .*:reporting_enabled = false:" \ + conf/sample.ini || die "prepare failed" + sed -i "s:;check_for_updates = .*:check_for_updates = false:" \ + conf/sample.ini || die "prepare failed" + + ## offline/cache installation + echo -e "enableMirror: true\ncacheFolder: ./vendor_yarn" >> .yarnrc.yml + sed -i '/^yarnPath/d' .yarnrc.yml + echo "yarnPath: .yarn/releases/yarn-${yarn_version}.cjs" >> .yarnrc.yml + cp ${DISTDIR}/yarn-${yarn_version}.cjs .yarn/releases/ || die "could not copy yarn-${yarn_version}.cjs" + + ## preparing files (and replace the version) + mkdir -p "files" + cp -a "${FILESDIR}/${PN}".* files || die "coudln't copy needed files!" + sed -i "s/~PN_S~/${PN_S}/g" files/* || die "couldn't apply slot-patches!" + + ## setting build-info + sed -i 's/unknown-dev/gentoo/g' pkg/build/git.go + + default +} + +src_compile() { + ## install yarn deps(offline).. + CYPRESS_INSTALL_BINARY=0 PUPPETEER_SKIP_DOWNLOAD=0 yarn install || die "prepare failed" + + einfo "Wiring everything up.." + wire gen -tags oss ./pkg/server ./pkg/cmd/grafana-cli/runner || die "wiring failed" + einfo "Building binaries using go.." + go run -mod=vendor build.go build || die "compile failed" + einfo "Building frontend using webpack.." + # beware, we need at least 8G RAM (@32T) + export NODE_OPTIONS="--max-old-space-size=8192" + yarn run build || die "compile failed" +} + +src_install() { + insinto /etc/${PN_S} + newins conf/sample.ini ${PN}.ini + newins conf/ldap.toml ldap.toml + + exeinto /usr/libexec/${PN_S} + newexe `(find bin -name ${PN})` ${PN} + ## legacy + newexe `(find bin -name ${PN}-cli)` ${PN}-cli + newexe `(find bin -name ${PN}-server)` ${PN}-server + + exeinto /usr/bin + echo -e "#"'!'"/bin/sh\nPATH=\"/usr/libexec/${PN_S}:\${PATH}\" && ${PN} \$@" >> ${D}/usr/bin/${PN_S} + echo -e "#"'!'"/bin/sh\nPATH=\"/usr/libexec/${PN_S}:\${PATH}\" && ${PN} cli --homepath /var/lib/${PN_S} --pluginsDir /var/lib/${PN_S}/plugins \$@" >> ${D}/usr/bin/${PN_S}-cli + echo -e "#"'!'"/bin/sh\nPATH=\"/usr/libexec/${PN_S}:\${PATH}\" && ${PN} server --homepath /var/lib/${PN_S} \$@" >> ${D}/usr/bin/${PN_S}-server + + fperms +x /usr/bin/${PN_S} + fperms +x /usr/bin/${PN_S}-cli + fperms +x /usr/bin/${PN_S}-server + + insinto "/usr/share/${PN_S}" + doins -r public conf tools + + ## for the initd thingies we should take a look into: + # https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/#override-configuration-with-environment-variables + newconfd "${S}/files/${PN}.confd" "${PN_S}" + newinitd "${S}/files/${PN}.initd" "${PN_S}" + use systemd && systemd_newunit "${S}/files/${PN}.service" "${PN_S}.service" + + newtmpfiles "${S}/files"/${PN}.conf ${PN_S}.conf + + keepdir /var/{lib,log}/${PN_S} + fowners ${PN}:${PN} /var/{lib,log}/${PN_S} + fperms 0750 /var/{lib,log}/${PN_S} + + keepdir /var/lib/${PN_S}/{dashboards,plugins} + fowners ${PN}:${PN} /var/lib/${PN_S}/{dashboards,plugins} + fperms 0750 /var/lib/${PN_S}/{dashboards,plugins} + + keepdir /etc/${PN_S} + fowners ${PN}:${PN} /etc/${PN_S}/{${PN}.ini,ldap.toml} + fperms 0640 /etc/${PN_S}/{${PN}.ini,ldap.toml} +} + +pkg_postinst() { + tmpfiles_process ${PN_S}.conf + + if [ -d /var/lib/${PN} ]; then + # found non-slotted grafana installation + ewarn "We found an old ${PN} installation in '/var/lib/${PN}'!" + ewarn "Make sure to adjust the confs and do a data-migration, the" + ewarn "new ${PN} data-dir is '/var/lib/${PN_S}'." + fi + + einfo "${PN} has built-in log rotation. Please see [log.file] section of" + einfo "/etc/${PN_S}/${PN}.ini for related settings." + einfo + einfo "You may add your own custom configuration for app-admin/logrotate if you" + einfo "wish to use external rotation of logs. In this case, you also need to make" + einfo "sure the built-in rotation is turned off." +}