Date: Sun, 21 Jul 2024 06:56:41 GMT From: Matthias Fechner <mfechner@FreeBSD.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-branches@FreeBSD.org Subject: git: 03194a20aa97 - 2024Q3 - Mk/Uses: go.mk can not load a go.mod from other locations Message-ID: <202407210656.46L6ufFD068863@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch 2024Q3 has been updated by mfechner: URL: https://cgit.FreeBSD.org/ports/commit/?id=03194a20aa97ed622bccf2f28fd069b212a720a5 commit 03194a20aa97ed622bccf2f28fd069b212a720a5 Author: Matthias Fechner <mfechner@FreeBSD.org> AuthorDate: 2024-06-19 09:15:30 +0000 Commit: Matthias Fechner <mfechner@FreeBSD.org> CommitDate: 2024-07-21 05:38:36 +0000 Mk/Uses: go.mk can not load a go.mod from other locations Not all projects are providing there go.mod file to the go proxy. If the go.mod is not available on the go proxies it is not possible to build the port with the go module approach. This modification make a new variable GO_MOD_DIST availble. With the values: - gitlab (to download the go.mod from gitlab) - github (to download the go.mod from github) - https://.... (a custom URI without the go.mod in it) - not defined (will download as now from go proxy) This make it now possible to also easily package go based ports that are only hosted on some sites but not published to the go proxy. Differential Revision: https://reviews.freebsd.org/D45631 (cherry picked from commit 52b385abc68053471e9713a6ef9c81a8ce74910d) --- Mk/Uses/go.mk | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Mk/Uses/go.mk b/Mk/Uses/go.mk index e78dbe33b7a5..1929dbc1dc9f 100644 --- 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_MODNAME= ${GO_MODULE:C/^([^@]*)(@([^@]*)?)/\1/} 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}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202407210656.46L6ufFD068863>