File golang-github-lusitaniae-apache_exporter.spec of Package golang-github-lusitaniae-apache_exporter
#
# spec file for package golang-github-lusitaniae-apache_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/
#
#Compat macro for new _fillupdir macro introduced in Nov 2017
%if ! %{defined _fillupdir}
%define _fillupdir /var/adm/fillup-templates
%endif
%undefine _missing_build_ids_terminate_build
Name: golang-github-lusitaniae-apache_exporter
Version: 0.7.0
Release: 0
License: MIT
Summary: Apache Exporter for Prometheus
Url: https://github.com/lusitaniae/apache_exporter
Group: System/Management
Source: apache_exporter-%{version}.tar.xz
Source1: prometheus-apache_exporter.service
Source2: prometheus-apache_exporter.sysconfig
Source3: prometheus-apache_exporter.initd
%if 0%{?rhel} >= 8
BuildRequires: golang
%else
BuildRequires: go1.11
%endif
BuildRequires: xz
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version}
Requires(post): %fillup_prereq
%endif
%description
Exports apache mod_status statistics via HTTP for Prometheus consumption.
%prep
%setup -q -n apache_exporter-%{version}
%build
go build -mod=vendor -ldflags "-v -buildmode=pie -compressdwarf=false"
%install
install -D -m 0755 apache_exporter %{buildroot}/%{_bindir}/apache_exporter
%if 0%{?suse_version}
install -m755 -d %buildroot%{_fillupdir}
install -m644 %{SOURCE2} %buildroot%{_fillupdir}/sysconfig.prometheus-apache_exporter
%else
install -m755 -d %{buildroot}/etc/sysconfig
install -m644 %{SOURCE2} %{buildroot}/etc/sysconfig/prometheus-apache_exporter
%endif
%if 0%{?rhel} >= 7
install -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/prometheus-apache_exporter.service
%else
install -D -m 0755 %{SOURCE3} %{buildroot}%{_initddir}/prometheus-apache_exporter
%endif
%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
%post
%if 0%{?suse_version}
%fillup_only -n prometheus-apache_exporter
%endif
%if 0%{?rhel} >= 7
%systemd_post prometheus-apache_exporter.service
%else
/sbin/chkconfig --add prometheus-apache_exporter
%endif
%preun
%if 0%{?rhel} >= 7
%systemd_preun prometheus-apache_exporter.service
%else
if [ $1 -eq 0 ] ; then
/sbin/service prometheus-apache_exporter stop >/dev/null 2>&1
/sbin/chkconfig --del prometheus-apache_exporter
fi
%endif
%postun
%if 0%{?rhel} >= 7
%systemd_postun prometheus-apache_exporter.service
%else
if [ "$1" -ge "1" ] ; then
/sbin/service prometheus-apache_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}/apache_exporter
%if 0%{?suse_version}
%{_fillupdir}/sysconfig.prometheus-apache_exporter
%else
/etc/sysconfig/prometheus-apache_exporter
%endif
%if 0%{?rhel} >= 7
%{_unitdir}/prometheus-apache_exporter.service
%else
%{_initddir}/prometheus-apache_exporter
%endif
%changelog