mirror of
https://github.com/flatcar/scripts.git
synced 2025-11-16 16:12:00 +01:00
portage-stable/eclass: add Go cross-comile helper eclass
This change allows cross-compiling of Go packages and will be upstreamed. Signed-off-by: Thilo Fromm <thilofromm@microsoft.com>
This commit is contained in:
parent
7e493da5fc
commit
4b8f919bd1
46
sdk_container/src/third_party/portage-stable/eclass/go-env.eclass
vendored
Normal file
46
sdk_container/src/third_party/portage-stable/eclass/go-env.eclass
vendored
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# Copyright 2023 Flatcar Maintainers
|
||||||
|
# Distributed under the terms of the GNU General Public License v2
|
||||||
|
|
||||||
|
# @ECLASS: go-env.eclass
|
||||||
|
# @MAINTAINER:
|
||||||
|
# Flatcar Maintainers <infra@flatcar.org>
|
||||||
|
# @AUTHOR:
|
||||||
|
# Flatcar Maintainers <infra@flatcar.org>
|
||||||
|
# @SUPPORTED_EAPIS: 7 8
|
||||||
|
# @BLURB: Helper eclass for setting the Go compile environment. Required for cross-compiling.
|
||||||
|
# @DESCRIPTION:
|
||||||
|
# This eclass includes a helper function 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 toolchain-funcs
|
||||||
|
|
||||||
|
# Set up basic compile environment: CC, CXX, and GOARCH.
|
||||||
|
# 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() {
|
||||||
|
_arch() {
|
||||||
|
local arch=$(tc-arch "${CHOST}}")
|
||||||
|
case "${arch}" in
|
||||||
|
x86) echo "386" ;;
|
||||||
|
x64-*) echo "amd64" ;;
|
||||||
|
ppc64) if [[ "$(tc-endian "${${CHOST}}")" = "big" ]] then
|
||||||
|
echo "ppc64"
|
||||||
|
else
|
||||||
|
echo "ppc64le"
|
||||||
|
fi ;;
|
||||||
|
*) echo "${arch}" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
CC="$(tc-getCC)"
|
||||||
|
CXX="$(tc-getCXX)"
|
||||||
|
# Needs explicit export to arrive in go environment.
|
||||||
|
export GOARCH="$(_arch)"
|
||||||
|
}
|
||||||
|
|
||||||
|
fi
|
||||||
@ -1,4 +1,4 @@
|
|||||||
# Copyright 2019-2022 Gentoo Authors
|
# Copyright 2019-2023 Gentoo Authors
|
||||||
# Distributed under the terms of the GNU General Public License v2
|
# Distributed under the terms of the GNU General Public License v2
|
||||||
|
|
||||||
# @ECLASS: go-module.eclass
|
# @ECLASS: go-module.eclass
|
||||||
@ -26,7 +26,9 @@
|
|||||||
# If the software has a directory named vendor in its
|
# If the software has a directory named vendor in its
|
||||||
# top level directory, the only thing you need to do is inherit the
|
# top level directory, the only thing you need to do is inherit the
|
||||||
# eclass. If it doesn't, you need to also create a dependency tarball and
|
# eclass. If it doesn't, you need to also create a dependency tarball and
|
||||||
# host it somewhere, for example in your dev space.
|
# host it somewhere, for example in your dev space. It's recommended that
|
||||||
|
# a format supporting parallel decompression is used and developers should
|
||||||
|
# use higher levels of compression like '-9' for xz.
|
||||||
#
|
#
|
||||||
# Here is an example of how to create a dependency tarball.
|
# Here is an example of how to create a dependency tarball.
|
||||||
# The base directory in the GOMODCACHE setting must be go-mod in order
|
# The base directory in the GOMODCACHE setting must be go-mod in order
|
||||||
@ -36,7 +38,7 @@
|
|||||||
#
|
#
|
||||||
# $ cd /path/to/project
|
# $ cd /path/to/project
|
||||||
# $ GOMODCACHE="${PWD}"/go-mod go mod download -modcacherw
|
# $ GOMODCACHE="${PWD}"/go-mod go mod download -modcacherw
|
||||||
# $ tar -acf project-1.0-deps.tar.xz go-mod
|
# $ XZ_OPT='-T0 -9' tar -acf project-1.0-deps.tar.xz go-mod
|
||||||
#
|
#
|
||||||
# @CODE
|
# @CODE
|
||||||
#
|
#
|
||||||
@ -63,20 +65,19 @@ case ${EAPI} in
|
|||||||
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
|
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [[ -z ${_GO_MODULE} ]]; then
|
if [[ -z ${_GO_MODULE_ECLASS} ]]; then
|
||||||
|
_GO_MODULE_ECLASS=1
|
||||||
|
|
||||||
_GO_MODULE=1
|
inherit multiprocessing toolchain-funcs go-env
|
||||||
|
|
||||||
if [[ ! ${GO_OPTIONAL} ]]; then
|
if [[ ! ${GO_OPTIONAL} ]]; then
|
||||||
BDEPEND=">=dev-lang/go-1.16"
|
BDEPEND=">=dev-lang/go-1.18"
|
||||||
|
|
||||||
# Workaround for pkgcheck false positive: https://github.com/pkgcore/pkgcheck/issues/214
|
# Workaround for pkgcheck false positive: https://github.com/pkgcore/pkgcheck/issues/214
|
||||||
# MissingUnpackerDep: version ...: missing BDEPEND="app-arch/unzip"
|
# MissingUnpackerDep: version ...: missing BDEPEND="app-arch/unzip"
|
||||||
# Added here rather than to each affected package, so it can be cleaned up just
|
# Added here rather than to each affected package, so it can be cleaned up just
|
||||||
# once when pkgcheck is improved.
|
# once when pkgcheck is improved.
|
||||||
BDEPEND+=" app-arch/unzip"
|
BDEPEND+=" app-arch/unzip"
|
||||||
|
|
||||||
EXPORT_FUNCTIONS src_unpack
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Force go to build in module mode.
|
# Force go to build in module mode.
|
||||||
@ -93,10 +94,12 @@ export GOCACHE="${T}/go-build"
|
|||||||
export GOMODCACHE="${WORKDIR}/go-mod"
|
export GOMODCACHE="${WORKDIR}/go-mod"
|
||||||
|
|
||||||
# The following go flags should be used for all builds.
|
# The following go flags should be used for all builds.
|
||||||
|
# -buildmode=pie builds position independent executables
|
||||||
|
# -buildvcs=false omits version control information
|
||||||
# -modcacherw makes the build cache read/write
|
# -modcacherw makes the build cache read/write
|
||||||
# -v prints the names of packages as they are compiled
|
# -v prints the names of packages as they are compiled
|
||||||
# -x prints commands as they are executed
|
# -x prints commands as they are executed
|
||||||
export GOFLAGS="-modcacherw -v -x"
|
export GOFLAGS="-buildvcs=false -modcacherw -v -x"
|
||||||
|
|
||||||
# Do not complain about CFLAGS etc since go projects do not use them.
|
# Do not complain about CFLAGS etc since go projects do not use them.
|
||||||
QA_FLAGS_IGNORED='.*'
|
QA_FLAGS_IGNORED='.*'
|
||||||
@ -104,8 +107,8 @@ QA_FLAGS_IGNORED='.*'
|
|||||||
# Go packages should not be stripped with strip(1).
|
# Go packages should not be stripped with strip(1).
|
||||||
RESTRICT+=" strip"
|
RESTRICT+=" strip"
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: EGO_SUM
|
# @ECLASS_VARIABLE: EGO_SUM
|
||||||
# @DEPRECATED:
|
# @DEPRECATED: none
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# This is replaced by a dependency tarball, see above for how to create
|
# This is replaced by a dependency tarball, see above for how to create
|
||||||
# one.
|
# one.
|
||||||
@ -152,8 +155,8 @@ RESTRICT+=" strip"
|
|||||||
# This decision does NOT weaken Go module security, as Go will verify the
|
# This decision does NOT weaken Go module security, as Go will verify the
|
||||||
# go.sum copy of the Hash1 values during building of the package.
|
# go.sum copy of the Hash1 values during building of the package.
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: _GOMODULE_GOPROXY_BASEURI
|
# @ECLASS_VARIABLE: _GOMODULE_GOPROXY_BASEURI
|
||||||
# @DEPRECATED:
|
# @DEPRECATED: none
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Golang module proxy service to fetch module files from. Note that the module
|
# Golang module proxy service to fetch module files from. Note that the module
|
||||||
# proxy generally verifies modules via the Hash1 code.
|
# proxy generally verifies modules via the Hash1 code.
|
||||||
@ -175,15 +178,15 @@ RESTRICT+=" strip"
|
|||||||
# below, so please do not rely on it.
|
# below, so please do not rely on it.
|
||||||
: "${_GOMODULE_GOPROXY_BASEURI:=mirror://goproxy/}"
|
: "${_GOMODULE_GOPROXY_BASEURI:=mirror://goproxy/}"
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: _GOMODULE_GOSUM_REVERSE_MAP
|
# @ECLASS_VARIABLE: _GOMODULE_GOSUM_REVERSE_MAP
|
||||||
# @DEPRECATED:
|
# @DEPRECATED: none
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Mapping back from Gentoo distfile name to upstream distfile path.
|
# Mapping back from Gentoo distfile name to upstream distfile path.
|
||||||
# Associative array to avoid O(N*M) performance when populating the GOPROXY
|
# Associative array to avoid O(N*M) performance when populating the GOPROXY
|
||||||
# directory structure.
|
# directory structure.
|
||||||
declare -A -g _GOMODULE_GOSUM_REVERSE_MAP
|
declare -A -g _GOMODULE_GOSUM_REVERSE_MAP
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: GO_OPTIONAL
|
# @ECLASS_VARIABLE: GO_OPTIONAL
|
||||||
# @DEFAULT_UNSET
|
# @DEFAULT_UNSET
|
||||||
# @PRE_INHERIT
|
# @PRE_INHERIT
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
@ -206,7 +209,7 @@ ego() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# @FUNCTION: go-module_set_globals
|
# @FUNCTION: go-module_set_globals
|
||||||
# @DEPRECATED:
|
# @DEPRECATED: none
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Convert the information in EGO_SUM for other usage in the ebuild.
|
# Convert the information in EGO_SUM for other usage in the ebuild.
|
||||||
# - Populates EGO_SUM_SRC_URI that can be added to SRC_URI
|
# - Populates EGO_SUM_SRC_URI that can be added to SRC_URI
|
||||||
@ -259,7 +262,22 @@ go-module_set_globals() {
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_dir=$(_go-module_gomod_encode "${module}")
|
# Encode the name(path) of a Golang module in the format expected by Goproxy.
|
||||||
|
# Upper letters are replaced by their lowercase version with a '!' prefix.
|
||||||
|
# The transformed result of 'module' is stored in the '_dir' variable.
|
||||||
|
#
|
||||||
|
## Python:
|
||||||
|
# return re.sub('([A-Z]{1})', r'!\1', s).lower()
|
||||||
|
## Sed:
|
||||||
|
## This uses GNU Sed extension \l to downcase the match
|
||||||
|
# echo "${module}" |sed 's,[A-Z],!\l&,g'
|
||||||
|
local re _dir lower
|
||||||
|
_dir="${module}"
|
||||||
|
re='(.*)([A-Z])(.*)'
|
||||||
|
while [[ ${_dir} =~ ${re} ]]; do
|
||||||
|
lower='!'"${BASH_REMATCH[2],}"
|
||||||
|
_dir="${BASH_REMATCH[1]}${lower}${BASH_REMATCH[3]}"
|
||||||
|
done
|
||||||
|
|
||||||
for _ext in "${exts[@]}" ; do
|
for _ext in "${exts[@]}" ; do
|
||||||
# Relative URI within a GOPROXY for a file
|
# Relative URI within a GOPROXY for a file
|
||||||
@ -297,7 +315,7 @@ go-module_set_globals() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# @FUNCTION: go-module_setup_proxy
|
# @FUNCTION: go-module_setup_proxy
|
||||||
# @DEPRECATED:
|
# @DEPRECATED: none
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# If your ebuild redefines src_unpack and uses EGO_SUM you need to call
|
# If your ebuild redefines src_unpack and uses EGO_SUM you need to call
|
||||||
# this function in src_unpack.
|
# this function in src_unpack.
|
||||||
@ -340,11 +358,18 @@ go-module_setup_proxy() {
|
|||||||
|
|
||||||
# @FUNCTION: go-module_src_unpack
|
# @FUNCTION: go-module_src_unpack
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# If EGO_SUM is set, unpack the base tarball(s) and set up the
|
# Sets up GOFLAGS for the system and then unpacks based on the following rules:
|
||||||
# local go proxy. Also warn that this usage is deprecated.
|
# 1. If EGO_SUM is set, unpack the base tarball(s) and set up the
|
||||||
# - Otherwise, if EGO_VENDOR is set, bail out.
|
# local go proxy. This mode is deprecated.
|
||||||
# - Otherwise do a normal unpack.
|
# 2. Otherwise, if EGO_VENDOR is set, bail out, as this functionality was removed.
|
||||||
|
# 3. Otherwise, call 'ego mod verify' and then do a normal unpack.
|
||||||
|
# Set compile env via go-env.
|
||||||
go-module_src_unpack() {
|
go-module_src_unpack() {
|
||||||
|
if use amd64 || use arm || use arm64 ||
|
||||||
|
( use ppc64 && [[ $(tc-endian) == "little" ]] ) || use s390 || use x86; then
|
||||||
|
GOFLAGS="-buildmode=pie ${GOFLAGS}"
|
||||||
|
fi
|
||||||
|
GOFLAGS="${GOFLAGS} -p=$(makeopts_jobs)"
|
||||||
if [[ "${#EGO_SUM[@]}" -gt 0 ]]; then
|
if [[ "${#EGO_SUM[@]}" -gt 0 ]]; then
|
||||||
eqawarn "This ebuild uses EGO_SUM which is deprecated"
|
eqawarn "This ebuild uses EGO_SUM which is deprecated"
|
||||||
eqawarn "Please migrate to a dependency tarball"
|
eqawarn "Please migrate to a dependency tarball"
|
||||||
@ -355,11 +380,19 @@ go-module_src_unpack() {
|
|||||||
die "Please update this ebuild"
|
die "Please update this ebuild"
|
||||||
else
|
else
|
||||||
default
|
default
|
||||||
|
if [[ ! -d "${S}"/vendor ]]; then
|
||||||
|
cd "${S}"
|
||||||
|
local nf
|
||||||
|
[[ -n ${NONFATAL_VERIFY} ]] && nf=nonfatal
|
||||||
|
${nf} ego mod verify
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
go-env_set_compile_environment
|
||||||
}
|
}
|
||||||
|
|
||||||
# @FUNCTION: _go-module_src_unpack_gosum
|
# @FUNCTION: _go-module_src_unpack_gosum
|
||||||
# @DEPRECATED:
|
# @DEPRECATED: none
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Populate a GOPROXY directory hierarchy with distfiles from EGO_SUM and
|
# Populate a GOPROXY directory hierarchy with distfiles from EGO_SUM and
|
||||||
# unpack the base distfiles.
|
# unpack the base distfiles.
|
||||||
@ -405,7 +438,7 @@ _go-module_src_unpack_gosum() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# @FUNCTION: _go-module_gosum_synthesize_files
|
# @FUNCTION: _go-module_gosum_synthesize_files
|
||||||
# @DEPRECATED:
|
# @DEPRECATED: none
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Given a path & version, populate all Goproxy metadata files which aren't
|
# Given a path & version, populate all Goproxy metadata files which aren't
|
||||||
# needed to be downloaded directly.
|
# needed to be downloaded directly.
|
||||||
@ -433,7 +466,7 @@ _go-module_gosum_synthesize_files() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# @FUNCTION: _go-module_src_unpack_verify_gosum
|
# @FUNCTION: _go-module_src_unpack_verify_gosum
|
||||||
# @DEPRECATED:
|
# @DEPRECATED: none
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Validate the Go modules declared by EGO_SUM are sufficient to cover building
|
# Validate the Go modules declared by EGO_SUM are sufficient to cover building
|
||||||
# the package, without actually building it yet.
|
# the package, without actually building it yet.
|
||||||
@ -481,31 +514,8 @@ go-module_live_vendor() {
|
|||||||
popd >& /dev/null || die
|
popd >& /dev/null || die
|
||||||
}
|
}
|
||||||
|
|
||||||
# @FUNCTION: _go-module_gomod_encode
|
fi
|
||||||
# @DEPRECATED:
|
|
||||||
# @DESCRIPTION:
|
if [[ ! ${GO_OPTIONAL} ]]; then
|
||||||
# Encode the name(path) of a Golang module in the format expected by Goproxy.
|
EXPORT_FUNCTIONS src_unpack
|
||||||
#
|
|
||||||
# Upper letters are replaced by their lowercase version with a '!' prefix.
|
|
||||||
#
|
|
||||||
_go-module_gomod_encode() {
|
|
||||||
## Python:
|
|
||||||
# return re.sub('([A-Z]{1})', r'!\1', s).lower()
|
|
||||||
|
|
||||||
## Sed:
|
|
||||||
## This uses GNU Sed extension \l to downcase the match
|
|
||||||
#echo "${module}" |sed 's,[A-Z],!\l&,g'
|
|
||||||
#
|
|
||||||
# Bash variant:
|
|
||||||
debug-print-function "${FUNCNAME}" "$@"
|
|
||||||
#local re input lower
|
|
||||||
re='(.*)([A-Z])(.*)'
|
|
||||||
input="${1}"
|
|
||||||
while [[ ${input} =~ ${re} ]]; do
|
|
||||||
lower='!'"${BASH_REMATCH[2],}"
|
|
||||||
input="${BASH_REMATCH[1]}${lower}${BASH_REMATCH[3]}"
|
|
||||||
done
|
|
||||||
echo "${input}"
|
|
||||||
}
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
# Copyright 1999-2021 Gentoo Authors
|
# Copyright 1999-2022 Gentoo Authors
|
||||||
# Distributed under the terms of the GNU General Public License v2
|
# Distributed under the terms of the GNU General Public License v2
|
||||||
|
|
||||||
# @ECLASS: golang-base.eclass
|
# @ECLASS: golang-base.eclass
|
||||||
# @MAINTAINER:
|
# @MAINTAINER:
|
||||||
# William Hubbs <williamh@gentoo.org>
|
# William Hubbs <williamh@gentoo.org>
|
||||||
# @SUPPORTED_EAPIS: 5 6 7
|
# @SUPPORTED_EAPIS: 5 6 7
|
||||||
# @DEPRECATED: go-module.eclass
|
|
||||||
# @BLURB: Eclass that provides base functions for Go packages.
|
# @BLURB: Eclass that provides base functions for Go packages.
|
||||||
|
# @DEPRECATED: go-module.eclass
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# This eclass provides base functions for software written in the Go
|
# This eclass provides base functions for software written in the Go
|
||||||
# programming language; it also provides the build-time dependency on
|
# programming language; it also provides the build-time dependency on
|
||||||
@ -40,7 +40,7 @@ RESTRICT="strip"
|
|||||||
# force GO111MODULE to be auto for bug https://bugs.gentoo.org/771129
|
# force GO111MODULE to be auto for bug https://bugs.gentoo.org/771129
|
||||||
export GO111MODULE=auto
|
export GO111MODULE=auto
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: EGO_PN
|
# @ECLASS_VARIABLE: EGO_PN
|
||||||
# @REQUIRED
|
# @REQUIRED
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# This is the import path for the go package to build. Please emerge
|
# This is the import path for the go package to build. Please emerge
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
# Copyright 1999-2021 Gentoo Authors
|
# Copyright 1999-2023 Gentoo Authors
|
||||||
# Distributed under the terms of the GNU General Public License v2
|
# Distributed under the terms of the GNU General Public License v2
|
||||||
|
|
||||||
# @ECLASS: golang-vcs-snapshot.eclass
|
# @ECLASS: golang-vcs-snapshot.eclass
|
||||||
# @MAINTAINER:
|
# @MAINTAINER:
|
||||||
# William Hubbs <williamh@gentoo.org>
|
# William Hubbs <williamh@gentoo.org>
|
||||||
# @SUPPORTED_EAPIS: 5 6 7
|
# @SUPPORTED_EAPIS: 6 7
|
||||||
# @PROVIDES: golang-base
|
# @PROVIDES: golang-base
|
||||||
# @BLURB: eclass to unpack VCS snapshot tarballs for Go software
|
# @BLURB: eclass to unpack VCS snapshot tarballs for Go software
|
||||||
# @DEPRECATED: go-module.eclass
|
# @DEPRECATED: go-module.eclass
|
||||||
@ -44,16 +44,17 @@
|
|||||||
# ${WORKDIR}/${P}/src/github.com/user/package
|
# ${WORKDIR}/${P}/src/github.com/user/package
|
||||||
# and add the vendored tarballs to ${WORKDIR}/src/${EGO_PN}/vendor
|
# and add the vendored tarballs to ${WORKDIR}/src/${EGO_PN}/vendor
|
||||||
|
|
||||||
inherit golang-base
|
case ${EAPI} in
|
||||||
|
6|7) ;;
|
||||||
case ${EAPI:-0} in
|
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
|
||||||
5|6|7) ;;
|
|
||||||
*) die "${ECLASS} API in EAPI ${EAPI} not yet established."
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
EXPORT_FUNCTIONS src_unpack
|
if [[ -z ${_GOLANG_VCS_SNAPSHOT_ECLASS} ]]; then
|
||||||
|
_GOLANG_VCS_SNAPSHOT_ECLASS=1
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: EGO_VENDOR
|
inherit golang-base go-env
|
||||||
|
|
||||||
|
# @ECLASS_VARIABLE: EGO_VENDOR
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# This variable contains a list of vendored packages.
|
# This variable contains a list of vendored packages.
|
||||||
# The items of this array are strings that contain the
|
# The items of this array are strings that contain the
|
||||||
@ -82,7 +83,7 @@ unset -f _golang-vcs-snapshot_set_vendor_uri
|
|||||||
|
|
||||||
_golang-vcs-snapshot_dovendor() {
|
_golang-vcs-snapshot_dovendor() {
|
||||||
local VENDOR_PATH=$1 VENDORPN=$2 TARBALL=$3
|
local VENDOR_PATH=$1 VENDORPN=$2 TARBALL=$3
|
||||||
rm -fr "${VENDOR_PATH}/${VENDORPN}" || die
|
rm -rf "${VENDOR_PATH}/${VENDORPN}" || die
|
||||||
mkdir -p "${VENDOR_PATH}/${VENDORPN}" || die
|
mkdir -p "${VENDOR_PATH}/${VENDORPN}" || die
|
||||||
tar -C "${VENDOR_PATH}/${VENDORPN}" -x --strip-components 1\
|
tar -C "${VENDOR_PATH}/${VENDORPN}" -x --strip-components 1\
|
||||||
-f "${DISTDIR}"/${TARBALL} || die
|
-f "${DISTDIR}"/${TARBALL} || die
|
||||||
@ -91,6 +92,7 @@ _golang-vcs-snapshot_dovendor() {
|
|||||||
# @FUNCTION: golang-vcs-snapshot_src_unpack
|
# @FUNCTION: golang-vcs-snapshot_src_unpack
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Extract the first archive from ${A} to the appropriate location for GOPATH.
|
# Extract the first archive from ${A} to the appropriate location for GOPATH.
|
||||||
|
# Set compile env via go-env.
|
||||||
golang-vcs-snapshot_src_unpack() {
|
golang-vcs-snapshot_src_unpack() {
|
||||||
local lib vendor_path x
|
local lib vendor_path x
|
||||||
ego_pn_check
|
ego_pn_check
|
||||||
@ -116,4 +118,10 @@ golang-vcs-snapshot_src_unpack() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
go-env_set_compile_environment
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
EXPORT_FUNCTIONS src_unpack
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
# Copyright 1999-2021 Gentoo Authors
|
# Copyright 1999-2023 Gentoo Authors
|
||||||
# Distributed under the terms of the GNU General Public License v2
|
# Distributed under the terms of the GNU General Public License v2
|
||||||
|
|
||||||
# @ECLASS: golang-vcs.eclass
|
# @ECLASS: golang-vcs.eclass
|
||||||
# @MAINTAINER:
|
# @MAINTAINER:
|
||||||
# William Hubbs <williamh@gentoo.org>
|
# William Hubbs <williamh@gentoo.org>
|
||||||
# @SUPPORTED_EAPIS: 5 6 7
|
# @SUPPORTED_EAPIS: 6 7
|
||||||
# @PROVIDES: golang-base
|
# @PROVIDES: golang-base
|
||||||
# @BLURB: Eclass for fetching and unpacking go repositories.
|
# @BLURB: Eclass for fetching and unpacking go repositories.
|
||||||
# @DEPRECATED: go-module.eclass
|
# @DEPRECATED: go-module.eclass
|
||||||
@ -12,25 +12,19 @@
|
|||||||
# This eclass is written to ease the maintenance of live ebuilds
|
# This eclass is written to ease the maintenance of live ebuilds
|
||||||
# of software written in the Go programming language.
|
# of software written in the Go programming language.
|
||||||
|
|
||||||
inherit estack eutils golang-base
|
case ${EAPI} in
|
||||||
|
6|7) ;;
|
||||||
case "${EAPI:-0}" in
|
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
|
||||||
5|6|7)
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
die "${ECLASS}: Unsupported eapi (EAPI=${EAPI})"
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
EXPORT_FUNCTIONS src_unpack
|
if [[ -z ${_GOLANG_VCS_ECLASS} ]]; then
|
||||||
|
_GOLANG_VCS_ECLASS=1
|
||||||
|
|
||||||
if [[ -z ${_GOLANG_VCS} ]]; then
|
inherit estack golang-base go-env
|
||||||
|
|
||||||
_GOLANG_VCS=1
|
|
||||||
|
|
||||||
PROPERTIES+=" live"
|
PROPERTIES+=" live"
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: EGO_PN
|
# @ECLASS_VARIABLE: EGO_PN
|
||||||
# @REQUIRED
|
# @REQUIRED
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# This is the import path for the go package(s). Please emerge dev-lang/go
|
# This is the import path for the go package(s). Please emerge dev-lang/go
|
||||||
@ -42,7 +36,7 @@ PROPERTIES+=" live"
|
|||||||
# EGO_PN="github.com/user1/package1 github.com/user2/package2"
|
# EGO_PN="github.com/user1/package1 github.com/user2/package2"
|
||||||
# @CODE
|
# @CODE
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: EGO_STORE_DIR
|
# @ECLASS_VARIABLE: EGO_STORE_DIR
|
||||||
# @USER_VARIABLE
|
# @USER_VARIABLE
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Storage directory for Go sources.
|
# Storage directory for Go sources.
|
||||||
@ -52,12 +46,12 @@ PROPERTIES+=" live"
|
|||||||
#
|
#
|
||||||
# EGO_STORE_DIR=${DISTDIR}/go-src
|
# EGO_STORE_DIR=${DISTDIR}/go-src
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: EVCS_OFFLINE
|
# @ECLASS_VARIABLE: EVCS_OFFLINE
|
||||||
# @DEFAULT_UNSET
|
# @DEFAULT_UNSET
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# If non-empty, this variable prevents any online operations.
|
# If non-empty, this variable prevents any online operations.
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: EVCS_UMASK
|
# @ECLASS_VARIABLE: EVCS_UMASK
|
||||||
# @DEFAULT_UNSET
|
# @DEFAULT_UNSET
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Set this variable to a custom umask. This is intended to be set by
|
# Set this variable to a custom umask. This is intended to be set by
|
||||||
@ -69,11 +63,12 @@ PROPERTIES+=" live"
|
|||||||
# @INTERNAL
|
# @INTERNAL
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Create EGO_STORE_DIR if necessary.
|
# Create EGO_STORE_DIR if necessary.
|
||||||
|
# Set compile env via go-env.
|
||||||
_golang-vcs_env_setup() {
|
_golang-vcs_env_setup() {
|
||||||
debug-print-function ${FUNCNAME} "$@"
|
debug-print-function ${FUNCNAME} "$@"
|
||||||
|
|
||||||
local distdir=${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}
|
local distdir=${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}
|
||||||
: ${EGO_STORE_DIR:=${distdir}/go-src}
|
: "${EGO_STORE_DIR:=${distdir}/go-src}"
|
||||||
|
|
||||||
[[ -n ${EVCS_UMASK} ]] && eumask_push $EVCS_UMASK
|
[[ -n ${EVCS_UMASK} ]] && eumask_push $EVCS_UMASK
|
||||||
|
|
||||||
@ -90,6 +85,8 @@ _golang-vcs_env_setup() {
|
|||||||
mkdir -p "${WORKDIR}/${P}/src" ||
|
mkdir -p "${WORKDIR}/${P}/src" ||
|
||||||
die "${ECLASS}: unable to create ${WORKDIR}/${P}"
|
die "${ECLASS}: unable to create ${WORKDIR}/${P}"
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
go-env_set_compile_environment
|
||||||
}
|
}
|
||||||
|
|
||||||
# @FUNCTION: _golang-vcs_fetch
|
# @FUNCTION: _golang-vcs_fetch
|
||||||
@ -139,3 +136,5 @@ golang-vcs_src_unpack() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
EXPORT_FUNCTIONS src_unpack
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user