diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2021-05-31 20:59:14 +0100 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2021-05-31 20:59:14 +0100 |
commit | e748ba9741f6540f4675c23e3e37b73e822c13a4 (patch) | |
tree | 23dece8beabb3a3d7c6c0273b0eb40b21c62a889 /eclass/go-module.eclass | |
parent | 908778078736bd36f7a60a2d576d415cb8e000fa (diff) |
gentoo resync : 31.05.2021
Diffstat (limited to 'eclass/go-module.eclass')
-rw-r--r-- | eclass/go-module.eclass | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/eclass/go-module.eclass b/eclass/go-module.eclass index c9a7ab12eaf0..c11895944cdc 100644 --- a/eclass/go-module.eclass +++ b/eclass/go-module.eclass @@ -232,10 +232,54 @@ go-module_set_globals() { readonly EGO_SUM_SRC_URI readonly _GOMODULE_GOSUM_REVERSE_MAP + # export the GOPROXY setting + export GOPROXY="file://${T}/go-proxy" + # Set the guard that we are safe _GO_MODULE_SET_GLOBALS_CALLED=1 } +# @FUNCTION: go-module_setup_proxy +# @DESCRIPTION: +# If your ebuild redefines src_unpack and uses EGO_SUM you need to call +# this function in src_unpack. +# It sets up the go module proxy in the appropriate location. +go-module_setup_proxy() { + # shellcheck disable=SC2120 + debug-print-function "${FUNCNAME}" "$@" + + if [[ ! ${_GO_MODULE_SET_GLOBALS_CALLED} ]]; then + die "go-module_set_globals must be called in global scope" + fi + + local goproxy_dir="${GOPROXY/file:\/\//}" + mkdir -p "${goproxy_dir}" || die + + # For each Golang module distfile, look up where it's supposed to go and + # symlink it into place. + local f + local goproxy_mod_dir + for f in ${A}; do + goproxy_mod_path="${_GOMODULE_GOSUM_REVERSE_MAP["${f}"]}" + if [[ -n "${goproxy_mod_path}" ]]; then + debug-print-function "Populating go proxy for ${goproxy_mod_path}" + # Build symlink hierarchy + goproxy_mod_dir=$( dirname "${goproxy_dir}"/"${goproxy_mod_path}" ) + mkdir -p "${goproxy_mod_dir}" || die + ln -sf "${DISTDIR}"/"${f}" "${goproxy_dir}/${goproxy_mod_path}" || + die "Failed to ln" + local v=${goproxy_mod_path} + v="${v%.mod}" + v="${v%.zip}" + v="${v//*\/}" + _go-module_gosum_synthesize_files "${goproxy_mod_dir}" "${v}" + fi + done + + # Validate the gosum now + _go-module_src_unpack_verify_gosum +} + # @FUNCTION: go-module_src_unpack # @DESCRIPTION: # If EGO_SUM is set, unpack the base tarball(s) and set up the @@ -268,7 +312,7 @@ _go-module_src_unpack_gosum() { die "go-module_set_globals must be called in global scope" fi - local goproxy_dir="${T}/go-proxy" + local goproxy_dir="${GOPROXY/file:\/\//}" mkdir -p "${goproxy_dir}" || die # For each Golang module distfile, look up where it's supposed to go, and @@ -293,7 +337,6 @@ _go-module_src_unpack_gosum() { unpack "$f" fi done - export GOPROXY="file://${goproxy_dir}" # Validate the gosum now _go-module_src_unpack_verify_gosum |