@@ -25,17 +25,15 @@ Patch0: goversion.patch
2525
2626BuildRequires: golang-bin
2727BuildRequires: systemd-rpm-macros
28- %if 0%{?el8 }
29- BuildRequires: epel-rpm-macros
30- %endif
31- %if 0%{?el9 }
32- BuildRequires: rpmautospec-rpm-macros
33- %endif
28+ %{?sysusers_requires_compat }
3429%if ! 0%{?el8 }
3530BuildRequires: go-rpm-macros
3631%endif
32+
3733URL: https://openbao.org
3834
35+ # The bundled provides are generated from an awk/sed pipeline in the
36+ # make-spec script (which is included in Source1) that reads from go.mod.
3937Provides: bundled(golang(cel.dev/expr)) = v0.24.0
4038Provides: bundled(golang(cloud.google.com/go)) = v0.116.0
4139Provides: bundled(golang(cloud.google.com/go/auth)) = v0.14.1
@@ -423,40 +421,41 @@ GO_LDFLAGS+=" -X github.com/%{name}/%{name}/version.GitCommit="
423421BUILD_DATE= "$(date -d "@${SOURCE_DATE_EPOCH:-$(date +%s )}" +%Y -%m -%d )"
424422GO_LDFLAGS+= " -X github.com/%{name }/%{name }/version.BuildDate= ${BUILD_DATE}"
425423
426- %if 0%{?el8 } || "%{? go_debug }" != ""
424+ %if 0%{?el8 }
427425# Define the %%gobuild macro on el8 because it is outdated and doesn't work.
428- # Also redefine it if %%go_debug is set for now, until %%gobuild is updated
429- # to accept setting -gcflags.
430426
431427GO_LDFLAGS+= " -B gobuildid"
432428GO_BUILDTAGS+= " rpm_crashtraceback libtrust_openssl"
433429GO_LDFLAGS+= " -linkmode= external -compressdwarf= false"
434430GO_LDFLAGS+= " -extldflags '%__global_ldflags'"
435431
436- GO_BUILD_GCFLAGS=
437- %if "%{?go_debug }" != ""
438- # add debugging & testing flags
439- GO_BUILD_GCFLAGS= "all= -N -l"
440- GO_LDFLAGS+= " -X github.com/%{name }/%{name }/version.VersionMetadata= testonly"
441- # openbao documentation says testonly should not be used for production builds
442- GO_BUILDTAGS+= " testonly"
443- %endif
444-
445- %define gobuild(o:) go build -compiler gc -buildmode pie -ldflags "${GO_LDFLAGS}" -gcflags "${GO_BUILD_GCFLAGS}" -tags "${GO_BUILDTAGS}" %{?**}
432+ %define gobuild go build -compiler gc -buildmode pie -ldflags "${GO_LDFLAGS}" -tags "${GO_BUILDTAGS}"
446433
447434%else
448- # Use more modern gobuild macro, which (except for el9) defaults to not use
449- # go modules. Enable go modules because otherwise it fails to find even
450- # the openbao/openbao source.
435+ # Use more modern gobuild macro.
436+
437+ # Except for el9, this defaults to not use go modules. Enable go modules
438+ # because it is allowed and is a simpler option than making the additional go
439+ # macros required to manage the non-module form on el8 where they're missing.
451440%global gomodulesmode GO111MODULE= on
452441
453442%if 0%{?el9 }
454- # the el9 gobuild macro only accepts LDFLAGS
443+ # the el9 gobuild macro only accepts LDFLAGS, not GO_LDFLAGS
455444LDFLAGS= ${GO_LDFLAGS}
456445%endif
457446%endif
458447
448+ %if "%{?go_debug }" != ""
449+ # add debugging & testing flags
450+ GO_BUILD_GCFLAGS= "all= -N -l"
451+ GO_LDFLAGS+= " -X github.com/%{name }/%{name }/version.VersionMetadata= testonly"
452+ # openbao documentation says testonly should not be used for production builds
453+ GO_BUILDTAGS+= " testonly"
454+ %gobuild -o bin/bao -gcflags "${GO_BUILD_GCFLAGS}"
455+ %else
459456%gobuild -o bin/bao
457+ %endif
458+
460459
461460%install
462461# starts out in %%{name}-dist-%%{package_version} directory
@@ -483,16 +482,15 @@ ln -s %{name}.service %{buildroot}%{_unitdir}/%{oldname}.service
483482mkdir -p %{buildroot }%{_sysusersdir }
484483cp %{name }.conf %{buildroot }%{_sysusersdir }/%{name }.conf
485484
485+ #
486+ # NOTE: we can't run the standard go tests because some of them
487+ # require network access.
488+ #
489+
486490%pre
487- %if 0%{?el8 }
488- getent group %{name } > /dev/null || groupadd -r %{name }
489- getent passwd %{name } > /dev/null || \
490- useradd -r -d %{_sharedstatedir }/%{name } -g %{name } \
491- -s /sbin/nologin -c " %{name} secrets manager" %{name }
492- %endif
491+ %sysusers_create_compat %{name }.conf
493492
494493%post
495- setcap cap_ipc_lock=+ep %{_bindir }/bao
496494%systemd_post %{name }.service
497495
498496%preun
0 commit comments