1 |
On Thu, Sep 12, 2019 at 05:39:42AM +0000, Michał Górny wrote: |
2 |
> Dnia September 11, 2019 11:11:15 PM UTC, William Hubbs <williamh@g.o> napisał(a): |
3 |
> >On Wed, Sep 11, 2019 at 07:47:04PM +0000, Michał Górny wrote: |
4 |
> >> Dnia September 11, 2019 7:40:41 PM UTC, William Hubbs |
5 |
> ><williamh@g.o> napisał(a): |
6 |
> >> >On Wed, Sep 11, 2019 at 08:31:16PM +0200, Michał Górny wrote: |
7 |
> >> >> On Wed, 2019-09-11 at 13:22 -0500, William Hubbs wrote: |
8 |
> >> >> > On Wed, Sep 11, 2019 at 07:38:17PM +0200, Michał Górny wrote: |
9 |
> >> >> > > On Wed, 2019-09-11 at 12:21 -0500, William Hubbs wrote: |
10 |
> >> >> > > > Copyright: Sony Interactive Entertainment Inc. |
11 |
> >> >> > > > Signed-off-by: William Hubbs <williamh@g.o> |
12 |
> >> >> > > > --- |
13 |
> >> >> > > > eclass/go-module.eclass | 76 |
14 |
> >> >+++++++++++++++++++++++++++++++++++++++++ |
15 |
> >> >> > > > 1 file changed, 76 insertions(+) |
16 |
> >> >> > > > create mode 100644 eclass/go-module.eclass |
17 |
> >> >> > > > |
18 |
> >> >> > > > diff --git a/eclass/go-module.eclass |
19 |
> >b/eclass/go-module.eclass |
20 |
> >> >> > > > new file mode 100644 |
21 |
> >> >> > > > index 00000000000..7009fcd3beb |
22 |
> >> >> > > > --- /dev/null |
23 |
> >> >> > > > +++ b/eclass/go-module.eclass |
24 |
> >> >> > > > @@ -0,0 +1,76 @@ |
25 |
> >> >> > > > +# Copyright 1999-2015 Gentoo Foundation |
26 |
> >> >> > > |
27 |
> >> >> > > You need to replace your calendar. And copyright holder. |
28 |
> >> >> > |
29 |
> >> >> > Sure, I thought I ffixed that. |
30 |
> >> >> > |
31 |
> >> >> > > > +# Distributed under the terms of the GNU General Public |
32 |
> >> >License v2 |
33 |
> >> >> > > > + |
34 |
> >> >> > > > +# @ECLASS: go-module.eclass |
35 |
> >> >> > > |
36 |
> >> >> > > Any reason to change naming from golang-* to go-* now? |
37 |
> >> >> > |
38 |
> >> >> > Well, "lang" is sort of redundant, and there will be only one |
39 |
> >> >eclass, so |
40 |
> >> >> > I thought I would make things a bit more simple. |
41 |
> >> >> > |
42 |
> >> >> > > > +# @MAINTAINER: |
43 |
> >> >> > > > +# William Hubbs <williamh@g.o> |
44 |
> >> >> > > > +# @SUPPORTED_EAPIS: 7 |
45 |
> >> >> > > > +# @BLURB: basic eclass for building software written in the |
46 |
> >go |
47 |
> >> >> > > > +# programming language that uses go modules. |
48 |
> >> >> > > > +# @DESCRIPTION: |
49 |
> >> >> > > > +# This eclass provides a convenience src_prepare() phase |
50 |
> >and |
51 |
> >> >some basic |
52 |
> >> >> > > > +# settings needed for all software written in the go |
53 |
> >> >programming |
54 |
> >> >> > > > +# language that uses go modules. |
55 |
> >> >> > > > +# |
56 |
> >> >> > > > +# You will know the software you are packaging uses modules |
57 |
> >> >because |
58 |
> >> >> > > > +# it will have files named go.sum and go.mod in its |
59 |
> >top-level |
60 |
> >> >source |
61 |
> >> >> > > > +# directory. If it does not have these files, use the |
62 |
> >golang-* |
63 |
> >> >eclasses. |
64 |
> >> >> > > > +# |
65 |
> >> >> > > > +# If the software you are packaging uses modules, the next |
66 |
> >> >question is |
67 |
> >> >> > > > +# whether it has a directory named "vendor" at the |
68 |
> >top-level |
69 |
> >> >of the source tree. |
70 |
> >> >> > > > +# |
71 |
> >> >> > > > +# If it doesn't, you need to create a tarball of what would |
72 |
> >be |
73 |
> >> >in the |
74 |
> >> >> > > > +# vendor directory and mirror it locally. This is done with |
75 |
> >> >the |
76 |
> >> >> > > > +# following commands if upstream is using a git repository: |
77 |
> >> >> > > > +# |
78 |
> >> >> > > > +# @CODE: |
79 |
> >> >> > > > +# |
80 |
> >> >> > > > +# $ cd /my/clone/of/upstream |
81 |
> >> >> > > > +# $ git checkout <release> |
82 |
> >> >> > > > +# $ go mod vendor |
83 |
> >> >> > > > +# $ tar cvf project-version-vendor.tar.gz vendor |
84 |
> >> >> > > > +# |
85 |
> >> >> > > > +# @CODE: |
86 |
> >> >> > > > +# |
87 |
> >> >> > > > +# Other than this, all you need to do is inherit this |
88 |
> >eclass |
89 |
> >> >then |
90 |
> >> >> > > > +# make sure the exported src_prepare function is run. |
91 |
> >> >> > > > + |
92 |
> >> >> > > > +case ${EAPI:-0} in |
93 |
> >> >> > > > + 7) ;; |
94 |
> >> >> > > > + *) die "${ECLASS} API in EAPI ${EAPI} not yet |
95 |
> >established." |
96 |
> >> >> > > > +esac |
97 |
> >> >> > > > + |
98 |
> >> >> > > > +if [[ -z ${_GO_MODULE} ]]; then |
99 |
> >> >> > > > + |
100 |
> >> >> > > > +_GO_MODULE=1 |
101 |
> >> >> > > > + |
102 |
> >> >> > > > +BDEPEND=">=dev-lang/go-1.12" |
103 |
> >> >> > > > + |
104 |
> >> >> > > > +# Do not download dependencies from the internet |
105 |
> >> >> > > > +# make build output verbose by default |
106 |
> >> >> > > > +export GOFLAGS="-mod=vendor -v -x" |
107 |
> >> >> > > > + |
108 |
> >> >> > > > +# Do not complain about CFLAGS etc since go projects do not |
109 |
> >> >use them. |
110 |
> >> >> > > > +QA_FLAGS_IGNORED='.*' |
111 |
> >> >> > > > + |
112 |
> >> >> > > > +# Upstream does not support stripping go packages |
113 |
> >> >> > > > +RESTRICT="strip" |
114 |
> >> >> > > > + |
115 |
> >> >> > > > +EXPORT_FUNCTIONS src_prepare |
116 |
> >> >> > > |
117 |
> >> >> > > Don't you need to inherit some other eclass to make it build? |
118 |
> >> >> > |
119 |
> >> >> > The primary reason for all of the golang-* eclasses was the |
120 |
> >GOPATH |
121 |
> >> >> > variable, which is not relevant when you are using modules. |
122 |
> >> >> > |
123 |
> >> >> > I can look at adding a src_compile to this eclass, but I haven't |
124 |
> >> >thought |
125 |
> >> >> > about what it would contain yet. |
126 |
> >> >> > |
127 |
> >> >> > > > + |
128 |
> >> >> > > > +# @FUNCTION: go-module_src_prepare |
129 |
> >> >> > > > +# @DESCRIPTION: |
130 |
> >> >> > > > +# Run a default src_prepare then move our provided vendor |
131 |
> >> >directory to |
132 |
> >> >> > > > +# the appropriate spot if upstream doesn't provide a vendor |
133 |
> >> >directory. |
134 |
> >> >> > > > +go-module_src_prepare() { |
135 |
> >> >> > > > + default |
136 |
> >> >> > > > + # Use the upstream provided vendor directory if it exists. |
137 |
> >> >> > > > + [[ -d vendor ]] && return |
138 |
> >> >> > > > + # If we are not providing a mirror of a vendor directory |
139 |
> >we |
140 |
> >> >created |
141 |
> >> >> > > > + # manually, return since there may be nothing to vendor. |
142 |
> >> >> > > > + [[ ! -d ../vendor ]] && return |
143 |
> >> >> > > > + # At this point, we know we are providing a vendor mirror. |
144 |
> >> >> > > > + mv ../vendor . || die "Unable to move ../vendor directory" |
145 |
> >> >> > > |
146 |
> >> >> > > Wouldn't it be much simpler to create appropriate directory |
147 |
> >> >structure |
148 |
> >> >> > > in the tarball? Then you wouldn't need a new eclass at all. |
149 |
> >> >> > |
150 |
> >> >> > You would definitely need an eclass (see the settings and |
151 |
> >> >dependencies). |
152 |
> >> >> > |
153 |
> >> >> > Take a look at the differences in the spire and hub ebuilds in |
154 |
> >this |
155 |
> >> >> > series. I'm not sure what you mean by adding the directory |
156 |
> >> >structure to |
157 |
> >> >> > the tarball? I guess you could add something to the vendor |
158 |
> >tarball |
159 |
> >> >when |
160 |
> >> >> > you create it. |
161 |
> >> >> |
162 |
> >> >> I mean packing it as 'spire-1.2.3/vendor' or whatever the package |
163 |
> >> >> directory is, so that it extracts correctly instead of making a |
164 |
> >> >tarball |
165 |
> >> >> that needs to be moved afterwards. |
166 |
> >> > |
167 |
> >> >That would clobber the upstream provided vendor directory and that's |
168 |
> >> >what I want to avoid with the first test in src_prepare. |
169 |
> >> |
170 |
> >> If upstream already includes vendored modules, why would you create |
171 |
> >your own tarball in the first place? |
172 |
> > |
173 |
> >You are right, and currently I quietly ignore your vendor tarball if |
174 |
> >upstream |
175 |
> >vendors the dependencies also. I could change this to generate a |
176 |
> >warning |
177 |
> >or die and force you to fix the ebuild, but that would not be possible |
178 |
> >if I follow your suggestion because I would not be able to tell whether |
179 |
> >the vendored dependencies came from us or upstream. |
180 |
> |
181 |
> Why would anyone create a vendor tarball if things work without it? That makes no sense. Also adding unused archives to SRC_URI is a QA violation. |
182 |
|
183 |
All the more reason to not have the vendor tarball overwrite the vendor |
184 |
directory upstream. I will show you when I update the eclass. |
185 |
|
186 |
> |
187 |
> > |
188 |
> >Also, another concern about your suggestion is the --transform switch |
189 |
> >that would have to be added to the tar command people use to create |
190 |
> >the |
191 |
> >vendor tarball, something like: |
192 |
> > |
193 |
> >tar -acvf package-version-vendor.tar.gz |
194 |
> >--transform='s#^vendor#package-version-vendor#' vendor |
195 |
> > |
196 |
> >You suggested that a maintainer could create a new tarball and build on |
197 |
> >top of it. I guess you mean don't use upstream's tarball if they don't |
198 |
> >vendor and create my own tarball and add the vendor directory to it. |
199 |
> >I'm |
200 |
> >against that option because I don't feel that we should manually |
201 |
> >tinker |
202 |
> >with upstream tarballs. That opens a pretty big can of worms imo. |
203 |
> |
204 |
> No. I suggested that rather than adding another git clone and checking out a tag (which sooner or later would mean someone forgetting and using master instead), you could unpack the same archive you're going to use in the ebuild. |
205 |
|
206 |
Ok, I am really not following you, so let's talk about this in the |
207 |
context of an example. |
208 |
|
209 |
Look at app-misc/spire and tell me how you would do it differently. |
210 |
|
211 |
William |