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