aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Bernardo <samuelbernardo.mail@gmail.com>2024-06-09 23:17:15 +0100
committerSamuel Bernardo <samuelbernardo.mail@gmail.com>2024-06-09 23:17:15 +0100
commit2620a7e6416b23e8849ab44fe29ef8120f449c38 (patch)
tree97aeb0fedca00ed8650934bf38b11b9631087198
parentUpdate terraform and golang eclasses (diff)
downloadssnb-2620a7e6416b23e8849ab44fe29ef8120f449c38.tar.gz
ssnb-2620a7e6416b23e8849ab44fe29ef8120f449c38.tar.bz2
ssnb-2620a7e6416b23e8849ab44fe29ef8120f449c38.zip
Update terraform provider libvirt and add required golang eclasses
Signed-off-by: Samuel Bernardo <samuelbernardo.mail@gmail.com>
-rw-r--r--app-admin/terraform-provider-libvirt/Manifest8
-rw-r--r--app-admin/terraform-provider-libvirt/terraform-provider-libvirt-0.3.ebuild34
-rw-r--r--app-admin/terraform-provider-libvirt/terraform-provider-libvirt-0.4.4.ebuild34
-rw-r--r--app-admin/terraform-provider-libvirt/terraform-provider-libvirt-0.7.6.ebuild (renamed from app-admin/terraform-provider-libvirt/terraform-provider-libvirt-0.6.1.ebuild)4
-rw-r--r--eclass/go-env.eclass112
-rw-r--r--eclass/golang-base.eclass94
-rw-r--r--eclass/golang-build.eclass85
-rw-r--r--eclass/golang-vcs-snapshot.eclass129
8 files changed, 424 insertions, 76 deletions
diff --git a/app-admin/terraform-provider-libvirt/Manifest b/app-admin/terraform-provider-libvirt/Manifest
index c6fae9e..45924e3 100644
--- a/app-admin/terraform-provider-libvirt/Manifest
+++ b/app-admin/terraform-provider-libvirt/Manifest
@@ -1,7 +1,3 @@
-DIST terraform-provider-libvirt-0.3.tar.gz 36134363 BLAKE2B 0fde1cb1ef3847f1b6d44a3f3c43709d5c45175378e47ae4e3c0cf6c37b5116ec554711b045ab191bee0e8dd6bea8cc51f046650d60eada6c21f58e9071b707a SHA512 d796e79e97386fda28b17e830516f51ecee49fb89b205af14e646fc91dfcb05b609913f087c5ab4d10410da744cdeb8d7257ce8fa10af5ea6afa185da659f643
-DIST terraform-provider-libvirt-0.4.4.tar.gz 64919973 BLAKE2B 664c409501507706e9cd4ba76cb969ec67cfce4e640f5bc227ea6ce999b40d71e42ef0291905a994a60325a7ed19980731cffeb4021b979b91fe1abfe8303673 SHA512 0c66858fcfcd98fef84d63d5fe7848c7231b56b5d5b45decb04216e3f8ad0cea52324b815e506b9f585fbbbd883778e5dd045cc6d6899a5c031b422ed6b70f17
-DIST terraform-provider-libvirt-0.6.1.tar.gz 22319066 BLAKE2B 82ac2859dde3a7957196ed0fa602923124acf68cd0e05326f2208ff6098366c8e87a80c6dcae5e3a71a472cfc39c7149dbd4683db1b976ad0ce7f9fed8ac4fd7 SHA512 f0bc775e7b97206136f867064d3cf2e4d3eb9c209336da70edf54e3d5d2a1ebe9ce2cd927526da9e5ef90096022bdffa9b6568cc07a9f0321478c3c9881fd6ca
-EBUILD terraform-provider-libvirt-0.3.ebuild 666 BLAKE2B eee787ef261bb8a4be4aed726a7de2e4068bd33b3bf00f23577d8e505f27aa9aefd57f1020324ff128697caeab707d201bea5e9981937bc1e3a8560ea00c1882 SHA512 41cd41cca4170c44abf84b928cfdecb62ac2d17b5436da7e79d71d9d6d793b01fca7612050669ddbad416b2e9547bdf9d7f35f39763b0eeee16721ad0470a2f3
-EBUILD terraform-provider-libvirt-0.4.4.ebuild 665 BLAKE2B b9d8997f003899ecbf2367d143dbb121aaccf9e1d50fd2901c50ff70dd6f6aae05ae7eacff7d16aff7eab1c133658266bd26b68caac8e2a0715cca4b55a682b8 SHA512 8770f3c114971851d7282cd9fa59928f70f898f53711927556d6c4a8ae982ef3f9df38fcc33a02fdeed89cb06d68136e3d6b654de98ed6fdaa6f9ce72020b616
-EBUILD terraform-provider-libvirt-0.6.1.ebuild 846 BLAKE2B 2ec92a6e6ec6639810df37f6b6a753545e5c1f380ed6f208713db22012cb694cf2734efb9eded5cab0702b7447610a6ae6fb30bf3d81c621fa4d9a50848a8835 SHA512 83ea2d346b3273dbb53722f66649f996df14d250bae9136248565ee999c0f9968a18cded5671abaaf5b16e9d7f736713b8df354b3d4bb459ca94d7bdda1b676e
+DIST terraform-provider-libvirt-0.7.6.tar.gz 16370221 BLAKE2B 2423ad2be3c24eb96abeac189ebc2f8beea52d7eaf3d785d9c9db69f64a3e81f447a278be262eeaadf3141f0dc0a7d43aca08f1b78f8971776c9f5eaf9f72795 SHA512 ad0b6780fc3a3236ca5724fbaa9ea0ada993b8785d52216fea93bdc21a03db57b4c06388555443ae1ee55aba636f4ef3b55c4669bf326ab529169ca6809c91b9
+EBUILD terraform-provider-libvirt-0.7.6.ebuild 843 BLAKE2B ed67e5eca798923d8de3f6856565bcf186181b3e7ed2d175660f379a7b55d9c11e098a72c44ec0114bd39659298f4fb53233784f643d1cc0d8070d1ffbd948aa SHA512 f72e3d9dbf1c3a4a618b6b433fc412d1e713faede7e40288a9a4ca095773f7cb1bbdf89a79f1adbc6495d8cb58b3319323503966dd1acf4357f6cd7599d5ec54
MISC metadata.xml 384 BLAKE2B a977c9a290d9a50c818b53b95369d9e564f37ba5be80d62739016f6c8933f52c6efca8ad09bad4a78212d1bb608d007f1c5559732d8399184735dad02892e54b SHA512 85b5d1cb9a1645b89d2f3b586c9c53b308860a075505dd1aee536115c41a9e0ba36c9e05f5025f749e71e9945d9c09785ee02054cf759696551de0bd5a2efb1f
diff --git a/app-admin/terraform-provider-libvirt/terraform-provider-libvirt-0.3.ebuild b/app-admin/terraform-provider-libvirt/terraform-provider-libvirt-0.3.ebuild
deleted file mode 100644
index 6b03e38..0000000
--- a/app-admin/terraform-provider-libvirt/terraform-provider-libvirt-0.3.ebuild
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=6
-
-GOLANG_PKG_IMPORTPATH="github.com/dmacvicar"
-GOLANG_PKG_ARCHIVEPREFIX="v"
-GOLANG_PKG_HAVE_TEST=1
-GOLANG_PKG_USE_CGO="yes"
-
-inherit golang-single versionator
-
-#GOLANG_PKG_VERSION="$(get_version_component_range 1-2)"
-
-DESCRIPTION="Terraform builds, changes, and combines infrastructure safely and efficiently"
-HOMEPAGE="http://www.terraform.io"
-
-LICENSE="Apache 2.0"
-SLOT="0"
-KEYWORDS="amd64 x86"
-IUSE=""
-
-RDEPEND="app-emulation/libvirt-glib
- dev-lang/go
- app-cdr/cdrtools"
-
-DOCS=(
- README.md
- examples/
-)
-
-src_install() {
- golang-single_src_install
-}
diff --git a/app-admin/terraform-provider-libvirt/terraform-provider-libvirt-0.4.4.ebuild b/app-admin/terraform-provider-libvirt/terraform-provider-libvirt-0.4.4.ebuild
deleted file mode 100644
index bed3cbd..0000000
--- a/app-admin/terraform-provider-libvirt/terraform-provider-libvirt-0.4.4.ebuild
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=6
-
-GOLANG_PKG_IMPORTPATH="github.com/dmacvicar"
-GOLANG_PKG_ARCHIVEPREFIX="v"
-GOLANG_PKG_HAVE_TEST=1
-GOLANG_PKG_USE_CGO="yes"
-
-inherit golang-single versionator
-
-GOLANG_PKG_VERSION="$(get_version_component_range 1-3)"
-
-DESCRIPTION="Terraform builds, changes, and combines infrastructure safely and efficiently"
-HOMEPAGE="http://www.terraform.io"
-
-LICENSE="Apache 2.0"
-SLOT="0"
-KEYWORDS="amd64 x86"
-IUSE=""
-
-RDEPEND="app-emulation/libvirt-glib
- dev-lang/go
- app-cdr/cdrtools"
-
-DOCS=(
- README.md
- examples/
-)
-
-src_install() {
- golang-single_src_install
-}
diff --git a/app-admin/terraform-provider-libvirt/terraform-provider-libvirt-0.6.1.ebuild b/app-admin/terraform-provider-libvirt/terraform-provider-libvirt-0.7.6.ebuild
index 4fa1678..5e1e67a 100644
--- a/app-admin/terraform-provider-libvirt/terraform-provider-libvirt-0.6.1.ebuild
+++ b/app-admin/terraform-provider-libvirt/terraform-provider-libvirt-0.7.6.ebuild
@@ -1,7 +1,7 @@
-# Copyright 1999-2020 Gentoo Foundation
+# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
-EAPI=7
+EAPI=8
GOLANG_PKG_IMPORTPATH="github.com/dmacvicar"
GOLANG_PKG_ARCHIVEPREFIX="v"
diff --git a/eclass/go-env.eclass b/eclass/go-env.eclass
new file mode 100644
index 0000000..2cd5506
--- /dev/null
+++ b/eclass/go-env.eclass
@@ -0,0 +1,112 @@
+# Copyright 2023-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: go-env.eclass
+# @MAINTAINER:
+# Samuel Bernardo <samuelbernardo.mail@gmail.com>
+# @AUTHOR:
+# Flatcar Linux Maintainers <infra@flatcar-linux.org>
+# @BLURB: Helper eclass for setting the Go compile environment. Required for cross-compiling.
+# @DESCRIPTION:
+# This eclass includes helper functions for setting the compile environment for Go ebuilds.
+# Intended to be called by other Go eclasses in an early build stage, e.g. src_unpack.
+
+if [[ -z ${_GO_ENV_ECLASS} ]]; then
+_GO_ENV_ECLASS=1
+
+inherit flag-o-matic toolchain-funcs
+
+# @FUNCTION: go-env_set_compile_environment
+# @DESCRIPTION:
+# Set up basic compile environment: CC, CXX, and GOARCH.
+# Necessary platform-specific settings such as GOARM or GO386 are also set
+# according to the Portage configuration when building for those architectures.
+# Also carry over CFLAGS, LDFLAGS and friends.
+# Required for cross-compiling with crossdev.
+# If not set, host defaults will be used and the resulting binaries are host arch.
+# (e.g. "emerge-aarch64-cross-linux-gnu foo" run on x86_64 will emerge "foo" for x86_64
+# instead of aarch64)
+go-env_set_compile_environment() {
+ tc-export CC CXX PKG_CONFIG
+
+ export GOARCH="$(go-env_goarch)"
+ use arm && export GOARM=$(go-env_goarm)
+ use x86 && export GO386=$(go-env_go386)
+
+ # XXX: Hack for checking ICE (bug #912152, gcc PR113204)
+ case ${EAPI} in
+ 6)
+ has_version "sys-devel/gcc[debug]" && filter-lto
+ ;;
+ *)
+ has_version -b "sys-devel/gcc[debug]" && filter-lto
+ ;;
+ esac
+
+ export CGO_CFLAGS="${CGO_CFLAGS:-$CFLAGS}"
+ export CGO_CPPFLAGS="${CGO_CPPFLAGS:-$CPPFLAGS}"
+ export CGO_CXXFLAGS="${CGO_CXXFLAGS:-$CXXFLAGS}"
+ export CGO_LDFLAGS="${CGO_LDFLAGS:-$LDFLAGS}"
+}
+
+# @FUNCTION: go-env_goarch
+# @USAGE: [toolchain prefix]
+# @DESCRIPTION:
+# Returns the appropriate GOARCH setting for the target architecture.
+go-env_goarch() {
+ # By chance most portage arch names match Go
+ local tc_arch=$(tc-arch $@)
+ case "${tc_arch}" in
+ x86) echo 386;;
+ x64-*) echo amd64;;
+ loong) echo loong64;;
+ mips) if use abi_mips_o32; then
+ [[ $(tc-endian $@) = big ]] && echo mips || echo mipsle
+ elif use abi_mips_n64; then
+ [[ $(tc-endian $@) = big ]] && echo mips64 || echo mips64le
+ fi ;;
+ ppc64) [[ $(tc-endian $@) = big ]] && echo ppc64 || echo ppc64le ;;
+ riscv) echo riscv64 ;;
+ s390) echo s390x ;;
+ *) echo "${tc_arch}";;
+ esac
+}
+
+# @FUNCTION: go-env_go386
+# @DESCRIPTION:
+# Returns the appropriate GO386 setting for the CFLAGS in use.
+go-env_go386() {
+ # Piggy-back off any existing CPU_FLAGS_X86 usage in the ebuild if
+ # it's there.
+ if in_iuse cpu_flags_x86_sse2 && use cpu_flags_x86_sse2 ; then
+ echo 'sse2'
+ return
+ fi
+
+ if tc-cpp-is-true "defined(__SSE2__)" ${CFLAGS} ${CXXFLAGS} ; then
+ echo 'sse2'
+ return
+ fi
+
+ # Go 1.16 dropped explicit support for 386 FP and relies on software
+ # emulation instead in the absence of SSE2.
+ echo 'softfloat'
+}
+
+# @FUNCTION: go-env_goarm
+# @USAGE: [CHOST-value]
+# @DESCRIPTION:
+# Returns the appropriate GOARM setting for the CHOST given, or the default
+# CHOST.
+go-env_goarm() {
+ case "${1:-${CHOST}}" in
+ armv5*) echo 5;;
+ armv6*) echo 6;;
+ armv7*) echo 7;;
+ *)
+ die "unknown GOARM for ${1:-${CHOST}}"
+ ;;
+ esac
+}
+
+fi
diff --git a/eclass/golang-base.eclass b/eclass/golang-base.eclass
new file mode 100644
index 0000000..5b3b6fd
--- /dev/null
+++ b/eclass/golang-base.eclass
@@ -0,0 +1,94 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: golang-base.eclass
+# @MAINTAINER:
+# Samuel Bernardo <samuelbernardo.mail@gmail.com>
+# @AUTHORS:
+# William Hubbs <williamh@gentoo.org>
+# @SUPPORTED_EAPIS: 5 6 7
+# @BLURB: Eclass that provides base functions for Go packages.
+# @DEPRECATED: go-module.eclass
+# @DESCRIPTION:
+# This eclass provides base functions for software written in the Go
+# programming language; it also provides the build-time dependency on
+# dev-lang/go.
+
+case "${EAPI:-0}" in
+ 8)
+ ;;
+ *)
+ die "${ECLASS}: Unsupported EAPI (EAPI=${EAPI})"
+ ;;
+esac
+
+if [[ -z ${_GOLANG_BASE} ]]; then
+
+_GOLANG_BASE=1
+
+GO_DEPEND=">=dev-lang/go-1.10"
+if [[ ${EAPI:-0} == [56] ]]; then
+ DEPEND="${GO_DEPEND}"
+else
+ BDEPEND="${GO_DEPEND}"
+fi
+
+# Do not complain about CFLAGS etc since go projects do not use them.
+QA_FLAGS_IGNORED='.*'
+
+# Upstream does not support stripping go packages
+RESTRICT="strip"
+
+# force GO111MODULE to be auto for bug https://bugs.gentoo.org/771129
+export GO111MODULE=auto
+
+# @ECLASS_VARIABLE: EGO_PN
+# @REQUIRED
+# @DESCRIPTION:
+# This is the import path for the go package to build. Please emerge
+# dev-lang/go and read "go help importpath" for syntax.
+#
+# Example:
+# @CODE
+# EGO_PN=github.com/user/package
+# @CODE
+
+# @FUNCTION: ego_pn_check
+# @DESCRIPTION:
+# Make sure EGO_PN has a value.
+ego_pn_check() {
+ [[ -z "${EGO_PN}" ]] &&
+ die "${ECLASS}.eclass: EGO_PN is not set"
+ return 0
+}
+
+# @FUNCTION: get_golibdir
+# @DESCRIPTION:
+# Return the non-prefixed library directory where Go packages
+# should be installed
+get_golibdir() {
+ echo /usr/lib/go-gentoo
+}
+
+# @FUNCTION: get_golibdir_gopath
+# @DESCRIPTION:
+# Return the library directory where Go packages should be installed
+# This is the prefixed version which should be included in GOPATH
+get_golibdir_gopath() {
+ echo "${EPREFIX}$(get_golibdir)"
+}
+
+# @FUNCTION: golang_install_pkgs
+# @DESCRIPTION:
+# Install Go packages.
+# This function assumes that $cwd is a Go workspace.
+golang_install_pkgs() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ ego_pn_check
+ insinto "$(get_golibdir)"
+ insopts -m0644 -p # preserve timestamps for bug 551486
+ doins -r pkg src
+}
+
+fi
diff --git a/eclass/golang-build.eclass b/eclass/golang-build.eclass
new file mode 100644
index 0000000..75e77ce
--- /dev/null
+++ b/eclass/golang-build.eclass
@@ -0,0 +1,85 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: golang-build.eclass
+# @MAINTAINER:
+# Samuel Bernardo <samuelbernardo.mail@gmail.com>
+# @AUTHORS:
+# William Hubbs <williamh@gentoo.org>
+# @SUPPORTED_EAPIS: 6 7
+# @PROVIDES: golang-base
+# @BLURB: Eclass for compiling go packages.
+# @DEPRECATED: go-module.eclass
+# @DESCRIPTION:
+# This eclass provides default src_compile, src_test and src_install
+# functions for software written in the Go programming language.
+
+case ${EAPI} in
+ 8) ;;
+ *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+if [[ -z ${_GOLANG_BUILD_ECLASS} ]]; then
+_GOLANG_BUILD_ECLASS=1
+
+inherit golang-base
+
+# @ECLASS_VARIABLE: EGO_BUILD_FLAGS
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# This allows you to pass build flags to the Go compiler. These flags
+# are common to the "go build" and "go install" commands used below.
+# Please emerge dev-lang/go and run "go help build" for the
+# documentation for these flags.
+#
+# Example:
+# @CODE
+# EGO_BUILD_FLAGS="-ldflags \"-X main.version ${PV}\""
+# @CODE
+
+# @ECLASS_VARIABLE: EGO_PN
+# @REQUIRED
+# @DESCRIPTION:
+# This is the import path for the go package(s) to build. Please emerge
+# dev-lang/go and read "go help importpath" for syntax.
+#
+# Example:
+# @CODE
+# EGO_PN=github.com/user/package
+# @CODE
+
+golang-build_src_compile() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ ego_pn_check
+ set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
+ GOCACHE="${T}/go-cache" \
+ go build -v -work -x ${EGO_BUILD_FLAGS} "${EGO_PN}"
+ echo "$@"
+ "$@" || die
+}
+
+golang-build_src_install() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ ego_pn_check
+ set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
+ go install -v -work -x ${EGO_BUILD_FLAGS} "${EGO_PN}"
+ echo "$@"
+ "$@" || die
+ golang_install_pkgs
+}
+
+golang-build_src_test() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ ego_pn_check
+ set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
+ go test -v -work -x "${EGO_PN}"
+ echo "$@"
+ "$@" || die
+}
+
+fi
+
+EXPORT_FUNCTIONS src_compile src_install src_test
diff --git a/eclass/golang-vcs-snapshot.eclass b/eclass/golang-vcs-snapshot.eclass
new file mode 100644
index 0000000..06aabd2
--- /dev/null
+++ b/eclass/golang-vcs-snapshot.eclass
@@ -0,0 +1,129 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: golang-vcs-snapshot.eclass
+# @MAINTAINER:
+# Samuel Bernardo <samuelbernardo.mail@gmail.com>
+# @AUTHORS:
+# William Hubbs <williamh@gentoo.org>
+# @SUPPORTED_EAPIS: 8
+# @PROVIDES: golang-base
+# @BLURB: eclass to unpack VCS snapshot tarballs for Go software
+# @DEPRECATED: go-module.eclass
+# @DESCRIPTION:
+# This eclass provides a convenience src_unpack() which unpacks the
+# first tarball mentioned in SRC_URI to its appropriate location in
+# ${WORKDIR}/${P}, treating ${WORKDIR}/${P} as a go workspace.
+# Also, it provides a downstream method of vendoring packages.
+#
+# The location where the tarball is extracted is defined as
+# ${WORKDIR}/${P}/src/${EGO_PN}. The location of vendored packages is
+# defined as ${WORKDIR}/${P}/src/${EGO_PN%/*}/vendor to match Go's
+# vendoring setup.
+#
+# The typical use case is VCS snapshots coming from github, bitbucket
+# and similar services.
+#
+# Please note that this eclass currently handles only tarballs
+# (.tar.gz), but support for more formats may be added in the future.
+#
+# @EXAMPLE:
+#
+# @CODE
+# EGO_PN=github.com/user/package
+# EGO_VENDOR=(
+# "github.com/xenolf/lego 6cac0ea7d8b28c889f709ec7fa92e92b82f490dd"
+# "golang.org/x/crypto 453249f01cfeb54c3d549ddb75ff152ca243f9d8 github.com/golang/crypto"
+# )
+#
+# inherit golang-vcs-snapshot
+#
+# SRC_URI="https://github.com/example/${PN}/tarball/v${PV} -> ${P}.tar.gz
+# ${EGO_VENDOR_URI}"
+# @CODE
+#
+# The above example will extract the tarball to
+# ${WORKDIR}/${P}/src/github.com/user/package
+# and add the vendored tarballs to ${WORKDIR}/src/${EGO_PN}/vendor
+
+case ${EAPI} in
+ 8) ;;
+ *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+if [[ -z ${_GOLANG_VCS_SNAPSHOT_ECLASS} ]]; then
+_GOLANG_VCS_SNAPSHOT_ECLASS=1
+
+inherit golang-base go-env
+
+# @ECLASS_VARIABLE: EGO_VENDOR
+# @DESCRIPTION:
+# This variable contains a list of vendored packages.
+# The items of this array are strings that contain the
+# import path and the git commit hash for a vendored package.
+# If the import path does not start with github.com, the third argument
+# can be used to point to a github repository.
+
+declare -arg EGO_VENDOR
+
+_golang-vcs-snapshot_set_vendor_uri() {
+ EGO_VENDOR_URI=
+ local lib
+ for lib in "${EGO_VENDOR[@]}"; do
+ lib=(${lib})
+ if [[ -n ${lib[2]} ]]; then
+ EGO_VENDOR_URI+=" https://${lib[2]}/archive/${lib[1]}.tar.gz -> ${lib[2]//\//-}-${lib[1]}.tar.gz"
+ else
+ EGO_VENDOR_URI+=" https://${lib[0]}/archive/${lib[1]}.tar.gz -> ${lib[0]//\//-}-${lib[1]}.tar.gz"
+ fi
+ done
+ readonly EGO_VENDOR_URI
+}
+
+_golang-vcs-snapshot_set_vendor_uri
+unset -f _golang-vcs-snapshot_set_vendor_uri
+
+_golang-vcs-snapshot_dovendor() {
+ local VENDOR_PATH=$1 VENDORPN=$2 TARBALL=$3
+ rm -rf "${VENDOR_PATH}/${VENDORPN}" || die
+ mkdir -p "${VENDOR_PATH}/${VENDORPN}" || die
+ tar -C "${VENDOR_PATH}/${VENDORPN}" -x --strip-components 1\
+ -f "${DISTDIR}"/${TARBALL} || die
+}
+
+# @FUNCTION: golang-vcs-snapshot_src_unpack
+# @DESCRIPTION:
+# Extract the first archive from ${A} to the appropriate location for GOPATH.
+# Set compile env via go-env.
+golang-vcs-snapshot_src_unpack() {
+ local lib vendor_path x
+ ego_pn_check
+ set -- ${A}
+ x="$1"
+ mkdir -p "${WORKDIR}/${P}/src/${EGO_PN%/...}" || die
+ tar -C "${WORKDIR}/${P}/src/${EGO_PN%/...}" -x --strip-components 1 \
+ -f "${DISTDIR}/${x}" || die
+
+ if [[ -n "${EGO_VENDOR}" ]]; then
+ vendor_path="${WORKDIR}/${P}/src/${EGO_PN%/...}/vendor"
+ mkdir -p "${vendor_path}" || die
+ for lib in "${EGO_VENDOR[@]}"; do
+ lib=(${lib})
+ if [[ -n ${lib[2]} ]]; then
+ einfo "Vendoring ${lib[0]} ${lib[2]//\//-}-${lib[1]}.tar.gz"
+ _golang-vcs-snapshot_dovendor "${vendor_path}" ${lib[0]} \
+ ${lib[2]//\//-}-${lib[1]}.tar.gz
+ else
+ einfo "Vendoring ${lib[0]} ${lib[0]//\//-}-${lib[1]}.tar.gz"
+ _golang-vcs-snapshot_dovendor "${vendor_path}" ${lib[0]} \
+ ${lib[0]//\//-}-${lib[1]}.tar.gz
+ fi
+ done
+ fi
+
+ go-env_set_compile_environment
+}
+
+fi
+
+EXPORT_FUNCTIONS src_unpack