File golang-github-prometheus-node_exporter.spec of Package golang-github-prometheus-node_exporter
#
# spec file for package golang-github-prometheus-node_exporter
#
# Copyright (c) 2020 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/
#
# build ids are not currently generated:
%undefine _missing_build_ids_terminate_build
Name: golang-github-prometheus-node_exporter
Version: 1.3.1
Release: 0
Summary: Prometheus exporter for machine metrics
License: Apache-2.0
Group: System/Management
Url: https://prometheus.io/
Source: node_exporter-%{version}.tar.gz
# Generated after applying 0001-Update-prometheus-client-to-1.11.1.patch
Source1: vendor.tar.gz
Source2: prometheus-node_exporter.service
Source3: prometheus-node_exporter.initd
Source4: prometheus-node_exporter.sysconfig
# This patch has been applied before generating vendor tarball
Patch1: 0001-Update-prometheus-client-to-1.11.1.patch
%if 0%{?rhel} >= 9
BuildRequires: go >= 1.15
%else
BuildRequires: go1.15
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Provides: node_exporter
Provides: prometheus(node_exporter)
ExclusiveArch: %ix86 x86_64 %arm ppc64le aarch64
%description
Prometheus exporter for hardware and OS metrics exposed by *NIX kernels, written in Go with pluggable metric collectors.
%prep
%autosetup -a1 -p1 -n node_exporter-%{version}
%build
go build -mod=vendor -ldflags "-v -buildmode=pie -compressdwarf=false"
%install
install -D -m 0755 node_exporter %{buildroot}/%{_bindir}/node_exporter
install -Dd -m0755 %{buildroot}%{_sbindir}
%if 0%{?rhel} >= 7
install -D -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/prometheus-node_exporter.service
install -D -m 0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/prometheus-node_exporter
%else
install -D -m 0755 %{SOURCE3} %{buildroot}%{_initddir}/prometheus-node_exporter
%endif
%check
go test github.com/prometheus/node_exporter -mod=vendor
%pre
getent group prometheus >/dev/null || %{_sbindir}/groupadd -r prometheus
getent passwd prometheus >/dev/null || %{_sbindir}/useradd -r -g prometheus -d %{_localstatedir}/lib/prometheus -M -s /sbin/nologin prometheus
%if 0%{?rhel} >= 7
%post
%systemd_post prometheus-node_exporter.service
%preun
%systemd_preun prometheus-node_exporter.service
%postun
%systemd_postun prometheus-node_exporter.service
%else
%post
/sbin/chkconfig --add prometheus-node_exporter
%preun
if [ $1 -eq 0 ] ; then
/sbin/service prometheus-node_exporter stop >/dev/null 2>&1
/sbin/chkconfig --del prometheus-node_exporter
fi
%postun
if [ "$1" -ge "1" ] ; then
/sbin/service prometheus-node_exporter condrestart >/dev/null 2>&1 || :
fi
%endif
%files
%defattr(-,root,root,-)
%doc README.md
# RHEL 6 license macro patch
%{!?_licensedir:%global license %%doc}
%license LICENSE
%{_bindir}/node_exporter
%if 0%{?rhel} >= 7
%{_unitdir}/prometheus-node_exporter.service
%{_sysconfdir}/prometheus-node_exporter
%else
%{_initddir}/prometheus-node_exporter
%endif
%changelog