Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: William Hubbs <williamh@g.o>
Subject: Re: [gentoo-dev] [PATCH 1/3] go-module.eclass: introduce new eclass to handle go modules
Date: Wed, 11 Sep 2019 17:38:32
Message-Id: 1839d49b6adcfeba3c807543e0ba01e0f2888a36.camel@gentoo.org
In Reply to: [gentoo-dev] [PATCH 1/3] go-module.eclass: introduce new eclass to handle go modules by William Hubbs
1 On Wed, 2019-09-11 at 12:21 -0500, William Hubbs wrote:
2 > Copyright: Sony Interactive Entertainment Inc.
3 > Signed-off-by: William Hubbs <williamh@g.o>
4 > ---
5 > eclass/go-module.eclass | 76 +++++++++++++++++++++++++++++++++++++++++
6 > 1 file changed, 76 insertions(+)
7 > create mode 100644 eclass/go-module.eclass
8 >
9 > diff --git a/eclass/go-module.eclass b/eclass/go-module.eclass
10 > new file mode 100644
11 > index 00000000000..7009fcd3beb
12 > --- /dev/null
13 > +++ b/eclass/go-module.eclass
14 > @@ -0,0 +1,76 @@
15 > +# Copyright 1999-2015 Gentoo Foundation
16
17 You need to replace your calendar. And copyright holder.
18
19 > +# Distributed under the terms of the GNU General Public License v2
20 > +
21 > +# @ECLASS: go-module.eclass
22
23 Any reason to change naming from golang-* to go-* now?
24
25 > +# @MAINTAINER:
26 > +# William Hubbs <williamh@g.o>
27 > +# @SUPPORTED_EAPIS: 7
28 > +# @BLURB: basic eclass for building software written in the go
29 > +# programming language that uses go modules.
30 > +# @DESCRIPTION:
31 > +# This eclass provides a convenience src_prepare() phase and some basic
32 > +# settings needed for all software written in the go programming
33 > +# language that uses go modules.
34 > +#
35 > +# You will know the software you are packaging uses modules because
36 > +# it will have files named go.sum and go.mod in its top-level source
37 > +# directory. If it does not have these files, use the golang-* eclasses.
38 > +#
39 > +# If the software you are packaging uses modules, the next question is
40 > +# whether it has a directory named "vendor" at the top-level of the source tree.
41 > +#
42 > +# If it doesn't, you need to create a tarball of what would be in the
43 > +# vendor directory and mirror it locally. This is done with the
44 > +# following commands if upstream is using a git repository:
45 > +#
46 > +# @CODE:
47 > +#
48 > +# $ cd /my/clone/of/upstream
49 > +# $ git checkout <release>
50 > +# $ go mod vendor
51 > +# $ tar cvf project-version-vendor.tar.gz vendor
52 > +#
53 > +# @CODE:
54 > +#
55 > +# Other than this, all you need to do is inherit this eclass then
56 > +# make sure the exported src_prepare function is run.
57 > +
58 > +case ${EAPI:-0} in
59 > + 7) ;;
60 > + *) die "${ECLASS} API in EAPI ${EAPI} not yet established."
61 > +esac
62 > +
63 > +if [[ -z ${_GO_MODULE} ]]; then
64 > +
65 > +_GO_MODULE=1
66 > +
67 > +BDEPEND=">=dev-lang/go-1.12"
68 > +
69 > +# Do not download dependencies from the internet
70 > +# make build output verbose by default
71 > +export GOFLAGS="-mod=vendor -v -x"
72 > +
73 > +# Do not complain about CFLAGS etc since go projects do not use them.
74 > +QA_FLAGS_IGNORED='.*'
75 > +
76 > +# Upstream does not support stripping go packages
77 > +RESTRICT="strip"
78 > +
79 > +EXPORT_FUNCTIONS src_prepare
80
81 Don't you need to inherit some other eclass to make it build?
82
83 > +
84 > +# @FUNCTION: go-module_src_prepare
85 > +# @DESCRIPTION:
86 > +# Run a default src_prepare then move our provided vendor directory to
87 > +# the appropriate spot if upstream doesn't provide a vendor directory.
88 > +go-module_src_prepare() {
89 > + default
90 > + # Use the upstream provided vendor directory if it exists.
91 > + [[ -d vendor ]] && return
92 > + # If we are not providing a mirror of a vendor directory we created
93 > + # manually, return since there may be nothing to vendor.
94 > + [[ ! -d ../vendor ]] && return
95 > + # At this point, we know we are providing a vendor mirror.
96 > + mv ../vendor . || die "Unable to move ../vendor directory"
97
98 Wouldn't it be much simpler to create appropriate directory structure
99 in the tarball? Then you wouldn't need a new eclass at all.
100
101 > +}
102 > +
103 > +fi
104
105 --
106 Best regards,
107 Michał Górny

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies