You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

82 lines
2.3 KiB

%global _hardened_build 1
%define prometheus_user prometheus
%define prometheus_group prometheus
%define prometheus_home /var/lib/prometheus
%define prometheus_logdir /var/log/prometheus
#%define debug_package %{nil}
Name : prometheus
Version : 2.7.2
Release : 1%{dist}
License : MIT
URL : https://prometheus.io
Summary : The Prometheus monitoring system and time series database.
Source0 : prometheus.service
BuildRequires: golang
BuildRequires: git
Requires : git
%description
Power your metrics and alerting with a leading
open-source monitoring solution.
%prep
%setup -T -q -c %{name}-%{version}
export GOPATH=`pwd`
mkdir -p src/github.com/prometheus/
cd src/github.com/prometheus/
git clone https://github.com/prometheus/prometheus/
%build
export GOPATH=`pwd`
cd src/github.com/prometheus/prometheus/
git checkout tags/v%{version}
make build
%install
install -p -D -m 0644 src/github.com/prometheus/prometheus/prometheus %{buildroot}%{_bindir}/prometheus
install -p -D -m 0644 src/github.com/prometheus/prometheus/promtool %{buildroot}%{_bindir}/promtool
install -p -D -m 0644 %{SOURCE0} %{buildroot}%{_unitdir}/prometheus.service
install -p -D -m 0644 src/github.com/prometheus/prometheus/documentation/examples/prometheus.yml %{buildroot}%{_sysconfdir}/prometheus/prometheus.yml
mkdir -p %{buildroot}%{_datadir}/%{name}/
cp -r src/github.com/prometheus/prometheus/consoles/ %{buildroot}%{_datadir}/%{name}/
cp -r src/github.com/prometheus/prometheus/console_libraries/ %{buildroot}%{_datadir}/%{name}/
install -p -d -m 0700 %{buildroot}%{prometheus_home}
install -p -d -m 0700 %{buildroot}%{prometheus_logdir}
%pre
getent group %{prometheus_group} > /dev/null || groupadd -r %{prometheus_group}
getent passwd %{prometheus_user} > /dev/null || \
useradd -r -d %{prometheus_home} -g %{prometheus_group} \
-s /bin/bash -c "Prometheus user" %{prometheus_user}
exit 0
%post
%systemd_post prometheus.service
%preun
%systemd_preun prometheus.service
%postun
%systemd_postun prometheus.service
%files
%attr(775,%{prometheus_user},%{prometheus_group}) %{_sysconfdir}/%{name}/
%config(noreplace) %{_sysconfdir}/%{name}/%{name}.yml
%{_bindir}/%{name}
%{_bindir}/promtool
%{_datadir}/%{name}/consoles/
%{_datadir}/%{name}/console_libraries/
%{_unitdir}/prometheus.service
%changelog