@@ -12,13 +12,28 @@ Release: %autorelease
1212Summary: A tool for securely accessing secrets
1313# See LICENSE for primary license
1414# See LICENSE_DEPENDENCIES.md for bundled dependencies
15+ # CC0-1.0 is normally not permissible for code in Fedora. Because the vendored Go package
16+ # github.com/zeebo/blake3 it applies to has been available in Fedora as golang-github-zeebo-blake3
17+ # since before the cutoff date 2022-08-01, the exception to use it also applies here.
1518License: MPL-2.0 AND AFL-2.0 AND Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND CC0-1.0 AND ISC AND MIT
16- Source0: https://github.com/opensciencegrid/%{name }-rpm/releases/download/v%{package_version }/%{name }-rpm-%{package_version }.tar.gz
17- Source1: https://github.com/openbao/%{name }/releases/download/v%{package_version }/%{name }-dist-%{package_version }.tar.xz
19+ Source0: https://github.com/openbao/%{name }/releases/download/v%{package_version }/%{name }-dist-%{package_version }.tar.xz
20+ # This includes extra files to include in the package and is used as a
21+ # single branch to track changes to them and a place where checks can be
22+ # automated using github actions.
23+ Source1: https://github.com/opensciencegrid/%{name }-rpm/releases/download/v%{package_version }/%{name }-rpm-%{package_version }.tar.gz
1824Patch0: goversion.patch
1925
2026BuildRequires: golang-bin
2127BuildRequires: 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
34+ %if ! 0%{?el8 }
35+ BuildRequires: go-rpm-macros
36+ %endif
2237URL: https://openbao.org
2338
2439Provides: bundled(golang(cel.dev/expr)) = v0.24.0
@@ -392,8 +407,8 @@ Provides a compatibility layer on top of OpenBao to emulate a Hashicorp
392407Vault package.
393408
394409%prep
395- %setup -q -n %{name }-rpm-%{package_version }
396- %setup -q -T -b 1 - n %{name }-dist-%{package_version }
410+ %setup -q -T -b 1 - n %{name }-rpm-%{package_version }
411+ %setup -q -n %{name }-dist-%{package_version }
397412%autopatch
398413
399414%build
@@ -402,32 +417,46 @@ Vault package.
402417# this prevents it from complaining that ui assets are too old
403418touch http/web_ui/index.html
404419
405- GO_BUILD_MODE= "-buildmode pie"
406- GO_BUILD_GCFLAGS=
407- GO_BUILD_LDFLAGS= "-X github.com/%{name }/%{name }/version.fullVersion= %{version }-%{release }"
408- GO_BUILD_LDFLAGS+= " -X github.com/%{name }/%{name }/version.GitCommit= "
420+ GO_BUILDTAGS= "ui"
421+ GO_LDFLAGS= "-X github.com/%{name }/%{name }/version.fullVersion= %{version }-%{release }"
422+ GO_LDFLAGS+= " -X github.com/%{name }/%{name }/version.GitCommit= "
409423BUILD_DATE= "$(date -d "@${SOURCE_DATE_EPOCH:-$(date +%s )}" +%Y -%m -%d )"
410- GO_BUILD_LDFLAGS+= " -X github.com/%{name }/%{name }/version.BuildDate= ${BUILD_DATE}"
411- GO_BUILD_LDFLAGS+= " -B gobuildid"
412- GO_BUILD_TAGS= "ui"
424+ GO_LDFLAGS+= " -X github.com/%{name }/%{name }/version.BuildDate= ${BUILD_DATE}"
425+
426+ %if 0%{?el8 } || "%{?go_debug }" != ""
427+ # 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.
413430
414- # These are from the %%gobuild macro which we can't use because it doesn't
415- # allow for extra tags (nor extra gcflags for debug mode).
416- GO_BUILD_TAGS+= " rpm_crashtraceback libtrust_openssl"
417- GO_BUILD_LDFLAGS+= " -linkmode= external -compressdwarf= false"
418- GO_BUILD_LDFLAGS+= " -extldflags '%__global_ldflags'"
431+ GO_LDFLAGS+= " -B gobuildid"
432+ GO_BUILDTAGS+= " rpm_crashtraceback libtrust_openssl"
433+ GO_LDFLAGS+= " -linkmode= external -compressdwarf= false"
434+ GO_LDFLAGS+= " -extldflags '%__global_ldflags'"
419435
436+ GO_BUILD_GCFLAGS=
420437%if "%{?go_debug }" != ""
421438# add debugging & testing flags
422439GO_BUILD_GCFLAGS= "all= -N -l"
423- GO_BUILD_LDFLAGS += " -X github.com/%{name }/%{name }/version.VersionMetadata= testonly"
440+ GO_LDFLAGS += " -X github.com/%{name }/%{name }/version.VersionMetadata= testonly"
424441# openbao documentation says testonly should not be used for production builds
425- GO_BUILD_TAGS += " testonly"
442+ GO_BUILDTAGS += " testonly"
426443%endif
427444
428- # instructions from https://openbao.org/docs/contributing/packaging/#ui-release
429- # The ui is pre-prepared in the source distribution tarball
430- go build ${GO_BUILD_MODE} -gcflags "${GO_BUILD_GCFLAGS}" -ldflags "${GO_BUILD_LDFLAGS}" -buildvcs= false -o bin/bao -tags "${GO_BUILD_TAGS}"
445+ %define gobuild(o:) go build -compiler gc -buildmode pie -ldflags "${GO_LDFLAGS}" -gcflags "${GO_BUILD_GCFLAGS}" -tags "${GO_BUILDTAGS}" %{?**}
446+
447+ %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.
451+ %global gomodulesmode GO111MODULE= on
452+
453+ %if 0%{?el9 }
454+ # the el9 gobuild macro only accepts LDFLAGS
455+ LDFLAGS= ${GO_LDFLAGS}
456+ %endif
457+ %endif
458+
459+ %gobuild -o bin/bao
431460
432461%install
433462# starts out in %%{name}-dist-%%{package_version} directory
@@ -455,10 +484,12 @@ mkdir -p %{buildroot}%{_sysusersdir}
455484cp %{name }.conf %{buildroot }%{_sysusersdir }/%{name }.conf
456485
457486%pre
487+ %if 0%{?el8 }
458488getent group %{name } > /dev/null || groupadd -r %{name }
459489getent passwd %{name } > /dev/null || \
460490 useradd -r -d %{_sharedstatedir }/%{name } -g %{name } \
461491 -s /sbin/nologin -c " %{name} secrets manager" %{name }
492+ %endif
462493
463494%post
464495setcap cap_ipc_lock=+ep %{_bindir }/bao
0 commit comments