File percona-node_exporter.spec of Package percona-node_exporter

#
# spec file for package percona-node_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 node_exporter

Name:           percona-node_exporter
Version:        0
Release:        0
Summary:        Prometheus exporter for Node Statistics
License:        Apache-2.0
Url:            https://github.com/percona/node_exporter
Source:         _service
Source1:        prometheus-node_exporter.service
Source2:        prometheus-node_exporter.sysconfig
Source3:        vendor.tar.xz
BuildRequires:  percona-macros
BuildRequires:  golang-packaging
BuildRequires:  golang(API)
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 Node Statistics.

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

%build
export VERSION=%{version}
go build \
  -mod=vendor \
  -buildmode=pie \
  -ldflags "\
    -X github.com/prometheus/common/version.Version=${VERSION} \
    -X github.com/prometheus/common/version.Revision=${VERSION##*.} \
    -X github.com/prometheus/common/version.Branch=master \
    -X github.com/prometheus/common/version.BuildUser=abuild@build.opensuse.org
    -X github.com/prometheus/common/version.BuildDate=$(date -u '+%Y-%m-%dT%H:%M' -d @${SOURCE_DATE_EPOCH}) \
    " \
    node_exporter.go
./node_exporter --version

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

%files
%license LICENSE
%doc CHANGELOG.md README.md CONTRIBUTING.md MAINTAINERS.md
%doc example.prom  example-rules.yml
%{percona_exporter_dir}/node_exporter

%changelog
openSUSE Build Service is sponsored by