Gentoo Archives: gentoo-commits

From: William Hubbs <williamh@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Wed, 26 May 2021 00:42:11
Message-Id: 1621989692.78d13659aa35772114a9f0d12430bd67273998ad.williamh@gentoo
1 commit: 78d13659aa35772114a9f0d12430bd67273998ad
2 Author: William Hubbs <williamh <AT> gentoo <DOT> org>
3 AuthorDate: Wed May 26 00:41:32 2021 +0000
4 Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
5 CommitDate: Wed May 26 00:41:32 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=78d13659
7
8 go-module.eclass: add go-module_setup_proxy function
9
10 This function is to be used in an ebuild that uses EGO_SUM and defines
11 src_unpack.
12
13 Signed-off-by: William Hubbs <williamh <AT> gentoo.org>
14
15 eclass/go-module.eclass | 41 +++++++++++++++++++++++++++++++++++++++++
16 1 file changed, 41 insertions(+)
17
18 diff --git a/eclass/go-module.eclass b/eclass/go-module.eclass
19 index 9d64ad48b43..c11895944cd 100644
20 --- a/eclass/go-module.eclass
21 +++ b/eclass/go-module.eclass
22 @@ -239,6 +239,47 @@ go-module_set_globals() {
23 _GO_MODULE_SET_GLOBALS_CALLED=1
24 }
25
26 +# @FUNCTION: go-module_setup_proxy
27 +# @DESCRIPTION:
28 +# If your ebuild redefines src_unpack and uses EGO_SUM you need to call
29 +# this function in src_unpack.
30 +# It sets up the go module proxy in the appropriate location.
31 +go-module_setup_proxy() {
32 + # shellcheck disable=SC2120
33 + debug-print-function "${FUNCNAME}" "$@"
34 +
35 + if [[ ! ${_GO_MODULE_SET_GLOBALS_CALLED} ]]; then
36 + die "go-module_set_globals must be called in global scope"
37 + fi
38 +
39 + local goproxy_dir="${GOPROXY/file:\/\//}"
40 + mkdir -p "${goproxy_dir}" || die
41 +
42 + # For each Golang module distfile, look up where it's supposed to go and
43 + # symlink it into place.
44 + local f
45 + local goproxy_mod_dir
46 + for f in ${A}; do
47 + goproxy_mod_path="${_GOMODULE_GOSUM_REVERSE_MAP["${f}"]}"
48 + if [[ -n "${goproxy_mod_path}" ]]; then
49 + debug-print-function "Populating go proxy for ${goproxy_mod_path}"
50 + # Build symlink hierarchy
51 + goproxy_mod_dir=$( dirname "${goproxy_dir}"/"${goproxy_mod_path}" )
52 + mkdir -p "${goproxy_mod_dir}" || die
53 + ln -sf "${DISTDIR}"/"${f}" "${goproxy_dir}/${goproxy_mod_path}" ||
54 + die "Failed to ln"
55 + local v=${goproxy_mod_path}
56 + v="${v%.mod}"
57 + v="${v%.zip}"
58 + v="${v//*\/}"
59 + _go-module_gosum_synthesize_files "${goproxy_mod_dir}" "${v}"
60 + fi
61 + done
62 +
63 + # Validate the gosum now
64 + _go-module_src_unpack_verify_gosum
65 +}
66 +
67 # @FUNCTION: go-module_src_unpack
68 # @DESCRIPTION:
69 # If EGO_SUM is set, unpack the base tarball(s) and set up the