File golang-github-wrouesnel-postgres_exporter.spec of Package golang-github-wrouesnel-postgres_exporter.11261

# spec file for package golang-github-wrouesnel-postgres_exporter
# Copyright (c) 2017 Silvio Moioli <>
# 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


#Compat macro for new _fillupdir macro introduced in Nov 2017
%if ! %{defined _fillupdir}
  %define _fillupdir /var/adm/fillup-templates

%define project
Name:           golang-github-wrouesnel-postgres_exporter
Version:        0.4.7
Release:        0
License:        Apache-2.0
Summary:        Prometheus exporter for PostgreSQL
Group:          System/Management
Source:         postgres_exporter-%{version}.tar.xz
Source1:        prometheus-postgres_exporter.service
Source2:        prometheus-postgres_exporter.sysconfig
Patch0:         architectures.patch
BuildRequires:  golang-packaging
BuildRequires:  golang(API) = 1.9
BuildRequires:  xz
BuildRequires:  pkgconfig(systemd)
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires(pre):  shadow

Prometheus exporter for PostgreSQL server metrics. Supported PostgreSQL versions: 9.1 and up.

%setup -q -n postgres_exporter-%{version}
%patch0 -p1

export GOPATH=$HOME/go
mkdir -pv $HOME/go/src/%{project}
cp -avr * $HOME/go/src/%{project}
cd $HOME/go/src/%{project}

go run mage.go binary

cd $HOME/go/src/%{project}
install -D -m 0755 bin/postgres_exporter_v0.0.0_linux-*/postgres_exporter %{buildroot}/%{_bindir}/prometheus-postgres_exporter

install -m755 -d %buildroot%{_fillupdir}
install -m644 %{S:2} %buildroot%{_fillupdir}/sysconfig.prometheus-postgres_exporter

install -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/prometheus-postgres_exporter.service
install -Dd -m 0755 %{buildroot}%{_sbindir}
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rcprometheus-postgres_exporter

%service_add_pre prometheus-postgres_exporter.service
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

%fillup_only -n prometheus-postgres_exporter
%service_add_post prometheus-postgres_exporter.service

%service_del_preun prometheus-postgres_exporter.service

%service_del_postun prometheus-postgres_exporter.service


openSUSE Build Service is sponsored by