Gentoo Archives: gentoo-dev

From: William Hubbs <williamh@g.o>
To: gentoo-dev@l.g.o, robbat2@g.o
Cc: robbat2@g.o
Subject: Re: [gentoo-dev] [PATCH v2 1/4] eclass/go-module: add support for building based on go.sum
Date: Wed, 19 Feb 2020 17:37:47
Message-Id: 20200219173739.GA32563@whubbs1.dev.av1.gaikai.org
In Reply to: Re: [gentoo-dev] [PATCH v2 1/4] eclass/go-module: add support for building based on go.sum by William Hubbs
1 On Wed, Feb 19, 2020 at 09:20:13AM -0600, William Hubbs wrote:
2 > On Wed, Feb 19, 2020 at 07:36:27AM +0000, Robin H. Johnson wrote:
3 > > On Tue, Feb 18, 2020 at 11:46:45PM -0600, William Hubbs wrote:
4 > > > > -# If it does not have a vendor directory, you should use the EGO_VENDOR
5 > > > > +# Alternatively, older versions of this eclass used the EGO_VENDOR
6 > > > > # variable and the go-module_vendor_uris function as shown in the
7 > > > > # example below to handle dependencies.
8 > > > I think we can remove the example with EGO_VENDOR and
9 > > > go-module_vendor_uris; we really don't want people to continue following
10 > > > that example.
11 > > I tried to handle more cases here, but now I'm wondering if it would be
12 > > cleaner just to put all of new way into a distinct eclass, and sunset
13 > > the old eclass entirely. I found unforeseen interactions, see below.
14 > >
15 > > > > +# S="${WORKDIR}/${MY_P}"
16 > > > The default setting of S should be fine for most ebuilds, so I don't
17 > > > think we need this in the example.
18 > > I'd copied it, but yes in this case.
19 > >
20 > > >
21 > > > > +# go-module_set_globals
22 > > > > +#
23 > > > > +# SRC_URI="https://github.com/example/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz
24 > > > > +# ${EGO_SUM_SRC_URI}"
25 > > > > +#
26 > > > > +# LICENSE="some-license ${EGO_SUM_LICENSES}"
27 > > > > +#
28 > > > > +# src_unpack() {
29 > > > > +# unpack ${P}.tar.gz
30 > > > > +# go-module_src_unpack
31 > > > > +# }
32 > > > I don't think I would put an src_unpack() in the example.
33 > > This is one of the unforeseen interactions.
34 > > The go.sum unpack only applies special handling to distfiles that it
35 > > knows about. It does NOT process any other distfiles at all.
36 > >
37 > > EAPI8 or future Portage improvements might have annotations to disable
38 > > any automatic unpacking for specific distfiles, which would resolve this
39 > > issue.
40 > >
41 > > Hence, you need to explicitly unpack any distfiles that are NOT part of
42 > > the go.sum dependencies. There are some ebuilds that do unpack & rename
43 > > in src_unpack already, so they need extra care as well.
44 > >
45 > > The EGO_VENDOR src_unpack unpacked EVERYTHING, so it didn't have this
46 > > issue.
47
48 It used filtering to decide what to unpack where, so I think we can use
49 the same idea. Look at this patch to what is in the tree currently.
50
51 Look at this patch. Part of it is just comments, but I think this could
52 work if module_files is populated correctly.
53
54 diff --git a/eclass/go-module.eclass b/eclass/go-module.eclass
55 index 80ff2902b3a..3e0091a0d25 100644
56 --- a/eclass/go-module.eclass
57 +++ b/eclass/go-module.eclass
58 @@ -113,7 +113,8 @@ go-module_vendor_uris() {
59 # ${EGO_VENDOR} to ${S}/vendor.
60 go-module_src_unpack() {
61 debug-print-function ${FUNCNAME} "$@"
62 - local f hash import line repo tarball vendor_tarballs x
63 + local f hash import line repo tarball module_files vendor_tarballs x
64 + module_files=()
65 vendor_tarballs=()
66 for line in "${EGO_VENDOR[@]}"; do
67 read -r import hash repo x <<< "${line}"
68 @@ -125,9 +126,15 @@ go-module_src_unpack() {
69 : "${repo:=${import}}"
70 vendor_tarballs+=("${repo//\//-}-${hash}.tar.gz")
71 done
72 + # populate module_files with the files we do not want to unpack
73 + # based on EGO_SUM
74 +
75 + # unpack the appropriate files from $A
76 for f in $A; do
77 [[ -n ${vendor_tarballs[*]} ]] && has "$f" "${vendor_tarballs[@]}" &&
78 continue
79 + [[ -n ${module_files[*]} ]] && has "$f" "${module_files[@]}" &&
80 + continue
81 unpack "$f"
82 done

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies