1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: golang-vcs-snapshot.eclass
7 # William Hubbs <williamh@gentoo.org>
8 # @BLURB: support eclass for unpacking VCS snapshot tarballs for
9 # software written in the Go programming language
11 # This eclass provides a convenience src_unpack() which unpacks the
12 # first tarball mentioned in SRC_URI to its appropriate location in
13 # ${WORKDIR}/${P}, treating ${WORKDIR}/${P} as a go workspace.
15 # The location where the tarball is extracted is defined as
16 # ${WORKDIR}/${P}/src/${EGO_PN}.
18 # The typical use case is VCS snapshots coming from github, bitbucket
19 # and similar services.
21 # Please note that this eclass currently handles only tarballs
22 # (.tar.gz), but support for more formats may be added in the future.
27 # EGO_PN=github.com/user/package
28 # inherit golang-vcs-snapshot
30 # SRC_URI="http://github.com/example/${PN}/tarball/v${PV} -> ${P}.tar.gz"
33 # The above example will extract the tarball to
34 # ${WORKDIR}/${P}/src/github.com/user/package
40 *) die "${ECLASS} API in EAPI ${EAPI} not yet established."
43 EXPORT_FUNCTIONS src_unpack
45 # @FUNCTION: golang-vcs-snapshot_src_unpack
47 # Extract the first archive from ${A} to the appropriate location for GOPATH.
48 golang-vcs-snapshot_src_unpack() {
53 mkdir -p "${WORKDIR}/${P}/src/${EGO_PN%/...}" || die
54 tar -C "${WORKDIR}/${P}/src/${EGO_PN%/...}" -x --strip-components 1 \
55 -f "${DISTDIR}/${x}" || die