File step-cli.spec of Package step-cli
%define realname cli
%define realver 0.23.2
%define srcext tar.gz
%define builddate %(date -u '+%Y-%m-%d %H:%M UTC')
# Common info
Name: step-cli
Version: %{realver}
Release: wiz%{?extraver:0.}1%{?dist}
License: Apache-2.0
Group: Productivity/Security
URL: https://smallstep.com/cli
Summary: The command-line interface for all things Smallstep
# Build-time parameters
BuildRequires: go >= 1.18
BuildRequires: systemd-rpm-macros
BuildRoot: %{_tmppath}/%{name}-root
Source0: https://codeload.github.com/smallstep/cli/%{srcext}/refs/tags/v%{realver}#/%{realname}-%{version}%{?extraver}.%{srcext}
# go mod vendor -v && tar -Jcvf vendor ../vendor.tar.xz
Source11: vendor.tar.xz
%description
step is an open-source command-line tool for developers, operators, and security
professionals to configure and automate the smallstep toolchain and a swiss-army
knife for day-to-day operations of open standard identity technologies.
# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{version}%{?extraver} -a11
# Build step (compile/build binaries, documentation, etc)
%build
export GOCACHE=$(pwd -P)/.gocache
export GOTRACEBACK=crash
export CGO_ENABLED=1
# Build static assets
go build \
-v \
-mod=vendor \
-buildmode=pie \
-gcflags=all='-dwarf=false' \
-ldflags=all='-s -w -X "main.Version=%{version}" -X "main.BuildTime=%{builddate}"' \
-o bin/step \
./cmd/step
# Install built stuff
%install
%{__install} -D -m0755 bin/step %{buildroot}%{_bindir}/step
%{__install} -d -m0755 %{buildroot}%{_unitdir}
%{__install} -m0644 systemd/*.{service,target,timer} %{buildroot}%{_unitdir}/
# Cleanup
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
# Files list
%files
%defattr(-,root,root)
%license LICENSE
%doc CHANGELOG.md README.md SECURITY.md
%{_bindir}/step
%{_unitdir}/*
%if 0%{?suse_version}
%pre
%{service_add_pre cert-renewer.target}
%{service_add_pre cert-renewer@.service}
%{service_add_pre ssh-cert-renewer.service}
%{service_add_pre ssh-cert-renewer.timer}
%post
%{service_add_post cert-renewer.target}
%{service_add_post cert-renewer@.service}
%{service_add_post ssh-cert-renewer.service}
%{service_add_post ssh-cert-renewer.timer}
%preun
%{service_del_preun cert-renewer.target}
%{service_del_preun cert-renewer@.service}
%{service_del_preun ssh-cert-renewer.service}
%{service_del_preun ssh-cert-renewer.timer}
%postun
%{service_del_postun cert-renewer.target}
%{service_del_postun cert-renewer@.service}
%{service_del_postun ssh-cert-renewer.service}
%{service_del_postun ssh-cert-renewer.timer}
%endif
%changelog