Skip to content

Commit 432fde4

Browse files
authored
Fix building zot natively on FreeBSD (#3247)
fix: allow zot to build on a FreeBSD host (#3246) The build works as long as the protoc package is installed on the build host. This also fixes lint checks when building on FreeBSD, working around common lint complaints caused by the fact that rlim_t is int64 on FreeBSD. Signed-off-by: Doug Rabson <dfr@rabson.org>
1 parent e33a937 commit 432fde4

5 files changed

Lines changed: 9 additions & 9 deletions

File tree

Makefile

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ build-metadata: $(if $(findstring ui,$(BUILD_LABELS)), ui)
123123
go list $(GO_CMD_TAGS) -f '{{ join .GoFiles "\n" }}' ./... | sort -u
124124

125125
.PHONY: gen-protobuf
126-
gen-protobuf: check-not-freebds $(PROTOC)
126+
gen-protobuf: $(PROTOC)
127127
$(PROTOC) --experimental_allow_proto3_optional \
128128
--proto_path=$(TOP_LEVEL)/pkg/meta/proto \
129129
--go_out=$(TOP_LEVEL)/pkg/meta/proto \
@@ -612,12 +612,6 @@ ifneq ($(shell go env GOOS),linux)
612612
$(error makefile target can be run only on linux)
613613
endif
614614

615-
.PHONY: check-not-freebds
616-
check-not-freebds:
617-
ifeq ($(shell go env GOOS),freebsd)
618-
$(error makefile target can't be run on freebsd)
619-
endif
620-
621615
.PHONY: check-compatibility
622616
check-compatibility:
623617
ifeq ($(OS),freebsd)

pkg/api/runtime.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func DumpRuntimeParams(log log.Logger) {
2020

2121
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
2222
if err == nil {
23-
evt = evt.Uint64("max. open files", uint64(rLimit.Cur)) //nolint: unconvert // required for *BSD
23+
evt = evt.Uint64("max. open files", uint64(rLimit.Cur)) //nolint: unconvert,gosec // required for *BSD
2424
}
2525

2626
if content, err := os.ReadFile("/proc/sys/net/core/somaxconn"); err == nil {

pkg/cli/server/stress_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func worker(id int, zotPort, rootDir string) {
193193
}
194194
}
195195

196-
func setMaxOpenFilesLimit(limit uint64) (uint64, error) {
196+
func setMaxOpenFilesLimit(limit test.RlimT) (test.RlimT, error) {
197197
var rLimit syscall.Rlimit
198198

199199
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)

pkg/test/common/rlimit_freebsd.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package common
2+
3+
type RlimT = int64

pkg/test/common/rlimit_linux.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package common
2+
3+
type RlimT = uint64

0 commit comments

Comments
 (0)