Skip to content

Commit 436b109

Browse files
authored
Merge pull request #48 from DrDaveD/more-review-responses
respond to more epel/fedora review comments
2 parents e57a862 + c5c4233 commit 436b109

File tree

3 files changed

+59
-66
lines changed

3 files changed

+59
-66
lines changed

ci/rpm-build

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66
dnf -y install git gpg golang wget rpm-build
77
. /etc/os-release
88
OS_VERSION="${VERSION_ID%.*}"
9-
if [ "$OS_VERSION" -le 9 ]; then
9+
if [ "$OS_VERSION" -lt 20 ]; then
10+
# el, not fedora
1011
dnf install -y epel-release
11-
if [ "$OS_VERSION" == 8 ]; then
12-
dnf install -y epel-rpm-macros
13-
else
14-
dnf install -y rpmautospec-rpm-macros
15-
fi
12+
dnf install -y epel-rpm-macros
1613
fi
1714
if [ "$OS_VERSION" != 8 ]; then
1815
dnf install -y go-rpm-macros

openbao.spec

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,15 @@ Patch0: goversion.patch
2525

2626
BuildRequires: golang-bin
2727
BuildRequires: 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}
3530
BuildRequires: go-rpm-macros
3631
%endif
32+
3733
URL: 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.
3937
Provides: bundled(golang(cel.dev/expr)) = v0.24.0
4038
Provides: bundled(golang(cloud.google.com/go)) = v0.116.0
4139
Provides: bundled(golang(cloud.google.com/go/auth)) = v0.14.1
@@ -423,40 +421,41 @@ GO_LDFLAGS+=" -X github.com/%{name}/%{name}/version.GitCommit="
423421
BUILD_DATE="$(date -d "@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y-%m-%d)"
424422
GO_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

431427
GO_LDFLAGS+=" -B gobuildid"
432428
GO_BUILDTAGS+=" rpm_crashtraceback libtrust_openssl"
433429
GO_LDFLAGS+=" -linkmode=external -compressdwarf=false"
434430
GO_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
455444
LDFLAGS=${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
483482
mkdir -p %{buildroot}%{_sysusersdir}
484483
cp %{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

openbao.spec.in

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,15 @@ Patch0: goversion.patch
2525

2626
BuildRequires: golang-bin
2727
BuildRequires: 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}
3530
BuildRequires: go-rpm-macros
3631
%endif
32+
3733
URL: 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.
3937
# This line gets replaced by bundled provides
4038

4139
%description
@@ -73,40 +71,41 @@ GO_LDFLAGS+=" -X github.com/%{name}/%{name}/version.GitCommit="
7371
BUILD_DATE="$(date -d "@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y-%m-%d)"
7472
GO_LDFLAGS+=" -X github.com/%{name}/%{name}/version.BuildDate=${BUILD_DATE}"
7573

76-
%if 0%{?el8} || "%{?go_debug}" != ""
74+
%if 0%{?el8}
7775
# Define the %%gobuild macro on el8 because it is outdated and doesn't work.
78-
# Also redefine it if %%go_debug is set for now, until %%gobuild is updated
79-
# to accept setting -gcflags.
8076

8177
GO_LDFLAGS+=" -B gobuildid"
8278
GO_BUILDTAGS+=" rpm_crashtraceback libtrust_openssl"
8379
GO_LDFLAGS+=" -linkmode=external -compressdwarf=false"
8480
GO_LDFLAGS+=" -extldflags '%__global_ldflags'"
8581

86-
GO_BUILD_GCFLAGS=
87-
%if "%{?go_debug}" != ""
88-
# add debugging & testing flags
89-
GO_BUILD_GCFLAGS="all=-N -l"
90-
GO_LDFLAGS+=" -X github.com/%{name}/%{name}/version.VersionMetadata=testonly"
91-
# openbao documentation says testonly should not be used for production builds
92-
GO_BUILDTAGS+=" testonly"
93-
%endif
94-
95-
%define gobuild(o:) go build -compiler gc -buildmode pie -ldflags "${GO_LDFLAGS}" -gcflags "${GO_BUILD_GCFLAGS}" -tags "${GO_BUILDTAGS}" %{?**}
82+
%define gobuild go build -compiler gc -buildmode pie -ldflags "${GO_LDFLAGS}" -tags "${GO_BUILDTAGS}"
9683

9784
%else
98-
# Use more modern gobuild macro, which (except for el9) defaults to not use
99-
# go modules. Enable go modules because otherwise it fails to find even
100-
# the openbao/openbao source.
85+
# Use more modern gobuild macro.
86+
87+
# Except for el9, this defaults to not use go modules. Enable go modules
88+
# because it is allowed and is a simpler option than making the additional go
89+
# macros required to manage the non-module form on el8 where they're missing.
10190
%global gomodulesmode GO111MODULE=on
10291

10392
%if 0%{?el9}
104-
# the el9 gobuild macro only accepts LDFLAGS
93+
# the el9 gobuild macro only accepts LDFLAGS, not GO_LDFLAGS
10594
LDFLAGS=${GO_LDFLAGS}
10695
%endif
10796
%endif
10897

98+
%if "%{?go_debug}" != ""
99+
# add debugging & testing flags
100+
GO_BUILD_GCFLAGS="all=-N -l"
101+
GO_LDFLAGS+=" -X github.com/%{name}/%{name}/version.VersionMetadata=testonly"
102+
# openbao documentation says testonly should not be used for production builds
103+
GO_BUILDTAGS+=" testonly"
104+
%gobuild -o bin/bao -gcflags "${GO_BUILD_GCFLAGS}"
105+
%else
109106
%gobuild -o bin/bao
107+
%endif
108+
110109

111110
%install
112111
# starts out in %%{name}-dist-%%{package_version} directory
@@ -133,16 +132,15 @@ ln -s %{name}.service %{buildroot}%{_unitdir}/%{oldname}.service
133132
mkdir -p %{buildroot}%{_sysusersdir}
134133
cp %{name}.conf %{buildroot}%{_sysusersdir}/%{name}.conf
135134

135+
#
136+
# NOTE: we can't run the standard go tests because some of them
137+
# require network access.
138+
#
139+
136140
%pre
137-
%if 0%{?el8}
138-
getent group %{name} > /dev/null || groupadd -r %{name}
139-
getent passwd %{name} > /dev/null || \
140-
useradd -r -d %{_sharedstatedir}/%{name} -g %{name} \
141-
-s /sbin/nologin -c "%{name} secrets manager" %{name}
142-
%endif
141+
%sysusers_create_compat %{name}.conf
143142

144143
%post
145-
setcap cap_ipc_lock=+ep %{_bindir}/bao
146144
%systemd_post %{name}.service
147145

148146
%preun

0 commit comments

Comments
 (0)