From 422d60ce9fc02f4ee602b5bf30195d57c1982c6a Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Wed, 31 Dec 2014 15:26:59 -0800 Subject: [PATCH 1/2] eclass: add basic eclass for building Go binaries This isn't particularly interesting right now but will be more important once it grows support for cgo and cross-compiling, things which our standard go build scripts don't handle. --- .../coreos-overlay/eclass/coreos-go.eclass | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 sdk_container/src/third_party/coreos-overlay/eclass/coreos-go.eclass diff --git a/sdk_container/src/third_party/coreos-overlay/eclass/coreos-go.eclass b/sdk_container/src/third_party/coreos-overlay/eclass/coreos-go.eclass new file mode 100644 index 0000000000..aee8c64749 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/eclass/coreos-go.eclass @@ -0,0 +1,61 @@ +# Copyright 2014 CoreOS, Inc. +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# @ECLASS: coreos-go.eclass +# @BLURB: utility functions for building Go binaries + +# @ECLASS-VARIABLE: COREOS_GO_PACKAGE +# @DESCRIPTION: +# Name of the Go package unpacked to ${S}, this is required. + +[[ ${EAPI} != "5" ]] && die "Only EAPI=5 is supported" + +inherit multiprocessing + +DEPEND="dev-lang/go" + +# @FUNCTION: go_build +# @USAGE: [] +go_build() { + debug-print-function ${FUNCNAME} "$@" + + [[ $# -eq 0 || $# -gt 2 ]] && die "go_install: incorrect # of arguments" + local package_name="$1" + local binary_name="${package_name##*/}" + + # TODO: handle cgo, cross-compiling, etc etc... + CGO_ENABLED=0 go build -x -p "$(makeopts_jobs)" \ + -o "${GOPATH}/bin/${binary_name}" "${package_name}" \ + || die "go build failed" +} + +coreos-go_src_prepare() { + debug-print-function ${FUNCNAME} "$@" + + export GOPATH="${WORKDIR}/gopath" + export GOBIN="${GOPATH}/bin" + mkdir -p "${GOBIN}" || die + + if [[ -z "${COREOS_GO_PACKAGE}" ]]; then + die "COREOS_GO_PACKAGE must be defined by the ebuild" + fi + + local package_path="${GOPATH}/src/${COREOS_GO_PACKAGE}" + mkdir -p "${package_path%/*}" || die + ln -sT "${S}" "${package_path}" || die +} + +coreos-go_src_compile() { + debug-print-function ${FUNCNAME} "$@" + + go_build "${COREOS_GO_PACKAGE}" +} + +coreos-go_src_install() { + debug-print-function ${FUNCNAME} "$@" + + dobin "${GOBIN}"/* +} + +EXPORT_FUNCTIONS src_prepare src_compile src_install From 1d86304c053509d803e06e4ea70e31a89d12f294 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Wed, 31 Dec 2014 15:29:42 -0800 Subject: [PATCH 2/2] coreos-devel/mantle: new SDK utility package Just the beginning for now, will eventually grow support for testing CoreOS builds and provide better integration with remote services like Google Cloud/Compute, Amazon, OpenStack clouds, etc. than we can achieve with our current collection of bash scripts. --- .../coreos-devel/mantle/mantle-0.0.1.ebuild | 1 + .../coreos-devel/mantle/mantle-9999.ebuild | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 120000 sdk_container/src/third_party/coreos-overlay/coreos-devel/mantle/mantle-0.0.1.ebuild create mode 100644 sdk_container/src/third_party/coreos-overlay/coreos-devel/mantle/mantle-9999.ebuild diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-devel/mantle/mantle-0.0.1.ebuild b/sdk_container/src/third_party/coreos-overlay/coreos-devel/mantle/mantle-0.0.1.ebuild new file mode 120000 index 0000000000..3969bcbf54 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/coreos-devel/mantle/mantle-0.0.1.ebuild @@ -0,0 +1 @@ +mantle-9999.ebuild \ No newline at end of file diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-devel/mantle/mantle-9999.ebuild b/sdk_container/src/third_party/coreos-overlay/coreos-devel/mantle/mantle-9999.ebuild new file mode 100644 index 0000000000..344a9b08d2 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/coreos-devel/mantle/mantle-9999.ebuild @@ -0,0 +1,25 @@ +# Copyright 2014 CoreOS, Inc. +# Distributed under the terms of the GNU General Public License v2 + +EAPI=5 +CROS_WORKON_PROJECT="coreos/mantle" +CROS_WORKON_REPO="git://github.com" +COREOS_GO_PACKAGE="github.com/coreos/mantle" + +if [[ "${PV}" == 9999 ]]; then + KEYWORDS="~amd64" +else + CROS_WORKON_COMMIT="14c53ce56771da9bc9a3f80a2f05a2aa65780e60" + KEYWORDS="amd64" +fi + +inherit coreos-go cros-workon + +DESCRIPTION="Mantle: Gluing CoreOS together" +HOMEPAGE="https://github.com/coreos/mantle" +LICENSE="Apache-2" +SLOT="0" + +src_compile() { + go_build "${COREOS_GO_PACKAGE}"/plume +}