public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] new eclass: go-live.eclass for handling go live ebuilds
@ 2015-06-04 19:10 William Hubbs
  2015-06-04 19:27 ` Andrew Udvare
  2015-06-05  4:54 ` Mike Frysinger
  0 siblings, 2 replies; 16+ messages in thread
From: William Hubbs @ 2015-06-04 19:10 UTC (permalink / raw
  To: gentoo development


[-- Attachment #1.1: Type: text/plain, Size: 280 bytes --]

All,

we are starting to get more go packages in the tree, so we need an
eclass that properly deals with go live ebuilds.

Attached you will find my proposal for this eclass. I will commit it on
6 Jun UTC if there is no feedback, so let me know what you think.

Thanks,

William


[-- Attachment #1.2: go-live.eclass --]
[-- Type: text/plain, Size: 3259 bytes --]

# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# @ECLASS: go-live.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.

case "${EAPI:-0}" in
	5)
		;;
	*)
		die "${ECLASS}: Unsupported eapi (EAPI=${EAPI})"
		;;
esac

EXPORT_FUNCTIONS src_unpack

if [[ ! ${_GO_LIVE} ]]; then

_GO_LIVE=1

DEPEND=">=dev-lang/go-1.4.2"

# @ECLASS-VARIABLE: EGO_PN
# @REQUIRED
# @DESCRIPTION:
# This is the import path for the go package. Please emerge dev-lang/go
# and read "go help importpath" for syntax.
#
# Example:
# @CODE
# EGO_PN="github.com/user/project"
# @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: _go-live_env_setup
# @INTERNAL
# @DESCRIPTION:
# Create EGO_STORE_DIR if necessary and set GOPATH.
_go-live_env_setup() {
	debug-print-function ${FUNCNAME} "$@"

	local distdir=${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}
	: ${EGO_STORE_DIR:=${distdir}/go-src}

	local saved_umask
	if [[ ${EVCS_UMASK} ]]; then
		saved_umask=$(umask)
		umask "${EVCS_UMASK}" ||
			die "${ECLASS}: bad options to umask: ${EVCS_UMASK}"
	fi

	if [[ ! -d ${EGO_STORE_DIR} ]]; then
		(
			addwrite /
			mkdir -p "${EGO_STORE_DIR}" || die
		) || die "${ECLASS}: unable to create ${EGO_STORE_DIR}"
	fi

	addwrite "${EGO_STORE_DIR}"
	export GOPATH="${EGO_STORE_DIR}"

	if [[ ${saved_umask} ]]; then
		umask "${saved_umask}" ||
			die "${ECLASS}: unable to restore saved umask"
	fi
	mkdir -p "${S}" ||
		die "${ECLASS}: unable to create ${S}"
}

# @FUNCTION: _go-live_fetch
# @INTERNAL
# @DESCRIPTION:
# Retrieve the EGO_PN go package along with its dependencies.
_go-live_fetch() {
	debug-print-function ${FUNCNAME} "$@"

	[[ ${EGO_PN} ]] ||
		die "${ECLASS}: EGO_PN is not set"

	if [[ ${EVCS_OFFLINE} ]]; then
		export GOPATH="${S}:${GOPATH}"
		return
	fi

	local saved_umask
	if [[ ${EVCS_UMASK} ]]; then
		saved_umask=$(umask)
		umask "${EVCS_UMASK}" ||
			die "${ECLASS}: Bad options to umask: ${EVCS_UMASK}"
	fi

	go get -d -t -u -v -x "$EGO_PN"
	[[ ! -d "${EGO_STORE_DIR}/src/${EGO_PN}" ]] &&
		die "${ECLASS}: unable to retrieve ${EGO_PN} or a dependency"

	if [[ ${saved_umask} ]]; then
		umask "${saved_umask}" ||
			die "${ECLASS}: unable to restore saved umask"
	fi
	export GOPATH="${S}:${GOPATH}"
}

go-live_src_fetch() {
	debug-print-function ${FUNCNAME} "$@"

	_go-live_env_setup
	_go-live_fetch
}

go-live_src_unpack() {
	debug-print-function ${FUNCNAME} "$@"

	go-live_src_fetch
}

fi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-06-16 21:03 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-04 19:10 [gentoo-dev] new eclass: go-live.eclass for handling go live ebuilds William Hubbs
2015-06-04 19:27 ` Andrew Udvare
2015-06-04 19:45   ` William Hubbs
2015-06-05  4:54 ` Mike Frysinger
2015-06-05 14:34   ` William Hubbs
2015-06-05 19:12     ` William Hubbs
2015-06-06  6:44       ` [gentoo-dev] " Duncan
2015-06-06  1:22     ` [gentoo-dev] " Mike Frysinger
2015-06-08 19:38       ` William Hubbs
2015-06-10  3:34         ` Dean Stephens
2015-06-10 15:08           ` William Hubbs
2015-06-11  4:28             ` Dean Stephens
2015-06-10 15:53         ` Mike Frysinger
2015-06-10 17:32           ` William Hubbs
2015-06-11 15:27             ` William Hubbs
2015-06-16 21:03               ` William Hubbs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox