summaryrefslogtreecommitdiff
path: root/eclass/golang-vcs.eclass
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2015-08-08 13:49:04 -0700
committerRobin H. Johnson <robbat2@gentoo.org>2015-08-08 17:38:18 -0700
commit56bd759df1d0c750a065b8c845e93d5dfa6b549d (patch)
tree3f91093cdb475e565ae857f1c5a7fd339e2d781e /eclass/golang-vcs.eclass
downloadgentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.gz
gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.xz
proj/gentoo: Initial commit
This commit represents a new era for Gentoo: Storing the gentoo-x86 tree in Git, as converted from CVS. This commit is the start of the NEW history. Any historical data is intended to be grafted onto this point. Creation process: 1. Take final CVS checkout snapshot 2. Remove ALL ChangeLog* files 3. Transform all Manifests to thin 4. Remove empty Manifests 5. Convert all stale $Header$/$Id$ CVS keywords to non-expanded Git $Id$ 5.1. Do not touch files with -kb/-ko keyword flags. Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> X-Thanks: Alec Warner <antarus@gentoo.org> - did the GSoC 2006 migration tests X-Thanks: Robin H. Johnson <robbat2@gentoo.org> - infra guy, herding this project X-Thanks: Nguyen Thai Ngoc Duy <pclouds@gentoo.org> - Former Gentoo developer, wrote Git features for the migration X-Thanks: Brian Harring <ferringb@gentoo.org> - wrote much python to improve cvs2svn X-Thanks: Rich Freeman <rich0@gentoo.org> - validation scripts X-Thanks: Patrick Lauer <patrick@gentoo.org> - Gentoo dev, running new 2014 work in migration X-Thanks: Michał Górny <mgorny@gentoo.org> - scripts, QA, nagging X-Thanks: All of other Gentoo developers - many ideas and lots of paint on the bikeshed
Diffstat (limited to 'eclass/golang-vcs.eclass')
-rw-r--r--eclass/golang-vcs.eclass153
1 files changed, 153 insertions, 0 deletions
diff --git a/eclass/golang-vcs.eclass b/eclass/golang-vcs.eclass
new file mode 100644
index 00000000000..2fe3a848b25
--- /dev/null
+++ b/eclass/golang-vcs.eclass
@@ -0,0 +1,153 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+# @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)
+ ;;
+ *)
+ 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_SRC
+# @DESCRIPTION:
+# This is the Go upstream repository which will be copied to
+# ${WORKDIR}/${P}.
+# If it isn't set, it defaults to the first word of ${EGO_PN}.
+# This should be set if you are retrieving a repository that includes
+# multiple packages, e.g. golang.org/x/tools.
+#
+# Example:
+# @CODE
+# EGO_PN="github.com/user/repository/..."
+# EGO_SRC="github.com/user/repository"
+# @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}"
+ if [ -z "${EGO_SRC}" ]; then
+ set -- ${EGO_PN}
+ EGO_SRC="$1"
+ fi
+ 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
+ set -- mkdir -p "${WORKDIR}/${P}/src/${EGO_SRC%/*}"
+ echo "$@"
+ "$@" || die "Unable to create ${WORKDIR}/${P}/src"
+ set -- cp -r "${EGO_STORE_DIR}/src/${EGO_SRC}" \
+ "${WORKDIR}/${P}/src/${EGO_SRC%/*}"
+ echo "$@"
+ "$@" || die "Unable to copy sources to ${WORKDIR}/${P}"
+ 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