specify minimum go version for port build ?

ok I found I need to put

USES= go:1.23,modules

and also my port tree was not up to date.

However now I am getting a whole bunch of errors:
cmd/hostd/run.go:15:2: cannot find module providing package go.sia.tech/core/consensus: import lookup disabled by -mod=vendor
cmd/hostd/run.go:16:2: cannot find module providing package go.sia.tech/core/gateway: import lookup disabled by -mod=vendor
cmd/hostd/config.go:14:2: cannot find module providing package go.sia.tech/core/types: import lookup disabled by -mod=vendor
cmd/hostd/run.go:18:2: cannot find module providing package go.sia.tech/coreutils: import lookup disabled by -mod=vendor
.... more of the same

here is my current port Makefile

Code:
PORTNAME=       hostd
DISTVERSIONPREFIX=      v
DISTVERSION=    2.0.4
CATEGORIES=     net-p2p

MAINTAINER=     bruno@tinkerbox.org
COMMENT=        Offer your storage space on the Sia network
WWW=            https://sia.tech/host

LICENSE=        MIT
LICENSE_FILE=   ${WRKSRC}/LICENSE

USES=           go:1.23,modules

USE_RC_SUBR=    hostd

USE_GITHUB=     yes
GH_ACCOUNT=     SiaFoundation
GO_TARGET=      ./cmd/hostd
GO_BUILDFLAGS+= -tags='netgo timetzdata' -trimpath

PLIST_FILES=    bin/hostd \
                "@sample ${PREFIX}/etc/hostd.yml.sample" \
                "@sample ${PREFIX}/etc/newsyslog.conf.d/hostd.conf.sample" \
                "@dir(${USERS},${GROUPS},750) /var/lib/${PORTNAME}"

SUB_FILES=      ${PORTNAME}.yml ${PORTNAME}.conf

SUB_LIST=       GROUPS=${GROUPS} \
                USERS=${USERS}

USERS=          ${PORTNAME}
GROUPS=         ${PORTNAME}

post-install:
        ${INSTALL_DATA} ${WRKDIR}/${PORTNAME}.conf ${STAGEDIR}${PREFIX}/etc/newsyslog.conf.d/${PORTNAME}.conf.sample
        ${INSTALL_DATA} ${WRKDIR}/${PORTNAME}.yml ${STAGEDIR}${PREFIX}/etc/${PORTNAME}.yml.sample
        ${INSTALL} -d ${STAGEDIR}/var/lib/${PORTNAME}

post-patch:
        ${REINPLACE_CMD} -e "s|BUILDTIME|$$(date +%s)|g" ${WRKSRC}/build/meta.go

.include <bsd.port.mk>

In my previous port, I was just using the lines

Code:
USES=           go:modules
USE_RC_SUBR=   hostd

GO_MODULE=      go.sia.tech/hostd

however that is not working anymore as the module is apparently not published on pkg.go.dev, so I switched to the form above specifying the github account. My guess is this causes some dependency problems which I have no idea how to solve...

note that of course I can build locally without problem, it's just the port fetching/build that is failing

SOLVED: need the USE_GITHUB and also do the GH_TUPLE described here https://docs.freebsd.org/en/books/porters-handbook/special/#using-go
 
ok so actually it is not solved. I was able to build and install, even create a package, however, I have the impression it only succeeded because some files where leftover during my previous attempts. After cleaning and trying to build again I am hitting an issue where one of the dependencies listed in GH_TUPLE can not be downloaded
so I generate the initial distinfo with make makesum, then generate the GH_TUPLE with make gomod-vendor, this succeeds.
then the next step with make makesum to generate distinfo for all dependencies fails
for example I have in the Makefile
Code:
GH_TUPLE=       \
                SiaFoundation:core:v0.10.1:siafoundation_core/vendor/go.sia.tech/core \
                SiaFoundation:coreutils:v0.11.1:siafoundation_coreutils/vendor/go.sia.tech/coreutils \
                SiaFoundation:jape:v0.12.1:siafoundation_jape/vendor/go.sia.tech/jape \
                SiaFoundation:mux:v1.3.0:siafoundation_mux/vendor/go.sia.tech/mux \
                SiaFoundation:web:5611d44a533e:siafoundation_web/vendor/go.sia.tech/web \
                SiaFoundation:web:v0.58.0:siafoundation_web_1/vendor/go.sia.tech/web/hostd \

