diff --git a/Mk/Uses/go.mk b/Mk/Uses/go.mk --- a/Mk/Uses/go.mk +++ b/Mk/Uses/go.mk @@ -23,6 +23,16 @@ # In most cases, this is the only required variable for ports that # use Go modules. # +# GO_MOD_DIST +# The location to download the go.mod file if GO_MODULE is used. +# The default is empty, so it is loaded from GO_PROXY. +# Set it to "gitlab" and make sure GL_PROJECT is defined to download +# the "go.mod" from gitlab. +# Set it to "github" and make sure GH_PROJECT is defined to download +# the "go.mod" from github. +# You can also set it completely manually a URI without go.mod in it, +# is attached automatically to the URI. +# # GO_PKGNAME # The name of the package when building in GOPATH mode. This # is the directory that will be created in ${GOPATH}/src. If not set @@ -143,9 +153,25 @@ GO_MODVERSION= ${GO_MODULE:C/^([^@]*)(@([^@]*)?)/\2/:M@*:S/^@//:S/^$/${DISTVERSIONFULL}/} GO_MODFILE= ${GO_MODVERSION}.mod GO_DISTFILE= ${GO_MODVERSION}.zip +# If GO_MOD_DIST is gitlab, download the go.mod from gitlab by the defined GL_ACCOUNT and GL_PROJECT/PORTNAME +. if defined(GO_MOD_DIST) && "${GO_MOD_DIST}" == "gitlab" +MASTER_SITES+= https://gitlab.com/${GL_ACCOUNT}/${GL_PROJECT}/-/raw/${GO_MODVERSION}/${WRKSRC_SUBDIR:?${WRKSRC_SUBDIR}/:} +DISTFILES+= go.mod +# If GO_MOD_DIST is github, download the go.mod from github by the defined GH_ACCOUNT and GH_PROJECT/PORTNAME +. elif defined(GO_MOD_DIST) && "${GO_MOD_DIST}" == "github" +MASTER_SITES+= https://raw.githubusercontent.com/${GH_ACCOUNT}/${GH_PROJECT}/${GO_MODVERSION}/${WRKSRC_SUBDIR:?${WRKSRC_SUBDIR}/:} +DISTFILES+= go.mod +# Manually defined GO_MOD_DIST +. elifdef(GO_MOD_DIST) +MASTER_SITES+= ${GO_MOD_DIST} +DISTFILES+= go.mod +# Fallback to default GO_PROXY +. else MASTER_SITES+= ${GO_GOPROXY}/${GO_MODNAME:C/([A-Z])/!\1/g:tl}/@v/ DISTFILES+= ${GO_MODFILE} ${GO_DISTFILE} WRKSRC= ${WRKDIR}/${GO_MODNAME}@${GO_MODVERSION} +. endif + . endif EXTRACT_ONLY?= ${DISTFILES:N*.mod\:*:N*.mod:C/:.*//} DIST_SUBDIR= go/${PKGORIGIN:S,/,_,g}/${DISTNAME}