[Buildroot] Using a go.mod in a subdirectory

Bryce Johnson bryce at redpinelabs.com
Fri Jun 23 16:59:00 UTC 2023


Hi All,
I was looking at adding a package for shellhub in buildroot.  Two
issues, first one is that the latest needs go 1.20.  I applied this
patch (https://patchwork.ozlabs.org/project/buildroot/list/?series=358451)
to get around that which seems to work so far.   CC: Christian since
I'm testing with his patch set.

The 2nd issue is the agent is in a subdirectory with its own go.mod
that is different from one the on the root directory.

Is there a way to do this better?  Or is the go.mod required to be in
the root of the repo?

SHELLHUB_VERSION = v0.12.3
SHELLHUB_SITE = $(call github,shellhub-io,shellhub,$(SHELLHUB_VERSION))
SHELLHUB_LICENSE = Apache-2.0
SHELLHUB_LICENSE_FILES = LICENSE.md
SHELLHUB_DEPENDENCIES = libxcrypt

SHELLHUB_GOMOD = github.com/shellhub-io/shellhub/agent
SHELLHUB_LDFLAGS =  -X main.AgentVersion=${SHELLHUB_VERSION}

# SHELLHUB_BUILD_TARGETS = agent
# SHELLHUB_INSTALL_BINS = $(notdir $(SHELLHUB_BUILD_TARGETS))

 $(eval $(golang-package))


I can export my output/host/usr/bin and do go build -ldflags "-X
main.AgentVersion=v0.12.3" and it is able to build in that way, so it
seems the host-go 1.20 patch is working.

Bryce



More information about the buildroot mailing list