1 |
This eclass includes the basic settings and a pkg_postinst function for |
2 |
go modules. |
3 |
|
4 |
Signed-off-by: William Hubbs <williamh@g.o> |
5 |
--- |
6 |
eclass/go-module.eclass | 79 +++++++++++++++++++++++++++++++++++++++++ |
7 |
1 file changed, 79 insertions(+) |
8 |
create mode 100644 eclass/go-module.eclass |
9 |
|
10 |
diff --git a/eclass/go-module.eclass b/eclass/go-module.eclass |
11 |
new file mode 100644 |
12 |
index 00000000000..0c2e072bd78 |
13 |
--- /dev/null |
14 |
+++ b/eclass/go-module.eclass |
15 |
@@ -0,0 +1,79 @@ |
16 |
+# Copyright 2019 gentoo authors |
17 |
+# Distributed under the terms of the GNU General Public License v2 |
18 |
+ |
19 |
+# @ECLASS: go-module.eclass |
20 |
+# @MAINTAINER: |
21 |
+# William Hubbs <williamh@g.o> |
22 |
+# @SUPPORTED_EAPIS: 7 |
23 |
+# @BLURB: basic eclass for building software written in the go |
24 |
+# programming language that uses go modules. |
25 |
+# @DESCRIPTION: |
26 |
+# This eclass provides some basic settings and a pkg_postinst function |
27 |
+# needed by all software written in the go programming language that uses |
28 |
+# go modules. |
29 |
+# |
30 |
+# You will know the software you are packaging uses modules because |
31 |
+# it will have files named go.sum and go.mod in its top-level source |
32 |
+# directory. If it does not have these files, use the golang-* eclasses. |
33 |
+# |
34 |
+# If it has these two files and a directory named vendor at the top |
35 |
+# level, your ebuild should inherit this eclass since upstream is vendoring |
36 |
+# their dependencies. If it does not have a vendor directory, your ebuild |
37 |
+# should inherit the go-module-vendor eclass. |
38 |
+# |
39 |
+# Since Go programs are statically linked, it is important that your ebuild's |
40 |
+# LICENSE= setting includes the licenses of all statically linked |
41 |
+# dependencies. So please make sure it is accurate. |
42 |
+# |
43 |
+# @EXAMPLE: |
44 |
+# |
45 |
+# @CODE |
46 |
+# |
47 |
+# inherit go-module |
48 |
+# |
49 |
+# @CODE |
50 |
+ |
51 |
+case ${EAPI:-0} in |
52 |
+ 7) ;; |
53 |
+ *) die "${ECLASS} API in EAPI ${EAPI} not yet established." |
54 |
+esac |
55 |
+ |
56 |
+if [[ -z ${_GO_MODULE} ]]; then |
57 |
+ |
58 |
+_GO_MODULE_=1 |
59 |
+ |
60 |
+BDEPEND=">=dev-lang/go-1.12" |
61 |
+ |
62 |
+# Force go to build in module mode. |
63 |
+# In this mode the GOPATH environment variable is ignored. |
64 |
+# this will become the default in the future. |
65 |
+export GO111MODULE=on |
66 |
+ |
67 |
+# The following go flags should be used for all builds. |
68 |
+# -mod=vendor stopps downloading of dependencies from the internet. |
69 |
+# -v prints the names of packages as they are compiled |
70 |
+# -x prints commands as they are executed |
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 |
+# Go packages should not be stripped with strip(1). |
77 |
+RESTRICT="strip" |
78 |
+ |
79 |
+EXPORT_FUNCTIONS pkg_postinst |
80 |
+ |
81 |
+# @FUNCTION: go-module_pkg_postinst |
82 |
+# @DESCRIPTION: |
83 |
+# Display a warning about security updates for Go programs. |
84 |
+go-module_pkg_postinst() { |
85 |
+ ewarn "${PN} is written in the Go programming language." |
86 |
+ ewarn "Since this language is statically linked, security" |
87 |
+ ewarn "updates will be handled in individual packages and will be" |
88 |
+ ewarn "difficult for us to track as a distribution." |
89 |
+ ewarn "For this reason, please update any go packages asap when new" |
90 |
+ ewarn "versions enter the tree or go stable if you are running the" |
91 |
+ ewarn "stable tree." |
92 |
+} |
93 |
+ |
94 |
+fi |
95 |
-- |
96 |
2.21.0 |