1 |
On Wed, 2019-09-11 at 13:22 -0500, William Hubbs wrote: |
2 |
> On Wed, Sep 11, 2019 at 07:38:17PM +0200, Michał Górny wrote: |
3 |
> > On Wed, 2019-09-11 at 12:21 -0500, William Hubbs wrote: |
4 |
> > > Copyright: Sony Interactive Entertainment Inc. |
5 |
> > > Signed-off-by: William Hubbs <williamh@g.o> |
6 |
> > > --- |
7 |
> > > eclass/go-module.eclass | 76 +++++++++++++++++++++++++++++++++++++++++ |
8 |
> > > 1 file changed, 76 insertions(+) |
9 |
> > > create mode 100644 eclass/go-module.eclass |
10 |
> > > |
11 |
> > > diff --git a/eclass/go-module.eclass b/eclass/go-module.eclass |
12 |
> > > new file mode 100644 |
13 |
> > > index 00000000000..7009fcd3beb |
14 |
> > > --- /dev/null |
15 |
> > > +++ b/eclass/go-module.eclass |
16 |
> > > @@ -0,0 +1,76 @@ |
17 |
> > > +# Copyright 1999-2015 Gentoo Foundation |
18 |
> > |
19 |
> > You need to replace your calendar. And copyright holder. |
20 |
> |
21 |
> Sure, I thought I ffixed that. |
22 |
> |
23 |
> > > +# Distributed under the terms of the GNU General Public License v2 |
24 |
> > > + |
25 |
> > > +# @ECLASS: go-module.eclass |
26 |
> > |
27 |
> > Any reason to change naming from golang-* to go-* now? |
28 |
> |
29 |
> Well, "lang" is sort of redundant, and there will be only one eclass, so |
30 |
> I thought I would make things a bit more simple. |
31 |
> |
32 |
> > > +# @MAINTAINER: |
33 |
> > > +# William Hubbs <williamh@g.o> |
34 |
> > > +# @SUPPORTED_EAPIS: 7 |
35 |
> > > +# @BLURB: basic eclass for building software written in the go |
36 |
> > > +# programming language that uses go modules. |
37 |
> > > +# @DESCRIPTION: |
38 |
> > > +# This eclass provides a convenience src_prepare() phase and some basic |
39 |
> > > +# settings needed for all software written in the go programming |
40 |
> > > +# language that uses go modules. |
41 |
> > > +# |
42 |
> > > +# You will know the software you are packaging uses modules because |
43 |
> > > +# it will have files named go.sum and go.mod in its top-level source |
44 |
> > > +# directory. If it does not have these files, use the golang-* eclasses. |
45 |
> > > +# |
46 |
> > > +# If the software you are packaging uses modules, the next question is |
47 |
> > > +# whether it has a directory named "vendor" at the top-level of the source tree. |
48 |
> > > +# |
49 |
> > > +# If it doesn't, you need to create a tarball of what would be in the |
50 |
> > > +# vendor directory and mirror it locally. This is done with the |
51 |
> > > +# following commands if upstream is using a git repository: |
52 |
> > > +# |
53 |
> > > +# @CODE: |
54 |
> > > +# |
55 |
> > > +# $ cd /my/clone/of/upstream |
56 |
> > > +# $ git checkout <release> |
57 |
> > > +# $ go mod vendor |
58 |
> > > +# $ tar cvf project-version-vendor.tar.gz vendor |
59 |
> > > +# |
60 |
> > > +# @CODE: |
61 |
> > > +# |
62 |
> > > +# Other than this, all you need to do is inherit this eclass then |
63 |
> > > +# make sure the exported src_prepare function is run. |
64 |
> > > + |
65 |
> > > +case ${EAPI:-0} in |
66 |
> > > + 7) ;; |
67 |
> > > + *) die "${ECLASS} API in EAPI ${EAPI} not yet established." |
68 |
> > > +esac |
69 |
> > > + |
70 |
> > > +if [[ -z ${_GO_MODULE} ]]; then |
71 |
> > > + |
72 |
> > > +_GO_MODULE=1 |
73 |
> > > + |
74 |
> > > +BDEPEND=">=dev-lang/go-1.12" |
75 |
> > > + |
76 |
> > > +# Do not download dependencies from the internet |
77 |
> > > +# make build output verbose by default |
78 |
> > > +export GOFLAGS="-mod=vendor -v -x" |
79 |
> > > + |
80 |
> > > +# Do not complain about CFLAGS etc since go projects do not use them. |
81 |
> > > +QA_FLAGS_IGNORED='.*' |
82 |
> > > + |
83 |
> > > +# Upstream does not support stripping go packages |
84 |
> > > +RESTRICT="strip" |
85 |
> > > + |
86 |
> > > +EXPORT_FUNCTIONS src_prepare |
87 |
> > |
88 |
> > Don't you need to inherit some other eclass to make it build? |
89 |
> |
90 |
> The primary reason for all of the golang-* eclasses was the GOPATH |
91 |
> variable, which is not relevant when you are using modules. |
92 |
> |
93 |
> I can look at adding a src_compile to this eclass, but I haven't thought |
94 |
> about what it would contain yet. |
95 |
> |
96 |
> > > + |
97 |
> > > +# @FUNCTION: go-module_src_prepare |
98 |
> > > +# @DESCRIPTION: |
99 |
> > > +# Run a default src_prepare then move our provided vendor directory to |
100 |
> > > +# the appropriate spot if upstream doesn't provide a vendor directory. |
101 |
> > > +go-module_src_prepare() { |
102 |
> > > + default |
103 |
> > > + # Use the upstream provided vendor directory if it exists. |
104 |
> > > + [[ -d vendor ]] && return |
105 |
> > > + # If we are not providing a mirror of a vendor directory we created |
106 |
> > > + # manually, return since there may be nothing to vendor. |
107 |
> > > + [[ ! -d ../vendor ]] && return |
108 |
> > > + # At this point, we know we are providing a vendor mirror. |
109 |
> > > + mv ../vendor . || die "Unable to move ../vendor directory" |
110 |
> > |
111 |
> > Wouldn't it be much simpler to create appropriate directory structure |
112 |
> > in the tarball? Then you wouldn't need a new eclass at all. |
113 |
> |
114 |
> You would definitely need an eclass (see the settings and dependencies). |
115 |
> |
116 |
> Take a look at the differences in the spire and hub ebuilds in this |
117 |
> series. I'm not sure what you mean by adding the directory structure to |
118 |
> the tarball? I guess you could add something to the vendor tarball when |
119 |
> you create it. |
120 |
|
121 |
I mean packing it as 'spire-1.2.3/vendor' or whatever the package |
122 |
directory is, so that it extracts correctly instead of making a tarball |
123 |
that needs to be moved afterwards. |
124 |
|
125 |
> |
126 |
> What I tried to avoid was stomping on the vendor directory if it is |
127 |
> included upstream. |
128 |
|
129 |
You do that anyway by moving files. |
130 |
|
131 |
> |
132 |
> William |
133 |
> > > +} |
134 |
> > > + |
135 |
> > > +fi |
136 |
> > |
137 |
> > -- |
138 |
> > Best regards, |
139 |
> > Michał Górny |
140 |
> > |
141 |
> |
142 |
> |
143 |
|
144 |
-- |
145 |
Best regards, |
146 |
Michał Górny |