and it fails with

...
=> SiaFoundation-web-v0.58.0_GH0.tar.gz doesn't seem to exist in /usr/ports/distfiles/.
=> Attempting to fetch https://codeload.github.com/SiaFoun...0?dummy=/SiaFoundation-web-v0.58.0_GH0.tar.gz
fetch: https://codeload.github.com/SiaFoun...0?dummy=/SiaFoundation-web-v0.58.0_GH0.tar.gz: Not Found
=> Attempting to fetch http://distcache.freebsd.org/ports-distfiles/SiaFoundation-web-v0.58.0_GH0.tar.gz
fetch: http://distcache.freebsd.org/ports-distfiles/SiaFoundation-web-v0.58.0_GH0.tar.gz: Not Found
=> Couldn't fetch it - please try to retrieve this
=> port manually into /usr/ports/distfiles/ and try again.

now this looks fishy to me because the go.mod files specifies

Code:
module go.sia.tech/hostd/v2 // v2.0.4

go 1.23.1

toolchain go1.23.2

require (
    github.com/aws/aws-sdk-go v1.55.6
    github.com/cloudflare/cloudflare-go v0.115.0
    github.com/hashicorp/golang-lru/v2 v2.0.7
    github.com/mattn/go-sqlite3 v1.14.24
    github.com/shopspring/decimal v1.4.0
    go.sia.tech/core v0.10.4
    go.sia.tech/coreutils v0.12.1
    go.sia.tech/jape v0.12.1
    go.sia.tech/web/hostd v0.58.0

....

where I wonder is why this go.sia.tech/web/hostd v0.58.0 turns into https://codeload.github.com/SiaFoun...0?dummy=/SiaFoundation-web-v0.58.0_GH0.tar.gz, it does not seem right to me ? (where did the hostd go? )
but then I see it fetch just fine
=> go-yaml-yaml-v3.0.1_GH0.tar.gz doesn't seem to exist in /usr/ports/distfiles/.
=> Attempting to fetch https://codeload.github.com/go-yaml/yaml/tar.gz/v3.0.1?dummy=/go-yaml-yaml-v3.0.1_GH0.tar.gz
fetch: https://codeload.github.com/go-yaml/yaml/tar.gz/v3.0.1?dummy=/go-yaml-yaml-v3.0.1_GH0.tar.gz: size of remote file is not known
go-yaml-yaml-v3.0.1_GH0.tar.gz

which in the GH_TUPLE is
go-yaml:yaml:v3.0.1:go_yaml_yaml_1/vendor/gopkg.in/yaml.v3

Is this URL really not right ? I don't get it...
 
What you're doing is way above my level, but I do hope you succeed. I want to migrate to FreeBSD, specifically to continue developing applications in Go. So I'm going to be cheeky and ask if you will consider porting the latest Go version - currently at v1.24.1. Or perhaps you'll provide a way to update Go in place once it's installed. Whatever it is you're doing, I want to say thank you.
 
So anyone can help ? I don't think I am doing anything wrong here, and it's trying to fetch a tarball that does not exist
How are those links to the tarball created ? any pointers ? could it be a github issue or in how the api is used ?
 
I think it doesn't quite understand the structure of that repository. It's a little weird.

Don't know if this will work, but try changing the line to:
Code:
SiaFoundation:web:hostd/v0.58.0:siafoundation_web_1/vendor/go.sia.tech/web/hostd
 
hey that worked, thanks a lot SirDice ! ... but only as far as fetching all the dependencies

I changed the line
SiaFoundation:web:v0.58.0:siafoundation_web_1/vendor/go.sia.tech/web/hostd

into
SiaFoundation:web:hostd/v0.58.0:siafoundation_web_1/vendor/go.sia.tech/web/hostd

so there seems to be a bug with the gomod-vendor target ?

but now I get build errors

Code:
===>  Building for hostd-2.0.4
(cd /usr/ports/net-p2p/hostd/work/hostd-2.0.4;  for t in ./cmd/hostd; do  out=$(/usr/bin/basename $(echo ${t} |  /usr/bin/sed -Ee 's/^[^:]*:([^:]+).*$/\1/' -e 's/^\.$/hostd/'));  pkg=$(echo ${t} |  /usr/bin/sed -Ee 's/^([^:]*).*$/\1/' -e 's/^hostd$/./');  echo "===>  Building ${out} from ${pkg}";  /usr/bin/env -i HOME=/usr/ports/net-p2p/hostd/work  MACHINE_ARCH=amd64  PWD="${PWD}"  GIT_CEILING_DIRECTORIES=/usr/ports/net-p2p/hostd/work  __MAKE_CONF=/nonexistent OSVERSION=1400097 PATH=/usr/ports/net-p2p/hostd/work/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin TERM=screen XDG_DATA_HOME=/usr/ports/net-p2p/hostd/work  XDG_CONFIG_HOME=/usr/ports/net-p2p/hostd/work  XDG_CACHE_HOME=/usr/ports/net-p2p/hostd/work/.cache  HOME=/usr/ports/net-p2p/hostd/work PATH=/usr/ports/net-p2p/hostd/work/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin PKG_CONFIG_LIBDIR=/usr/ports/net-p2p/hostd/work/.pkgconfig:/usr/local/libdata/pkgconfig:/usr/local/share/pkgconfig:/usr/libdata/pkgconfig MK_DEBUG_FILES=no MK_KERNEL_SYMBOLS=no SHELL=/bin/sh NO_LINT=YES PREFIX=/usr/local  LOCALBASE=/usr/local  CC="cc" CFLAGS="-O2 -pipe  -fstack-protector-strong -fno-strict-aliasing "  CPP="cpp" CPPFLAGS=""  LDFLAGS=" -fstack-protector-strong " LIBS=""  CXX="c++" CXXFLAGS="-O2 -pipe -fstack-protector-strong -fno-strict-aliasing  " BSD_INSTALL_PROGRAM="install  -s -m 555"  BSD_INSTALL_LIB="install  -s -m 0644"  BSD_INSTALL_SCRIPT="install  -m 555"  BSD_INSTALL_DATA="install  -m 0644"  BSD_INSTALL_MAN="install  -m 444" CGO_ENABLED=1  CGO_CFLAGS="-I/usr/local/include"  CGO_LDFLAGS="-L/usr/local/lib"  GOAMD64=  GOARM=  GOTMPDIR="/usr/ports/net-p2p/hostd/work" GOPATH="/usr/ports/distfiles/go/net-p2p_hostd"  GOBIN="/usr/ports/net-p2p/hostd/work/bin"  GO111MODULE=on  GOFLAGS=-modcacherw  GOSUMDB=sum.golang.org GO_NO_VENDOR_CHECKS=1 GOMAXPROCS=4 GOPROXY=off /usr/local/bin/go123 build -tags='netgo timetzdata' -trimpath -buildmode=exe -v -trimpath -ldflags=-s -buildvcs=false -mod=vendor  -o /usr/ports/net-p2p/hostd/work/bin/${out}  ${pkg};  done)
===>  Building hostd from ./cmd/hostd
go: ignoring package go.sia.tech/core/gateway which exists in the vendor directory but is missing from vendor/modules.txt. To sync the vendor directory run go mod vendor.
go: ignoring package go.sia.tech/core/consensus which exists in the vendor directory but is missing from vendor/modules.txt. To sync the vendor directory run go mod vendor.

if at that point I do:

cd work/hostd-2.0.4/ ; go mod vendor

then it successfully builds with just make

also, this works:
make clean; make gomod-vendor; make

so the vendor/modules.txt is not generated by the build. isn't that supposed to happen automatically ? just not sure if that is a bug or again something I am missing
 
hey that worked, thanks a lot SirDice ! ... but only as far as fetching all the dependencies

I changed the line
SiaFoundation:web:v0.58.0:siafoundation_web_1/vendor/go.sia.tech/web/hostd

into
SiaFoundation:web:hostd/v0.58.0:siafoundation_web_1/vendor/go.sia.tech/web/hostd

so there seems to be a bug with the gomod-vendor target ?

but now I get build errors

Code:
===>  Building for hostd-2.0.4
(cd /usr/ports/net-p2p/hostd/work/hostd-2.0.4;  for t in ./cmd/hostd; do  out=$(/usr/bin/basename $(echo ${t} |  /usr/bin/sed -Ee 's/^[^:]*:([^:]+).*$/\1/' -e 's/^\.$/hostd/'));  pkg=$(echo ${t} |  /usr/bin/sed -Ee 's/^([^:]*).*$/\1/' -e 's/^hostd$/./');  echo "===>  Building ${out} from ${pkg}";  /usr/bin/env -i HOME=/usr/ports/net-p2p/hostd/work  MACHINE_ARCH=amd64  PWD="${PWD}"  GIT_CEILING_DIRECTORIES=/usr/ports/net-p2p/hostd/work  __MAKE_CONF=/nonexistent OSVERSION=1400097 PATH=/usr/ports/net-p2p/hostd/work/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin TERM=screen XDG_DATA_HOME=/usr/ports/net-p2p/hostd/work  XDG_CONFIG_HOME=/usr/ports/net-p2p/hostd/work  XDG_CACHE_HOME=/usr/ports/net-p2p/hostd/work/.cache  HOME=/usr/ports/net-p2p/hostd/work PATH=/usr/ports/net-p2p/hostd/work/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin PKG_CONFIG_LIBDIR=/usr/ports/net-p2p/hostd/work/.pkgconfig:/usr/local/libdata/pkgconfig:/usr/local/share/pkgconfig:/usr/libdata/pkgconfig MK_DEBUG_FILES=no MK_KERNEL_SYMBOLS=no SHELL=/bin/sh NO_LINT=YES PREFIX=/usr/local  LOCALBASE=/usr/local  CC="cc" CFLAGS="-O2 -pipe  -fstack-protector-strong -fno-strict-aliasing "  CPP="cpp" CPPFLAGS=""  LDFLAGS=" -fstack-protector-strong " LIBS=""  CXX="c++" CXXFLAGS="-O2 -pipe -fstack-protector-strong -fno-strict-aliasing  " BSD_INSTALL_PROGRAM="install  -s -m 555"  BSD_INSTALL_LIB="install  -s -m 0644"  BSD_INSTALL_SCRIPT="install  -m 555"  BSD_INSTALL_DATA="install  -m 0644"  BSD_INSTALL_MAN="install  -m 444" CGO_ENABLED=1  CGO_CFLAGS="-I/usr/local/include"  CGO_LDFLAGS="-L/usr/local/lib"  GOAMD64=  GOARM=  GOTMPDIR="/usr/ports/net-p2p/hostd/work" GOPATH="/usr/ports/distfiles/go/net-p2p_hostd"  GOBIN="/usr/ports/net-p2p/hostd/work/bin"  GO111MODULE=on  GOFLAGS=-modcacherw  GOSUMDB=sum.golang.org GO_NO_VENDOR_CHECKS=1 GOMAXPROCS=4 GOPROXY=off /usr/local/bin/go123 build -tags='netgo timetzdata' -trimpath -buildmode=exe -v -trimpath -ldflags=-s -buildvcs=false -mod=vendor  -o /usr/ports/net-p2p/hostd/work/bin/${out}  ${pkg};  done)
===>  Building hostd from ./cmd/hostd
go: ignoring package go.sia.tech/core/gateway which exists in the vendor directory but is missing from vendor/modules.txt. To sync the vendor directory run go mod vendor.
go: ignoring package go.sia.tech/core/consensus which exists in the vendor directory but is missing from vendor/modules.txt. To sync the vendor directory run go mod vendor.

if at that point I do:

cd work/hostd-2.0.4/ ; go mod vendor

then it successfully builds with just make

also, this works:
make clean; make gomod-vendor; make

so the vendor/modules.txt is not generated by the build. isn't that supposed to happen automatically ? just not sure if that is a bug or again something I am missing
Can you send me your port files so I can try to find a solution? You can zip it and attach here as attachment. thanks.
 
Can you send me your port files so I can try to find a solution? You can zip it and attach here as attachment. thanks.
hey thanks, I had not noticed your answer before posting the above
I got it to build. Are you a comitter ? If you can take a look, hopefully it's good and can be added to the ports ?
 
It's been added quite recently (8 days ago), so only available in latest. It's not in quarterly yet. 2025Q2 will be branched soon (beginning of April), then it'll be in quarterly.
 
Back
Top