File helm.spec of Package helm

%define realname helm
%define srcext   tar.bz2

%if ! 0%{?go_os:1}
%define go_os %(go env GOOS)
%endif
%if ! 0%{?go_arch:1}
%define go_arch %(go env GOARCH)
%endif

# Common info
Name:          %{realname}
Version:       0
Release:       wiz%{?extraver:0.}1%{?dist}
License:       Apache-2.0
Group:         System/Management
URL:           https://helm.sh/
Summary:       The Kubernetes Package Manager

# Build-time parameters
BuildRequires: go
BuildRoot:     %{_tmppath}/%{name}-root
Source0:       %{realname}-%{version}.%{srcext}
# cd helm; go mod vendor -v && tar -Jcvf ../vendor.tar.xz vendor && rm -rf vendor/; cd ..
Source1:       vendor.tar.xz
# Completions
Source11:      helm-completions

%description
Helm is a tool for managing Charts. Charts are packages of pre-configured
Kubernetes resources.

Use Helm to:

  * Find and use popular software packaged as Helm Charts to run in Kubernetes
  * Share your own applications as Helm Charts
  * Create reproducible builds of your Kubernetes applications
  * Intelligently manage your Kubernetes manifest files
  * Manage releases of Helm packages

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{version}%{?extraver} -a1

# Build step (compile/build binaries, documentation, etc)
%build
export CGO_CFLAGS='%{optflags} %{?gcc_lto}'
export CGO_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro %{?gcc_lto}'
%{__sed} -ri 's/CGO_ENABLED=0/CGO_ENABLED=1/' Makefile
%{__make} %{?_smp_mflags} \
  GOFLAGS='-a -v -mod=vendor -gcflags=-dwarf=false' \
  GIT_COMMIT=0 \
  GIT_SHA=0 \
  GIT_TAG=v%{version} \
  GIT_DIRTY=clean \
  VERSION=%{version}

# Install built stuff
%install
%{__install} -D -m0755 bin/helm %{buildroot}%{_bindir}/helm
%{__install} -d -m0755 %{buildroot}%{_sysconfdir}/profile.d
cat > %{buildroot}%{_sysconfdir}/profile.d/helm.sh <<EOF
# Helm plugins search list
export HELM_PLUGINS=%{_libexecdir}/helm/plugins:\$HOME/.local/share/helm/plugins

EOF
# Completions
cat %{S:11} >> %{buildroot}%{_sysconfdir}/profile.d/helm.sh

# Cleanup
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}

# Files
%files
%defattr(-,root,root)
%license LICENSE
%doc ADOPTERS.md CONTRIBUTING.md KEYS README.md SECURITY.md code-of-conduct.md
%config(noreplace) %{_sysconfdir}/profile.d/helm.sh
%{_bindir}/helm

%changelog
openSUSE Build Service is sponsored by