From deaa246528cb25b6ffbbea25849d9fb3ab3c03b7 Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Sun, 26 Mar 2023 14:56:34 -0500 Subject: app-metrics/prometheus: fix service script Introduce the prometheus_args variable. Allow the continued use of command_args in the script for now to avoid breaking systems, but document that people should move to prometheus_args. Also, sync most of the defaults with the systemd service. Signed-off-by: William Hubbs --- app-metrics/prometheus/files/prometheus.confd | 28 ++++++++- app-metrics/prometheus/files/prometheus.initd | 12 ++++ app-metrics/prometheus/prometheus-2.43.0-r1.ebuild | 72 ++++++++++++++++++++++ app-metrics/prometheus/prometheus-2.43.0.ebuild | 72 ---------------------- 4 files changed, 110 insertions(+), 74 deletions(-) create mode 100644 app-metrics/prometheus/prometheus-2.43.0-r1.ebuild delete mode 100644 app-metrics/prometheus/prometheus-2.43.0.ebuild (limited to 'app-metrics/prometheus') diff --git a/app-metrics/prometheus/files/prometheus.confd b/app-metrics/prometheus/files/prometheus.confd index 93b41b31624c..19a286f5677a 100644 --- a/app-metrics/prometheus/files/prometheus.confd +++ b/app-metrics/prometheus/files/prometheus.confd @@ -1,2 +1,26 @@ -# arguments for Prometheus -command_args="" +# additional arguments for Prometheus +# +# command_args should not be set in this file. Instead, you should set +# prometheus_args. +# +# The default settings are listed below. +# If you are not changing these settings, you do +# not need to include them in prometheus_args. +# +# To migrate from using command_args to prometheus_args, drop any of the +# default settings below that you have set the same way then switch to +# prometheus_args. +# +# The new behavior is that prometheus_args will be appended to these +# defaults allowing anything you add to override them. +# +#The default settings are: +# +# --web.enable-lifecycle +# --config.file=/etc/prometheus/prometheus.yml +# --storage.tsdb.path=/var/lib/prometheus/data +# --web.console.templates=/etc/prometheus/consoles +# --web.console.libraries=/etc/prometheus/console_libraries +# --web.enable-admin-api +# +prometheus_args="" diff --git a/app-metrics/prometheus/files/prometheus.initd b/app-metrics/prometheus/files/prometheus.initd index f7371f8ca060..dc5db03ad5ea 100644 --- a/app-metrics/prometheus/files/prometheus.initd +++ b/app-metrics/prometheus/files/prometheus.initd @@ -9,7 +9,19 @@ group=${group:-${RC_SVCNAME}} command_user=${user}:${group} command="/usr/bin/prometheus" +if [ -z "${command_args}" ]; then +command_args=" + --web.enable-lifecycle + --config.file=/etc/prometheus/prometheus.yml + --storage.tsdb.path=/var/lib/prometheus/data + --web.console.templates=/etc/prometheus/consoles + --web.console.libraries=/etc/prometheus/console_libraries + --web.listen-address=0.0.0.0:9090 + --web.enable-admin-api + ${prometheus_args}" +else command_args="${command_args:---config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus/data}" +fi command_background="true" error_log=/var/log/${RC_SVCNAME}/${RC_SVCNAME}.log output_log=/var/log/${RC_SVCNAME}/${RC_SVCNAME}.log diff --git a/app-metrics/prometheus/prometheus-2.43.0-r1.ebuild b/app-metrics/prometheus/prometheus-2.43.0-r1.ebuild new file mode 100644 index 000000000000..db5a914685b6 --- /dev/null +++ b/app-metrics/prometheus/prometheus-2.43.0-r1.ebuild @@ -0,0 +1,72 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 +inherit go-module systemd +GIT_COMMIT=edfc3bcd025dd6fe296c167a14a216cab1e552ee +MY_PV=v${PV/_rc/-rc.} + +# To create the assets tarball run the following: +# git checkout +# make assets-compress +# tar -acf web/ui + +DESCRIPTION="Prometheus monitoring system and time series database" +HOMEPAGE="https://github.com/prometheus/prometheus" +SRC_URI="https://github.com/prometheus/prometheus/archive/${MY_PV}.tar.gz -> ${P}.tar.gz + https://dev.gentoo.org/~williamh/dist/${P}-deps.tar.xz + https://dev.gentoo.org/~williamh/dist/${P}-assets.tar.xz" + +LICENSE="Apache-2.0 BSD BSD-2 ISC MIT MPL-2.0" +SLOT="0" +KEYWORDS="~amd64 ~arm ~riscv" + +COMMON_DEPEND="acct-group/prometheus + acct-user/prometheus" +DEPEND="!app-metrics/prometheus-bin + ${COMMON_DEPEND}" +RDEPEND="${COMMON_DEPEND}" + +BDEPEND=">=dev-util/promu-0.3.0" + +RESTRICT=" test" + +src_prepare() { + default + sed -i \ + -e "s/{{.Branch}}/HEAD/" \ + -e "s/{{.Revision}}/${GIT_COMMIT}/" \ + -e "s/{{.Version}}/${PV}/" \ + .promu.yml || die + cp -a -n "${WORKDIR}"/web/ui web || die +} + +src_compile() { + emake PROMU="${EPREFIX}"/usr/bin/promu common-build plugins +} + +src_install() { + dobin prometheus promtool + dodoc -r {documentation,{README,CHANGELOG,CONTRIBUTING}.md} + insinto /usr/share/prometheus + doins -r console_libraries consoles + insinto /etc/prometheus + doins documentation/examples/prometheus.yml + dosym -r /usr/share/prometheus/console_libraries /etc/prometheus/console_libraries + dosym -r /usr/share/prometheus/consoles /etc/prometheus/consoles + + systemd_dounit "${FILESDIR}"/prometheus.service + newinitd "${FILESDIR}"/prometheus.initd prometheus + newconfd "${FILESDIR}"/prometheus.confd prometheus + keepdir /var/log/prometheus /var/lib/prometheus + fowners prometheus:prometheus /var/log/prometheus /var/lib/prometheus +} + +pkg_postinst() { + if has_version ' -# make assets-compress -# tar -acf web/ui - -DESCRIPTION="Prometheus monitoring system and time series database" -HOMEPAGE="https://github.com/prometheus/prometheus" -SRC_URI="https://github.com/prometheus/prometheus/archive/${MY_PV}.tar.gz -> ${P}.tar.gz - https://dev.gentoo.org/~williamh/dist/${P}-deps.tar.xz - https://dev.gentoo.org/~williamh/dist/${P}-assets.tar.xz" - -LICENSE="Apache-2.0 BSD BSD-2 ISC MIT MPL-2.0" -SLOT="0" -KEYWORDS="~amd64 ~arm ~riscv" - -COMMON_DEPEND="acct-group/prometheus - acct-user/prometheus" -DEPEND="!app-metrics/prometheus-bin - ${COMMON_DEPEND}" -RDEPEND="${COMMON_DEPEND}" - -BDEPEND=">=dev-util/promu-0.3.0" - -RESTRICT=" test" - -src_prepare() { - default - sed -i \ - -e "s/{{.Branch}}/HEAD/" \ - -e "s/{{.Revision}}/${GIT_COMMIT}/" \ - -e "s/{{.Version}}/${PV}/" \ - .promu.yml || die - cp -a -n "${WORKDIR}"/web/ui web || die -} - -src_compile() { - emake PROMU="${EPREFIX}"/usr/bin/promu common-build plugins -} - -src_install() { - dobin prometheus promtool - dodoc -r {documentation,{README,CHANGELOG,CONTRIBUTING}.md} - insinto /usr/share/prometheus - doins -r console_libraries consoles - insinto /etc/prometheus - doins documentation/examples/prometheus.yml - dosym -r /usr/share/prometheus/console_libraries /etc/prometheus/console_libraries - dosym -r /usr/share/prometheus/consoles /etc/prometheus/consoles - - systemd_dounit "${FILESDIR}"/prometheus.service - newinitd "${FILESDIR}"/prometheus.initd prometheus - newconfd "${FILESDIR}"/prometheus.confd prometheus - keepdir /var/log/prometheus /var/lib/prometheus - fowners prometheus:prometheus /var/log/prometheus /var/lib/prometheus -} - -pkg_postinst() { - if has_version '