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