File percona-postgres_exporter.spec of Package percona-postgres_exporter

#
# spec file for package percona-postgres_exporter
#
# Copyright (c) 2021 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/
#

%define pkg_name postgres_exporter

Name:           percona-postgres_exporter
Version:        0
Release:        0
Summary:        Prometheus exporter for PostgreSQL
License:        Apache-2.0
Url:            https://github.com/percona/postgres_exporter
Source:         _service
Source1:        prometheus-postgres_exporter.service
Source2:        prometheus-postgres_exporter.sysconfig
Source3:        vendor.tar.xz
BuildRequires:  percona-macros
BuildRequires:  golang-packaging
BuildRequires:  golang(API) >= 1.14
BuildRequires:  xz
BuildRequires:  pkgconfig(systemd)
#
Requires:       percona-common
Requires(pre):  percona-common
Requires(post): percona-common
Requires(postun): percona-common
Requires:       percona-common
%{?systemd_ordering}
#
%go_nostrip

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

%prep
mv %{_sourcedir}/%{pkg_name}-%{version} %{_builddir}/%{pkg_name}-%{version}
%autosetup -n %{pkg_name}-%{version} -p1 -D -T 0 -a 3

%build
# TODO: find out how to do this with the ldflags
perl -p -i -e 's|(var Version(Short)? =) "[^"]+"|$1 "%{version}"|g' ./cmd/postgres_exporter/postgres_exporter.go
go build -mod=vendor -buildmode=pie ./cmd/...
./postgres_exporter --version

%install
install -D -m 0755 postgres_exporter  %{buildroot}%{percona_exporter_dir}/postgres_exporter

%files
%license LICENSE
%doc CHANGELOG.md README.md
%doc queries.yaml example.alerts.yml example-queries-postgres.yml queries-postgres-uptime.yml
%{percona_exporter_dir}/postgres_exporter

%changelog
openSUSE Build Service is sponsored by