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