File golang-github-prometheus-promu.spec of Package golang-github-prometheus-promu
#
# spec file for package golang-github-prometheus-promu
#
# 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/
#
%if 0%{?suse_version}
%{go_nostrip}
%else
%global debug_package %{nil}
%endif
%global goipath github.com/prometheus/promu
Name: golang-github-prometheus-promu
Version: 0.5.0
Release: 0
Summary: Prometheus Utility Tool
License: Apache-2.0
Group: System/Management
URL: https://github.com/prometheus/promu
Source: promu-%{version}.tar.gz
Source1: vendor.tar.gz
%if 0%{?suse_version}
BuildRequires: golang-packaging
BuildRequires: golang(API) = 1.15
%else
BuildRequires: golang >= 1.15
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version}
%{go_provides}
%endif
%description
The Prometheus Utility Tool is used by the Prometheus project to build other components.
%prep
%setup -q -n promu-%{version}
%setup -q -T -D -a 1 -n promu-%{version}
%build
%if 0%{?suse_version}
%goprep %goipath
%else
mkdir -p ${RPM_BUILD_DIR}/go/src/%goipath
mkdir -p ${RPM_BUILD_DIR}/contrib/src
cp -rpT $(pwd) ${RPM_BUILD_DIR}/go/src/%goipath/
cp -rpT %{_datadir}/gocode/src ${RPM_BUILD_DIR}/contrib/src || :
%endif
export VERSION=%{version}
export CGO_ENABLED=0
go build \
-mod=vendor \
-buildmode=pie \
-ldflags "-s -w -X main.version=$VERSION -linkmode=external" \
-o promu ;
%install
install -D -m 0755 promu "%{buildroot}/%{_bindir}/promu"
%if 0%{?suse_version}
%gosrc
%else
mkdir -p ${RPM_BUILD_ROOT}/usr/share/gocode/src
files=$(find ${RPM_BUILD_DIR}/go/src \
-type f \
\( -iname "*.go" \
-o -iname "*.s" \
-o -iname "*.h" \
-o -iname "BUILD" \
-o -iname "BUILD.bazel" \
-o -iname "WORKSPACE" \))
for file in ${files}; do
install -D -m0644 ${file} ${RPM_BUILD_ROOT}/usr/share/gocode/src/${file#${RPM_BUILD_DIR}/go/src/}
done
%endif
%if 0%{?suse_version}
%gofilelist
%else
mkdir -p ${RPM_BUILD_ROOT}/usr/share/gocode/src
for path in $(find ${RPM_BUILD_ROOT}/usr/share/gocode/src); do
if [[ -d ${path} ]]; then
echo "%dir ${path#${RPM_BUILD_ROOT}}" >> file.lst
else
echo "${path#${RPM_BUILD_ROOT}}" >> file.lst
fi
done
%endif
%files -f file.lst
%defattr(-,root,root,-)
%doc README.md
%license LICENSE
%{_bindir}/promu
%changelog