%define debug_package %{nil} %global git_commit_sha 601ff95a7bc173b4bd58697b8a9ec3a64537c78e %global git_commit_timestamp 20250726182646 Name: apcupsd_exporter Version: 0.1.%{git_commit_timestamp} Release: %autorelease Summary: Prometheus exporter that exposes metrics from apcupsd's NIS License: MIT URL: https://github.com/ps-gill/apcupsd_exporter Source0: https://github.com/ps-gill/apcupsd_exporter/archive/%{git_commit_sha}.tar.gz Source1: %{name}.service Source2: %{name}-service.preset ExclusiveArch: x86_64 aarch64 BuildRequires: git BuildRequires: golang >= 1.23.0 BuildRequires: systemd-rpm-macros %{?systemd_requires} %{?sysusers_requires_compat} %description %{summary}. %prep %setup -q -n %{name}-%{git_commit_sha} %build go build ./cmd/apcupsd_exporter %install install -D --mode=755 %{name} "%{buildroot}%{_libexecdir}/%{name}" install -D --mode=644 "%{SOURCE1}" "%{buildroot}%{_unitdir}/%{name}.service" install -D --mode=644 "%{SOURCE2}" "%{buildroot}%{_prefix}/lib/systemd/system-preset/90-%{name}.preset" %files %doc README.md %license LICENSE.md %{_libexecdir}/%{name} %{_unitdir}/%{name}.service %{_prefix}/lib/systemd/system-preset/90-%{name}.preset %pre getent group apcupsd_exporter > /dev/null || groupadd --system apcupsd_exporter getent passwd apcupsd_exporter > /dev/null || \ useradd --system --create-home --home-dir "%{_sharedstatedir}/apcupsd_exporter" --gid apcupsd_exporter \ -s /sbin/nologin -c "apcupsd_exporter daemon" apcupsd_exporter exit 0 %post %systemd_post apcupsd_exporter.service %preun %systemd_preun apcupsd_exporter.service %postun %systemd_postun apcupsd_exporter.service %changelog %autochangelog