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