blob: b95ee29178f0d7ec3c8b3499f52b8f2f5b2b05e3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: golang-vcs.eclass
# @MAINTAINER:
# William Hubbs <williamh@gentoo.org>
# @BLURB: Eclass for fetching and unpacking go repositories.
# @DESCRIPTION:
# This eclass is written to ease the maintenance of live ebuilds
# of software written in the Go programming language.
inherit eutils golang-base
case "${EAPI:-0}" in
5|6)
;;
*)
die "${ECLASS}: Unsupported eapi (EAPI=${EAPI})"
;;
esac
EXPORT_FUNCTIONS src_unpack
if [[ -z ${_GOLANG_VCS} ]]; then
_GOLANG_VCS=1
# @ECLASS-VARIABLE: EGO_PN
# @REQUIRED
# @DESCRIPTION:
# This is the import path for the go package(s). Please emerge dev-lang/go
# and read "go help importpath" for syntax.
#
# Example:
# @CODE
# EGO_PN="github.com/user/package"
# EGO_PN="github.com/user1/package1 github.com/user2/package2"
# @CODE
# @ECLASS-VARIABLE: EGO_STORE_DIR
# @DESCRIPTION:
# Storage directory for Go sources.
#
# This is intended to be set by the user in make.conf. Ebuilds must not set
# it.
#
# EGO_STORE_DIR=${DISTDIR}/go-src
# @ECLASS-VARIABLE: EVCS_OFFLINE
# @DEFAULT_UNSET
# @DESCRIPTION:
# If non-empty, this variable prevents any online operations.
# @ECLASS-VARIABLE: EVCS_UMASK
# @DEFAULT_UNSET
# @DESCRIPTION:
# Set this variable to a custom umask. This is intended to be set by
# users. By setting this to something like 002, it can make life easier
# for people who do development as non-root (but are in the portage
# group) and use FEATURES=userpriv.
# @FUNCTION: _golang-vcs_env_setup
# @INTERNAL
# @DESCRIPTION:
# Create EGO_STORE_DIR if necessary.
_golang-vcs_env_setup() {
debug-print-function ${FUNCNAME} "$@"
local distdir=${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}
: ${EGO_STORE_DIR:=${distdir}/go-src}
[[ -n ${EVCS_UMASK} ]] && eumask_push $EVCS_UMASK
if [[ ! -d ${EGO_STORE_DIR} ]]; then
(
addwrite /
mkdir -p "${EGO_STORE_DIR}"
) || die "${ECLASS}: unable to create ${EGO_STORE_DIR}"
fi
addwrite "${EGO_STORE_DIR}"
[[ -n ${EVCS_UMASK} ]] && eumask_pop
mkdir -p "${WORKDIR}/${P}/src" ||
die "${ECLASS}: unable to create ${WORKDIR}/${P}"
return 0
}
# @FUNCTION: _golang-vcs_fetch
# @INTERNAL
# @DESCRIPTION:
# Retrieve the EGO_PN go package along with its dependencies.
_golang-vcs_fetch() {
debug-print-function ${FUNCNAME} "$@"
ego_pn_check
if [[ -z ${EVCS_OFFLINE} ]]; then
[[ -n ${EVCS_UMASK} ]] && eumask_push ${EVCS_UMASK}
set -- env GOPATH="${EGO_STORE_DIR}" go get -d -t -u -v -x "${EGO_PN}"
echo "$@"
"$@" || die
# The above dies if you pass repositories in EGO_PN instead of
# packages, e.g. golang.org/x/tools instead of golang.org/x/tools/cmd/vet.
# This is being discussed in the following upstream issue:
# https://github.com/golang/go/issues/11090
[[ -n ${EVCS_UMASK} ]] && eumask_pop
fi
local go_srcpath="${WORKDIR}/${P}/src/${EGO_PN%/...}"
set -- mkdir -p "${go_srcpath}"
echo "$@"
"$@" || die "Unable to create ${go_srcpath}"
set -- cp -r "${EGO_STORE_DIR}/src/${EGO_PN%/...}" \
"${go_srcpath}/.."
echo "$@"
"$@" || die "Unable to copy sources to ${go_srcpath}"
return 0
}
golang-vcs_src_fetch() {
debug-print-function ${FUNCNAME} "$@"
_golang-vcs_env_setup
_golang-vcs_fetch
}
golang-vcs_src_unpack() {
debug-print-function ${FUNCNAME} "$@"
golang-vcs_src_fetch
}
fi
|