From 432fde45affd66d2a42a0a578c822a23d828a8a9 Mon Sep 17 00:00:00 2001 From: Doug Rabson Date: Tue, 8 Jul 2025 13:12:15 +0100 Subject: [PATCH] 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 --- Makefile | 8 +------- pkg/api/runtime.go | 2 +- pkg/cli/server/stress_test.go | 2 +- pkg/test/common/rlimit_freebsd.go | 3 +++ pkg/test/common/rlimit_linux.go | 3 +++ 5 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 pkg/test/common/rlimit_freebsd.go create mode 100644 pkg/test/common/rlimit_linux.go diff --git a/Makefile b/Makefile index cb2540fa..5ccb218a 100644 --- a/Makefile +++ b/Makefile @@ -123,7 +123,7 @@ build-metadata: $(if $(findstring ui,$(BUILD_LABELS)), ui) go list $(GO_CMD_TAGS) -f '{{ join .GoFiles "\n" }}' ./... | sort -u .PHONY: gen-protobuf -gen-protobuf: check-not-freebds $(PROTOC) +gen-protobuf: $(PROTOC) $(PROTOC) --experimental_allow_proto3_optional \ --proto_path=$(TOP_LEVEL)/pkg/meta/proto \ --go_out=$(TOP_LEVEL)/pkg/meta/proto \ @@ -612,12 +612,6 @@ ifneq ($(shell go env GOOS),linux) $(error makefile target can be run only on linux) endif -.PHONY: check-not-freebds -check-not-freebds: -ifeq ($(shell go env GOOS),freebsd) - $(error makefile target can't be run on freebsd) -endif - .PHONY: check-compatibility check-compatibility: ifeq ($(OS),freebsd) diff --git a/pkg/api/runtime.go b/pkg/api/runtime.go index d3458166..e2c9023f 100644 --- a/pkg/api/runtime.go +++ b/pkg/api/runtime.go @@ -20,7 +20,7 @@ func DumpRuntimeParams(log log.Logger) { err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit) if err == nil { - evt = evt.Uint64("max. open files", uint64(rLimit.Cur)) //nolint: unconvert // required for *BSD + evt = evt.Uint64("max. open files", uint64(rLimit.Cur)) //nolint: unconvert,gosec // required for *BSD } if content, err := os.ReadFile("/proc/sys/net/core/somaxconn"); err == nil { diff --git a/pkg/cli/server/stress_test.go b/pkg/cli/server/stress_test.go index 7ef2c2c5..6a13dc30 100644 --- a/pkg/cli/server/stress_test.go +++ b/pkg/cli/server/stress_test.go @@ -193,7 +193,7 @@ func worker(id int, zotPort, rootDir string) { } } -func setMaxOpenFilesLimit(limit uint64) (uint64, error) { +func setMaxOpenFilesLimit(limit test.RlimT) (test.RlimT, error) { var rLimit syscall.Rlimit err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit) diff --git a/pkg/test/common/rlimit_freebsd.go b/pkg/test/common/rlimit_freebsd.go new file mode 100644 index 00000000..2ba0347b --- /dev/null +++ b/pkg/test/common/rlimit_freebsd.go @@ -0,0 +1,3 @@ +package common + +type RlimT = int64 diff --git a/pkg/test/common/rlimit_linux.go b/pkg/test/common/rlimit_linux.go new file mode 100644 index 00000000..5f1d87b0 --- /dev/null +++ b/pkg/test/common/rlimit_linux.go @@ -0,0 +1,3 @@ +package common + +type RlimT = uint64