## START: Set by rpmautospec ## (rpmautospec version 0.8.1) ## RPMAUTOSPEC: autorelease, autochangelog %define autorelease(e:s:pb:n) %{?-p:0.}%{lua: release_number = 4; base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}")); print(release_number + base_release_number - 1); }%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}} ## END: Set by rpmautospec %define gobuild(o:) %{expand: # https://bugzilla.redhat.com/show_bug.cgi?id=995136#c12 %global _dwz_low_mem_die_limit 0 %ifnarch ppc64 go build -buildmode pie -compiler gc -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}' -compressdwarf=false" -a -v -x %{?**}; %else go build -compiler gc -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}' -compressdwarf=false" -a -v -x %{?**}; %endif } %global shortname prometheus-node-exporter # https://github.com/prometheus/node_exporter %global goipath github.com/prometheus/node_exporter Version: 1.3.1 %global common_description %{expand: Prometheus exporter for hardware and OS metrics exposed by *NIX kernels, written in Go with pluggable metric collectors.} %global golicenses LICENSE NOTICE %global godocs docs examples CHANGELOG.md CODE_OF_CONDUCT.md\\\ CONTRIBUTING.md MAINTAINERS.md SECURITY.md README.md Name: golang-github-prometheus-node-exporter Release: %autorelease Summary: Exporter for machine metrics # Upstream license specification: Apache-2.0 License: ASL 2.0 and MIT URL: https://%{goipath} Source0: https://%{goipath}/archive/v%{version}/node_exporter-%{version}.tar.gz # git clone https://github.com/prometheus/node_exporter # cd node_exporter # git checkout v%%{version} # go mod vendor # tar -czvf ../vendor-%%{version}.tar.gz vendor/ Source10: vendor-%{version}.tar.gz # Source1: %%{shortname}.sysusers Source2: %{shortname}.service Source3: %{shortname}.conf Source4: %{shortname}.logrotate # Replace defaults paths for config files Patch0: defaults-paths.patch # https://github.com/prometheus/node_exporter/pull/2190 Patch1: 0001-Refactor-perf-collector.patch # e.g. el6 has ppc64 arch without gcc-go, so EA tag is required ExclusiveArch: %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 aarch64 %{arm}} # If go_compiler is not set to 1, there is no virtual provide. Use golang instead. BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang} BuildRequires: systemd-rpm-macros Requires(pre): shadow-utils %description %{common_description} %prep %autosetup -p1 -a 10 -n node_exporter-%{version} %build export GO111MODULE=on export GOFLAGS=-mod=vendor export BUILDTAGS="netgo osusergo static_build" LDFLAGS="-X github.com/prometheus/common/version.Version=%{version} \ -X github.com/prometheus/common/version.Revision=%{release} \ -X github.com/prometheus/common/version.Branch=tarball \ -X github.com/prometheus/common/version.BuildDate=$(date +%%Y%%m%%d) " %gobuild -o %{gobuilddir}/bin/node_exporter %{goipath} %install install -m 0755 -vd %{buildroot}%{_bindir} install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/ mv %{buildroot}%{_bindir}/node_exporter %{buildroot}%{_bindir}/%{shortname} pushd %{buildroot}%{_bindir} ln -s %{shortname} node_exporter popd # install -Dpm0644 %%{S:1} %%{buildroot}%%{_sysusersdir}/%%{shortname}.conf install -Dpm0644 %{S:2} %{buildroot}%{_unitdir}/%{shortname}.service pushd %{buildroot}%{_unitdir} ln -s %{shortname}.service node_exporter.service popd install -Dpm0644 %{S:3} %{buildroot}%{_sysconfdir}/default/%{shortname} install -Dpm0644 example-rules.yml %{buildroot}%{_datadir}/prometheus/node-exporter/example-rules.yml install -Dpm0644 %{S:4} %{buildroot}%{_sysconfdir}/logrotate.d/%{shortname} mkdir -vp %{buildroot}%{_sharedstatedir}/prometheus/node-exporter # Build man pages. mkdir -vp %{buildroot}/%{_mandir}/man1/ %{buildroot}%{_bindir}/%{shortname} --help-man > \ %{buildroot}/%{_mandir}/man1/%{shortname}.1 sed -i '/^ /d; /^.SH "NAME"/,+1c.SH "NAME"\nprometheus-node-exporter \\- The Prometheus Node-Exporter' \ %{buildroot}/%{_mandir}/man1/%{shortname}.1 %pre getent group prometheus >/dev/null || groupadd -r prometheus getent passwd prometheus >/dev/null || \ useradd -r -g prometheus -d /var/lib/prometheus -s /sbin/nologin \ -c "Prometheus user account" prometheus exit 0 %post %systemd_post %{shortname}.service %preun %systemd_preun %{shortname}.service %postun %systemd_postun_with_restart %{shortname}.service %files %license LICENSE NOTICE %doc docs examples CHANGELOG.md CODE_OF_CONDUCT.md CONTRIBUTING.md %doc MAINTAINERS.md SECURITY.md README.md %{_bindir}/* %config(noreplace) %{_sysconfdir}/default/%{shortname} %config(noreplace) %{_sysconfdir}/logrotate.d/%{shortname} # %%{_sysusersdir}/%%{shortname}.conf %{_unitdir}/%{shortname}.service %{_unitdir}/node_exporter.service %{_mandir}/man1/%{shortname}.1* %{_datadir}/prometheus/node-exporter/example-rules.yml %dir %attr(0755,prometheus,prometheus) %{_sharedstatedir}/prometheus %dir %attr(0755,prometheus,prometheus) %{_sharedstatedir}/prometheus/node-exporter %changelog ## START: Generated by rpmautospec * Fri Jan 28 2022 Robert-André Mauchin - 1.3.1-4 - Symlink for older service name * Sun Jan 16 2022 Robert-André Mauchin - 1.3.1-3 - Add logrotate file * Sat Jan 15 2022 Robert-André Mauchin - 1.3.1-2 - Use legacy user creation * Fri Jan 14 2022 Robert-André Mauchin - 1.3.1-1 - Update to 1.3.1 Close: rhbz#2024811 Close: rhbz#2039257 * Fri Aug 13 2021 Robert-André Mauchin - 1.2.2-1 - Update to 1.2.2 - Close: rhbz#1945422 * Sun Mar 28 18:14:35 CEST 2021 Robert-André Mauchin - 1.1.1-2 - Fix binary location * Wed Feb 17 2021 Robert-André Mauchin - 1.1.1-1 - Initial package ## END: Generated by rpmautospec