From 5f08c1ba3802ebdbb6958184273105a6096db49b Mon Sep 17 00:00:00 2001 From: "Chen, Chih-Chia" Date: Wed, 16 Mar 2022 19:07:42 +0800 Subject: apply new go-module guideline Signed-off-by: Chen, Chih-Chia --- eclass/golang-common.eclass | 1026 ----------------------- eclass/golang-live.eclass | 157 ---- eclass/golang-single.eclass | 185 ---- net-analyzer/amass/amass-9999.ebuild | 17 +- net-misc/BaiduPCS-Go/BaiduPCS-Go-9999.ebuild | 4 +- net-misc/curlie/curlie-9999.ebuild | 3 +- net-misc/hargo/Manifest | 8 - net-misc/hargo/hargo-0.1.2-r1.ebuild | 1 + net-misc/hargo/hargo-0.1.2.ebuild | 48 -- net-misc/hargo/hargo-9999.ebuild | 58 ++ net-vpn/cloudflared/Manifest | 2 +- net-vpn/cloudflared/cloudflared-2022.1.0.ebuild | 1 - net-vpn/cloudflared/cloudflared-2022.3.1.ebuild | 1 + net-vpn/cloudflared/cloudflared-9999.ebuild | 26 +- 14 files changed, 87 insertions(+), 1450 deletions(-) delete mode 100644 eclass/golang-common.eclass delete mode 100644 eclass/golang-live.eclass delete mode 100644 eclass/golang-single.eclass delete mode 100644 net-misc/hargo/Manifest create mode 120000 net-misc/hargo/hargo-0.1.2-r1.ebuild delete mode 100644 net-misc/hargo/hargo-0.1.2.ebuild create mode 100644 net-misc/hargo/hargo-9999.ebuild delete mode 120000 net-vpn/cloudflared/cloudflared-2022.1.0.ebuild create mode 120000 net-vpn/cloudflared/cloudflared-2022.3.1.ebuild diff --git a/eclass/golang-common.eclass b/eclass/golang-common.eclass deleted file mode 100644 index 8f66a08..0000000 --- a/eclass/golang-common.eclass +++ /dev/null @@ -1,1026 +0,0 @@ -# Copyright 1999-2017 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Id$ - -# @ECLASS: golang-utils.eclass -# @MAINTAINER: -# Mauro Toffanin -# @AUTHOR: -# Mauro Toffanin -# @BLURB: Base eclass for GoLang packages -# @DESCRIPTION: -# This eclass provides functionalities which are used by golang-single.eclass, -# golang-live.eclass, and as well as from ebuilds. -# -# This eclass should not be inherited directly from an ebuild. -# Instead, you should inherit golang-single or golang-live for GoLang packages. - -inherit versionator eutils multiprocessing - -if [[ -z ${_GOLANG_BASE_ECLASS} ]]; then -_GOLANG_BASE_ECLASS=1 - -# Silences repoman warnings. -case "${EAPI:-0}" in - 5|6) - case "${GOLANG_PKG_DEPEND_ON_GO_SUBSLOT:-yes}" in - yes) - GO_DEPEND="dev-lang/go:0=" - ;; - *) - GO_DEPEND="dev-lang/go:*" - ;; - esac - ;; - *) - die "${ECLASS}: Unsupported eapi (EAPI=${EAPI})" - ;; -esac -DEPEND+=" ${GO_DEPEND}" - -RESTRICT+=" mirror strip" - -QA_FLAGS_IGNORED="usr/bin/.* - usr/sbin/.*" - -# @ECLASS-VARIABLE: GOLANG_PKG_NAME -# @DESCRIPTION: -# Sets the GoLang name for the generated package. -# GOLANG_PKG_NAME="${PN}" -GOLANG_PKG_NAME="${GOLANG_PKG_NAME:-${PN}}" - -# @ECLASS-VARIABLE: GOLANG_PKG_VERSION -# @DESCRIPTION: -# Sets the GoLang version for the generated package. -# GOLANG_PKG_VERSION="${PV}" -GOLANG_PKG_VERSION="${GOLANG_PKG_VERSION:-${PV/_pre/.pre}}" - -# @ECLASS-VARIABLE: GOLANG_PKG_IMPORTPATH -# @DESCRIPTION: -# Sets the remote import path for the generated package. -# GOLANG_PKG_IMPORTPATH="github.com/captObvious/" -GOLANG_PKG_IMPORTPATH="${GOLANG_PKG_IMPORTPATH:-}" - -# @ECLASS-VARIABLE: GOLANG_PKG_IMPORTPATH_ALIAS -# @DESCRIPTION: -# Sets an alias of the remote import path for the generated package. -# GOLANG_PKG_IMPORTPATH_ALIAS="privaterepo.com/captObvious/" -GOLANG_PKG_IMPORTPATH_ALIAS="${GOLANG_PKG_IMPORTPATH_ALIAS:=${GOLANG_PKG_IMPORTPATH}}" - -# @ECLASS-VARIABLE: GOLANG_PKG_ARCHIVEPREFIX -# @DESCRIPTION: -# Sets the archive prefix for the file URI of the package. -# Most projects hosted on GitHub's mirrors provide archives with prefix as -# 'v' or 'source-', other hosted services offer different archive formats. -# This eclass defaults to an empty prefix. -GOLANG_PKG_ARCHIVEPREFIX="${GOLANG_PKG_ARCHIVEPREFIX:-}" - -# @ECLASS-VARIABLE: GOLANG_PKG_ARCHIVESUFFIX -# @DESCRIPTION: -# Sets the archive suffix for the file URI of the package. -# Most projects hosted on GitHub's mirrors provide archives with suffix as -# '.tar.gz' or '.zip', other hosted services offer different archive formats. -# This eclass defaults to '.tar.gz'. -GOLANG_PKG_ARCHIVESUFFIX="${GOLANG_PKG_ARCHIVESUFFIX:=".tar.gz"}" - -# @ECLASS-VARIABLE: GOLANG_PKG_OUTPUT_NAME -# @DESCRIPTION: -# Specifies the output file name of the package. -# If not set, it derives from the name of the package, such as $GOLANG_PKG_NAME. -# This eclass defaults to $PN. -GOLANG_PKG_OUTPUT_NAME="${GOLANG_PKG_OUTPUT_NAME:=${PN}}" - -# @ECLASS-VARIABLE: GOLANG_PKG_BUILDPATH -# @DESCRIPTION: -# Specifies a go source file to be compiled as a single main package. -# This eclass defaults to an empty value. -# This eclass defaults to "/..." when the user declares GOLANG_PKG_IS_MULTIPLE=1 -GOLANG_PKG_BUILDPATH="${GOLANG_PKG_BUILDPATH:-}" - -# @ECLASS-VARIABLE: GOLANG_PKG_INSTALLPATH -# @DESCRIPTION: -# Sets the root path into which a binary, or a list of binaries, will be -# installed (e.x.: ${GOLANG_PKG_INSTALLPATH}/bin). -# This eclass defaults to "/usr" -GOLANG_PKG_INSTALLPATH="${GOLANG_PKG_INSTALLPATH:="/usr"}" - -# @ECLASS-VARIABLE: GOLANG_PKG_INSTALLSUFFIX -# @DESCRIPTION: -# Sets a suffix to use in the name of the package installation directory. -# This eclass defaults to an empty install suffix. -GOLANG_PKG_INSTALLSUFFIX="${GOLANG_PKG_INSTALLSUFFIX:-}" - -# @ECLASS-VARIABLE: GOLANG_PKG_IS_MULTIPLE -# @DESCRIPTION: -# Set to enable the building of multiple packages from a single import path. - -# @ECLASS-VARIABLE: GOLANG_PKG_HAVE_TEST -# @DEFAULT_UNSET -# @DESCRIPTION: -# Set to enable the execution of automated testing. - -# @ECLASS-VARIABLE: GOLANG_PKG_HAVE_TEST_RACE -# @DEFAULT_UNSET -# @DESCRIPTION: -# Set to enable the execution of automated testing with support for -# data race detection. - -# @ECLASS-VARIABLE: GOLANG_PKG_USE_CGO -# @DEFAULT_UNSET -# @DESCRIPTION: -# Set to enable the compilation of the package with CGO. - -# @ECLASS-VARIABLE: GOLANG_PKG_USE_GENERATE -# @DEFAULT_UNSET -# @DESCRIPTION: -# Set to run commands described by directives within existing golang files. - -# @ECLASS-VARIABLE: GOLANG_PKG_DEPEND_ON_GO_SUBSLOT -# @DESCRIPTION: -# Set to ensure the package does depend on the dev-lang/go subslot value. -# Possible values: {yes,no} -# This eclass defaults to "no" -GOLANG_PKG_DEPEND_ON_GO_SUBSLOT=${GOLANG_PKG_DEPEND_ON_GO_SUBSLOT:="no"} - -# @ECLASS-VARIABLE: GOLANG_PKG_LDFLAGS -# @DESCRIPTION: -# Sets the linker arguments to pass to 5l, 6l, or 8l. -# This eclass defaults to an empty list. -GOLANG_PKG_LDFLAGS="${GOLANG_PKG_LDFLAGS:-}" - -# @ECLASS-VARIABLE: GOLANG_PKG_TAGS -# @DESCRIPTION: -# Sets the list of build tags during the build. -# This eclass defaults to an empty list. -GOLANG_PKG_TAGS="${GOLANG_PKG_TAGS:-}" - -# @ECLASS-VARIABLE: GOLANG_PKG_VENDOR -# @DESCRIPTION: -# Sets additional standard Go workspaces to be appended to the environment -# variable GOPATH, as described in http://golang.org/doc/code.html. -# This eclass defaults to an empty list. -GOLANG_PKG_VENDOR=() - -# @ECLASS-VARIABLE: GOLANG_PKG_STATIK -# @DESCRIPTION: -# Sets the arguments to pass to dev-go/statik. -# This eclass defaults to an empty list. -GOLANG_PKG_STATIK="${GOLANG_PKG_STATIK:-}" - - -# @ECLASS-VARIABLE: GO -# @DEFAULT_UNSET -# @DESCRIPTION: -# The absolute path to the current GoLang interpreter. -# -# This variable is set automatically after calling golang_setup(). -# -# Default value: -# @CODE -# /usr/bin/go -# @CODE - -# @ECLASS-VARIABLE: EGO -# @DEFAULT_UNSET -# @DESCRIPTION: -# The executable name of the current GoLang interpreter. -# -# This variable is set automatically after calling golang_setup(). -# -# Default value: -# @CODE -# go -# @CODE - -# @ECLASS-VARIABLE: PATCHES -# @DEFAULT_UNSET -# @DESCRIPTION: -# Array variable containing all the patches to be applied. This variable -# is expected to be defined in the global scope of ebuilds. Make sure to -# specify the full path. This variable is used in src_prepare phase. -# -# Example: -# @CODE -# PATCHES=( -# "${FILESDIR}/mypatch.patch" -# "${FILESDIR}/mypatch2.patch" -# ) -# @CODE - - - -# Adds gccgo as a compile-time dependency when GOLANG_PKG_USE_CGO is set. -[[ -n ${GOLANG_PKG_USE_CGO} ]] && DEPEND+=" >=sys-devel/gcc-4.8.4[go]" - -# Adds dev-go/statik as a compile-time dependency when GOLANG_PKG_STATIK is set. -[[ -n ${GOLANG_PKG_STATIK} ]] && DEPEND+=" dev-go/statik" - -# Validates GOLANG_PKG_IMPORTPATH. -if [[ -z ${GOLANG_PKG_IMPORTPATH} ]]; then - eerror "The remote import path for this package has not been declared" - die "Mandatory variable GOLANG_PKG_IMPORTPATH is unset" -fi - -# Forces a multiple package build when user specifies GOLANG_PKG_IS_MULTIPLE=1. -if [[ -n ${GOLANG_PKG_IS_MULTIPLE} && -z ${GOLANG_PKG_BUILDPATH} ]]; then - GOLANG_PKG_BUILDPATH="/..." -fi - -# Validates use of GOLANG_PKG_BUILDPATH combined with GOLANG_PKG_IS_MULTIPLE -# FIX: makes sure user isn't overriding GOLANG_PKG_BUILDPATH with inane values. -if [[ -n ${GOLANG_PKG_IS_MULTIPLE} && ${GOLANG_PKG_BUILDPATH##*/} != "..." ]]; then - ewarn "Ebuild ${CATEGORY}/${PF} specifies GOLANG_PKG_IS_MULTIPLE=1," - ewarn "but then GOLANG_PKG_BUILDPATH is overridden with \"${GOLANG_PKG_BUILDPATH}\"." - ewarn "Please, fix it by appending \"/...\" to your GOLANG_PKG_BUILDPATH." - ewarn "If in doubt, remove GOLANG_PKG_BUILDPATH entirely." -fi - -# Even though xz-utils are in @system, they must still be added to DEPEND; see -# http://archives.gentoo.org/gentoo-dev/msg_a0d4833eb314d1be5d5802a3b710e0a4.xml -if [[ ${GOLANG_PKG_ARCHIVESUFFIX/.*} == "xz" ]]; then - DEPEND+=" app-arch/xz-utils" -fi - -# Defines common USE flags -IUSE="${IUSE} debug pie" -# Enables USE 'test' when required by GOLANG_PKG_HAVE_TEST. -if [[ -n ${GOLANG_PKG_HAVE_TEST} ]]; then - IUSE+=" test" -fi - -# Defines HOMEPAGE. -[ -z "$HOMEPAGE" ] && HOMEPAGE="https://${GOLANG_PKG_IMPORTPATH}/${PN}" - -# Defines SOURCE directory. -S="${WORKDIR}/gopath/src/${GOLANG_PKG_IMPORTPATH_ALIAS}/${GOLANG_PKG_NAME}" - - -# @FUNCTION: _factorize_dependency_entities -# @INTERNAL -# @DESCRIPTION: -# Factorizes the dependency declaration in specific tokens such as the import -# path, the import path alias, the host name, the author name, the project name, -# and the revision tag. -_factorize_dependency_entities() { - debug-print-function ${FUNCNAME} "${@}" - - local -A dependency=() - local key_list=(importpathalias importpath host project_name author_name revision) - - # Strips all the white spaces from the supplied argument. - local raw_dependency="${1//\ /}" - - # Determines the alias of the import path (if present). - dependency[importpathalias]="${raw_dependency##*->}" - - # Strips the import path alias from the supplied argument. - raw_dependency="${raw_dependency%%->*}" - - # Determines the import path. - dependency[importpath]="${raw_dependency%:*}" - - # When the importpath alias is not specified, then this eclass sets the - # alias as equal to the import path minus the project name. - if [[ "${raw_dependency}" == "${dependency[importpathalias]}" ]]; then - dependency[importpathalias]="${dependency[importpath]%/*}" - fi - - # Determines the host. - dependency[host]="${dependency[importpath]%%/*}" - - # Determines the project name. - dependency[project_name]="${dependency[importpath]##*/}" - - # Determines the author name. - dependency[author_name]="${dependency[importpath]#*/}" - dependency[author_name]="${dependency[author_name]%/*}" - - # Determines the revision. - dependency[revision]="${raw_dependency#*:}" - - # Exports all the dependency tokens as an associated list. - for key in ${key_list[@]}; do - echo "${key} ${dependency[${key}]}" - done -} - - -# @FUNCTION: golang_setup -# @DESCRIPTION: -# Determines where is the GoLang implementation and then set-up the -# GoLang build environment. -golang_setup() { - debug-print-function ${FUNCNAME} "${@}" - - # NOTE: Keep /usr/bin/go as index [0] and never overwrite it, - # always append other binary paths after the index [0] - local GOLANG_BINS=( - /usr/bin/go - /usr/bin/gofmt - ) - - [[ -n ${GOLANG_PKG_STATIK} ]] && GOLANG_BINS+=(/usr/bin/statik) - - # Reset GoLang environment variables - unset EGO - unset EGOFMT - unset ESTATIK - unset GO - unset GOPATH - unset GOBIN - - # Determine is the GoLang interpreter is working - local IS_EXECUTABLE=1 - for binary in "${GOLANG_BINS[@]}"; do - debug-print "${FUNCNAME}: Checking ... ${binary}" - - [[ -x "${EPREFIX}/${binary}" ]] && continue - IS_EXECUTABLE=0 - ewarn "It seems that the binary '${binary}' is not executable." - done - - # dev-lang/go isn't installed or one of its binaries aren't executable. - # Either way, the Gentoo box is screwed; no need to set up the GoLang environment - [[ ${IS_EXECUTABLE} == 0 ]] && exit - - # dev-lang/go is available and working. - # Exports GO/EGO/EGOFMT global variables. - export GO="${GOLANG_BINS[0]}" - export EGO="${GOLANG_BINS[0]##*/}" - export EGOFMT="${GOLANG_BINS[1]}" - - # dev-go/statik is available and working. - # Exports ESTATIK global variable. - [[ -n ${GOLANG_PKG_STATIK} ]] && export ESTATIK="${GOLANG_BINS[2]##*/}" - - debug-print "${FUNCNAME}: GO = ${GO}" - debug-print "${FUNCNAME}: EGO = ${EGO}" - debug-print "${FUNCNAME}: EGOFMT = ${EGOFMT}" - debug-print "${FUNCNAME}: ESTATIK = ${ESTATIK}" - - # Determines go interpreter version. - GOLANG_VERSION="$( ${GO} version )" - GOLANG_VERSION="${GOLANG_VERSION/go\ version\ go}" - export GOLANG_VERSION="${GOLANG_VERSION%\ *}" - einfo "Found GoLang version: ${GOLANG_VERSION}" - - # Determines statik interpreter version. - # TODO: add version detection when statik will provide a -version option. - if [[ -n ${GOLANG_PKG_STATIK} ]]; then - local STATIK_VERSION="" - einfo "Found statik version: ${STATIK_VERSION}" - fi - - # Enable/Disable frame pointers - local GOEXPERIMENT="noframepointer" - use debug && GOEXPERIMENT="framepointer" - - # Sets the build environment inside Portage's WORKDIR. - ebegin "Setting up GoLang build environment" - - # Prepares CGO_ENABLED. - CGO_ENABLED=0 - [[ -z ${GOLANG_PKG_USE_CGO} ]] || CGO_ENABLED=1 - use pie && CGO_ENABLED=1 # PIE requires CGO - - # Prepares gopath / gobin directories inside WORKDIR. - local _GOPATH="${WORKDIR}/gopath" - local _GOBIN="${WORKDIR}/gobin" - mkdir -p "${_GOBIN}" || die - mkdir -p "${_GOPATH}"/src || die - - # Exports special env variable EGO_SRC. - export EGO_SRC="${_GOPATH}/src" - - # Exports GoLang env variables. - export GOPATH="$_GOPATH" - export GOBIN="$_GOBIN" - export CGO_ENABLED - export GOEXPERIMENT - export GO15VENDOREXPERIMENT=0 - - debug-print "${FUNCNAME}: GOPATH = ${GOPATH}" - debug-print "${FUNCNAME}: GOBIN = ${GOBIN}" - debug-print "${FUNCNAME}: EGO_SRC = ${EGO_SRC}" - debug-print "${FUNCNAME}: CGO_ENABLED = ${CGO_ENABLED}" - eend -} - - -# @FUNCTION: golang-common_src_prepare -# @DESCRIPTION: -# Prepare source code. -golang-common_src_prepare() { - debug-print-function ${FUNCNAME} "${@}" - - pushd "${WORKDIR}" > /dev/null || die - einfo "Preparing GoLang build environment in ${GOPATH}/src" - - # If the ebuild declares an importpath alias, then its path was - # already created during the src_unpack phase. That means the eclass - # needs to create the missing original import path (GOLANG_PKG_IMPORTPATH) - # as a simbolic link pointing to the alias. - if [[ "${GOLANG_PKG_IMPORTPATH}" != "${GOLANG_PKG_IMPORTPATH_ALIAS}" ]]; then - - # If the ebuild declares a GOLANG_PKG_NAME different from PN, then - # the latter will be used as the simbolic link target. - local TARGET="${GOLANG_PKG_NAME}" - [[ "${PN}" != "${GOLANG_PKG_NAME}" ]] && TARGET="${PN}" - - golang_fix_importpath_alias \ - "${GOLANG_PKG_IMPORTPATH_ALIAS}/${TARGET}" \ - "${GOLANG_PKG_IMPORTPATH}/${GOLANG_PKG_NAME}" - fi - - # If the ebuild declares some GoLang dependencies, then they need to be - # correctly installed into the sand-boxed GoLang build environment which - # was set up automatically during src_unpack) phase. - if [[ ${#GOLANG_PKG_DEPENDENCIES[@]} -gt 0 ]]; then - - for i in ${!GOLANG_PKG_DEPENDENCIES[@]} ; do - - # Collects all the tokens of the dependency. - local -A DEPENDENCY=() - while read -r -d $'\n' key value; do - [[ -z ${key} ]] && continue - DEPENDENCY[$key]="${value}" - done <<-EOF - $( _factorize_dependency_entities "${GOLANG_PKG_DEPENDENCIES[$i]}" ) - EOF - - # Debug - debug-print "${FUNCNAME}: DEPENDENCY = ${GOLANG_PKG_DEPENDENCIES[$i]}" - debug-print "${FUNCNAME}: importpath = ${DEPENDENCY[importpath]}" - debug-print "${FUNCNAME}: importpathalias = ${DEPENDENCY[importpathalias]}" - debug-print "${FUNCNAME}: host = ${DEPENDENCY[host]}" - debug-print "${FUNCNAME}: author = ${DEPENDENCY[author_name]}" - debug-print "${FUNCNAME}: project = ${DEPENDENCY[project_name]}" - debug-print "${FUNCNAME}: revision = ${DEPENDENCY[revision]}" - - local message="Importing ${DEPENDENCY[importpath]}" - local destdir - - # Prepares GOPATH structure. - case ${DEPENDENCY[importpathalias]} in - gopkg.in*) - message+=" as ${DEPENDENCY[importpathalias]}" - destdir="${DEPENDENCY[importpathalias]}" - - # Creates the import path in GOPATH. - mkdir -p "${GOPATH}/src/${DEPENDENCY[importpathalias]%/*}" || die - #einfo "\n${GOPATH}/src/${DEPENDENCY[importpathalias]%/*}" - ;; - *) - [[ "${DEPENDENCY[importpath]}" != "${DEPENDENCY[importpathalias]}/${DEPENDENCY[project_name]}" ]] && message+=" as ${DEPENDENCY[importpathalias]}/${DEPENDENCY[project_name]}" - destdir="${DEPENDENCY[importpathalias]}/${DEPENDENCY[project_name]}" - - # Creates the import path in GOPATH. - mkdir -p "${GOPATH}/src/${DEPENDENCY[importpathalias]}" || die - #einfo "\n${GOPATH}/src/${DEPENDENCY[importpathalias]}" - ;; - esac - - # Moves sources from WORKDIR into GOPATH. - case ${DEPENDENCY[host]} in - github*) - ebegin "${message}" - mv ${DEPENDENCY[project_name]}-${DEPENDENCY[revision]}* "${GOPATH}"/src/${destdir} || die - eend - - # FIX: sometimes the source code inside an importpath alias - # (such as gopkg.in/mylib.v1) invokes imports from - # the original import path instead of using the alias, - # thus we need a symbolic link between the alias and - # the original import path to avoid compilation issues. - # Example: gopkg.in/Shopify/sarama.v1 erroneously - # invokes imports from github.com/shopify/sarama - if [[ ${destdir} != ${DEPENDENCY[importpath]} ]]; then - golang_fix_importpath_alias ${destdir} ${DEPENDENCY[importpath]} - fi - ;; - bitbucket*) - #einfo "path: ${DEPENDENCY[author_name]}-${DEPENDENCY[project_name]}-${DEPENDENCY[revision]}" - ebegin "${message}" - mv ${DEPENDENCY[author_name]}-${DEPENDENCY[project_name]}-${DEPENDENCY[revision]}* "${GOPATH}"/src/${destdir} || die - eend - ;; - code.google*) - ebegin "${message}" - mv ${DEPENDENCY[project_name]}-${DEPENDENCY[revision]}* "${GOPATH}"/src/${destdir} || die - eend - ;; - *) die "Function 'golang-common_src_prepare' doesn't support '${DEPENDENCY[importpath]}'" ;; - esac - done - - fi - - popd > /dev/null || die - - - # Auto-detects the presence of Go's vendored - # dependencies inside $S/vendor. - local VENDOR="${S}/vendor" - if [[ -d "${VENDOR}" ]]; then - golang_add_vendor "${VENDOR}" - export GO15VENDOREXPERIMENT=1 - fi - - # Auto-detects the presence of Go's vendored - # dependencies inside $S/*/vendor - if [[ -n ${GOLANG_PKG_BUILDPATH} && ${GOLANG_PKG_BUILDPATH##*/} != "..." ]]; then - while read -r -d $' ' path; do - # Trims leading slash (if any). - path="${path/\//}" - - # Extracts the root path. - path="${path%%/*}" - - # Ignores $path when it's empty or a string of white spaces. - [[ -n $path ]] || continue - - local vendor="${S}/${path}/vendor" - if [[ -d "${vendor}" ]]; then - golang_add_vendor "${vendor}" - fi - done <<< "$( echo ${GOLANG_PKG_BUILDPATH}) " - fi - - - # Auto-detects the presence of Godep's workspace - # (see github.com/tools/godep for more infos). - VENDOR="${S}/Godeps/_workspace" - if [[ -d "${VENDOR}" ]]; then - golang_add_vendor "${VENDOR}" - fi - - - # Evaluates PATCHES array. - default_src_prepare -} - - -# @FUNCTION: golang-common_src_configure -# @DESCRIPTION: -# Configure the package. -golang-common_src_configure() { - debug-print-function ${FUNCNAME} "${@}" - - [[ ${EGO} ]] || die "No GoLang implementation set (golang_setup not called?)." - - # Defines the level of verbosity. - local EGO_VERBOSE="-v" - [[ -z ${PORTAGE_VERBOSE} ]] || EGO_VERBOSE+=" -x" - - # GoLang doesn't have a configure phase, - # so instead this eclass prints the output of 'go env'. - local -a GOLANG_ENV=() - while read -r line; do - GOLANG_ENV+=("${line}") - done <<-EOF - $( ${GO} env ) - EOF - - # Prints an error when 'go env' output is missing. - if [[ ${#GOLANG_ENV[@]} -eq 1 ]]; then - eerror "Your GoLang environment should be more verbose" - fi - - # Prints GoLang environment summary. - einfo " ${EGO} env" - for env in "${GOLANG_ENV[@]}"; do - einfo " - ${env}" - done - - - # Removes GoLang object files from package source directories (pkg/) - # and temporary directories (_obj/ _test*/). - local EGO_SUBPACKAGES="${GOLANG_PKG_IMPORTPATH_ALIAS}/${GOLANG_PKG_NAME}" - case $( get_version_component_range 1-2 ${GOLANG_VERSION} ) in - 1.4*) ;; - *) - EGO_SUBPACKAGES+="/..." - ;; - esac -# einfo "${EGO} clean -i ${EGO_VERBOSE} ${EGO_SUBPACKAGES}" -# ${EGO} clean -i \ -# ${EGO_VERBOSE} \ -# "${EGO_SUBPACKAGES}" \ -# || die - - # Removes GoLang objects files from all the dependencies too. -# if [[ ${#GOLANG_PKG_DEPENDENCIES[@]} -gt 0 ]]; then -# -# for i in ${!GOLANG_PKG_DEPENDENCIES[@]} ; do -# -# # Collects all the tokens of the dependency. -# local -A DEPENDENCY=() -# while read -r -d $'\n' key value; do -# [[ -z ${key} ]] && continue -# DEPENDENCY[$key]="${value}" -# done <<-EOF -# $( _factorize_dependency_entities "${GOLANG_PKG_DEPENDENCIES[$i]}" ) -# EOF -# -# [[ ! -d ${DEPENDENCY[importpath]} ]] && continue -# -# # Debug -# debug-print "${FUNCNAME}: DEPENDENCY = ${GOLANG_PKG_DEPENDENCIES[$i]}" -# debug-print "${FUNCNAME}: importpath = ${DEPENDENCY[importpath]}" -# -# # Cleans object files of the dependency. -# einfo "${EGO} clean -i ${EGO_VERBOSE} ${DEPENDENCY[importpath]}" -# ${EGO} clean \ -# -i ${EGO_VERBOSE} \ -# "${DEPENDENCY[importpath]}" \ -# || die -# done -# fi - - # Before to compile Godep's dependencies it's wise to wipe out - # all pre-built object files from Godep's package source directories. - if [[ -d "${S}"/Godeps/_workspace/pkg ]]; then - ebegin "Cleaning up pre-built object files in Godep workspace" - rm -r "${S}"/Godeps/_workspace/pkg || die - eend - fi - if [[ -d "${S}"/Godeps/_workspace/bin ]]; then - ebegin "Cleaning up executables in Godep workspace" - rm -r "${S}"/Godeps/_workspace/bin || die - eend - fi - - - # Executes 'go generate'. - # NOTE: generate should never run automatically. It must be run explicitly. - if [[ -n ${GOLANG_PKG_USE_GENERATE} ]]; then - pushd "${GOPATH}/src/${GOLANG_PKG_IMPORTPATH_ALIAS}/${GOLANG_PKG_NAME}" > /dev/null || die - einfo "${EGO} generate ${EGO_VERBOSE} ${GOLANG_PKG_IMPORTPATH_ALIAS}/${GOLANG_PKG_NAME}/..." - ${EGO} generate \ - ${EGO_VERBOSE} \ - ./... \ - || die - popd > /dev/null || die - fi - - - # Executes 'statik' when explicitly asked. - if [[ -n ${GOLANG_PKG_STATIK} ]]; then - ebegin "${ESTATIK} $GOLANG_PKG_STATIK" - ${ESTATIK} $GOLANG_PKG_STATIK || die - eend - fi -} - - -# @FUNCTION: golang-common_src_compile -# @DESCRIPTION: -# Compiles the package. -golang-common_src_compile() { - debug-print-function ${FUNCNAME} "${@}" - - [[ ${EGO} ]] || die "No GoLang implementation set (golang_setup not called?)." - - # Populates env variable GOPATH with vendored workspaces (if present). - if [[ -n ${GOLANG_PKG_VENDOR} ]]; then - einfo "Using vendored dependencies from:" - - for path in "${GOLANG_PKG_VENDOR[@]}"; do - [ -d ${path} ] || continue - - if [[ ${path//${S}\//} == "vendor" ]]; then - einfo "- vendor/ (native vendoring support)" - continue - fi - - debug-print "$FUNCNAME: GOPATH: Adding vendor path ${path}" - ebegin "- ${path//${S}\//}" - GOPATH="${GOPATH}:$( echo ${path} )" - eend - done - - export GOPATH - fi - - # Enables position-independent executables (PIE) - local EGO_PIE - use pie && EGO_PIE="-buildmode=pie" - - # Defines the install suffix. - local EGO_INSTALLSUFFIX - [[ -z ${GOLANG_PKG_INSTALLSUFFIX} ]] || EGO_INSTALLSUFFIX="-installsuffix=${GOLANG_PKG_INSTALLSUFFIX}" - - # Defines the level of verbosity. - local EGO_VERBOSE="-v" - [[ -z ${PORTAGE_VERBOSE} ]] || EGO_VERBOSE+=" -x" - - # Defines the number of builds that can be run in parallel. - local EGO_PARALLEL="-p $(makeopts_jobs)" - - # Defines extra options. - local EGO_EXTRA_OPTIONS="-a" - - # Prepares build flags for the go toolchain. - local EGO_BUILD_FLAGS="$( echo ${EGO_VERBOSE} ) $( echo ${EGO_PARALLEL} ) $( echo ${EGO_EXTRA_OPTIONS} ) $( echo ${EGO_PIE} )" - [[ -n ${EGO_INSTALLSUFFIX} ]] && EGO_BUILD_FLAGS+=" $( echo ${EGO_INSTALLSUFFIX} )" - - # Detects the total number of packages. - local pkgs=0 ifs_save=${IFS} IFS=$' ' - for path in ${GOLANG_PKG_BUILDPATH[@]} ; do - pkgs=$(( $pkgs + 1 )) - done - [[ ${pkgs} -eq 0 ]] && pkgs=1 # there is always at least 1 package - IFS=${ifs_save} - - # Builds the package - einfo "Compiling ${pkgs} package(s):" - if [[ -n ${GOLANG_PKG_BUILDPATH} && ${GOLANG_PKG_BUILDPATH##*/} != "..." && ${pkgs} -gt 1 ]]; then - - # NOTE: This eclass trims all leading and trailing white spaces from the - # input of the following 'while read' loop, then appends an extra - # trailing space; this is necessary to avoid undefined behaviours - # within the loop when GOLANG_PKG_BUILDPATH is populated with only - # a single element. - while read -r -d $' ' cmd; do - # Ignores $cmd when it's empty or a string of white spaces - #einfo "cmd: |$cmd| cmd: |${cmd##*/}|" - [[ -n $cmd ]] || continue - - golang_do_build \ - ${EGO_BUILD_FLAGS} \ - -o "${GOBIN}/${cmd##*/}" \ - "${GOLANG_PKG_IMPORTPATH_ALIAS}/${GOLANG_PKG_NAME}${cmd}" - done <<< "$( echo ${GOLANG_PKG_BUILDPATH}) " - else - # If the package is a multiple package (/...) - # then this eclass doesn't specify the output name. - [[ ${GOLANG_PKG_BUILDPATH##*/} != "..." ]] && EGO_BUILD_FLAGS+=" -o ${GOBIN}/${GOLANG_PKG_OUTPUT_NAME}" - - golang_do_build \ - ${EGO_BUILD_FLAGS} \ - "${GOLANG_PKG_IMPORTPATH_ALIAS}/${GOLANG_PKG_NAME}${GOLANG_PKG_BUILDPATH}" - fi -} - - -# @FUNCTION: golang-common_src_install -# @DESCRIPTION: -# Installs binaries and documents from DOCS or HTML_DOCS arrays. -golang-common_src_install() { - debug-print-function ${FUNCNAME} "${@}" - - [[ ${EGO} ]] || die "No GoLang implementation set (golang_setup not called?)." - - # Enables position-independent executables (PIE) - local EGO_PIE - use pie && EGO_PIE="-buildmode=pie" - - # Defines the install suffix. - local EGO_INSTALLSUFFIX - [[ -z ${GOLANG_PKG_INSTALLSUFFIX} ]] || EGO_INSTALLSUFFIX="-installsuffix=${GOLANG_PKG_INSTALLSUFFIX}" - - # Defines the level of verbosity. - local EGO_VERBOSE="-v" - [[ -z ${PORTAGE_VERBOSE} ]] || EGO_VERBOSE+=" -x" - - # Defines the number of builds that can be run in parallel. - local EGO_PARALLEL="-p $(makeopts_jobs)" - - # Defines extra options. - local EGO_EXTRA_OPTIONS - - # Prepares build flags for the go toolchain. - local EGO_BUILD_FLAGS="$( echo ${EGO_VERBOSE} ) $( echo ${EGO_PARALLEL} ) $( echo ${EGO_EXTRA_OPTIONS} ) $( echo ${EGO_PIE} )" - [[ -n ${EGO_INSTALLSUFFIX} ]] && EGO_BUILD_FLAGS+=" $( echo ${EGO_INSTALLSUFFIX} )" - - # Defines sub-packages. - local EGO_SUBPACKAGES="${GOLANG_PKG_IMPORTPATH_ALIAS}/${GOLANG_PKG_NAME}${GOLANG_PKG_BUILDPATH}" - - # Executes the pre-install phase (go install). - if [[ -n ${GOLANG_PKG_IS_MULTIPLE} ]]; then - einfo "${EGO} install -ldflags '$GOLANG_PKG_LDFLAGS' -tags '$GOLANG_PKG_TAGS' ${EGO_BUILD_FLAGS} ${EGO_SUBPACKAGES}" - ${EGO} install \ - -ldflags "${GOLANG_PKG_LDFLAGS}" \ - -tags "${GOLANG_PKG_TAGS}" \ - ${EGO_BUILD_FLAGS} \ - "${EGO_SUBPACKAGES}" \ - || die - fi - - # Installs binaries. - into ${GOLANG_PKG_INSTALLPATH} - for bin in "${GOBIN}"/* ; do - dobin ${bin} - done - - # Installs documentation. - einstalldocs -} - -# @FUNCTION: golang-common_src_test -# @DESCRIPTION: -# Runs the unit tests for the main package. -golang-common_src_test() { - debug-print-function ${FUNCNAME} "${@}" - - [[ ${EGO} ]] || die "No GoLang implementation set (golang_setup not called?)." - - # Appends S and GOBIN to exported main paths. - # FIX: this is necessary for unit tests that need to invoke bins from - # $GOBIN or from within $S/bin. - export PATH="${S}/bin:${GOBIN}:${PATH}" - - # Defines the level of verbosity. - local EGO_VERBOSE="-v" - [[ -z ${PORTAGE_VERBOSE} ]] || EGO_VERBOSE+=" -x" - - # Defines the number of builds that can be run in parallel. - local EGO_PARALLEL="-p $(makeopts_jobs)" - - # Defines extra options. - #local EGO_EXTRA_OPTIONS="-a" - - # Enables data race detection. - local EGO_RACE - [[ -n ${GOLANG_PKG_HAVE_TEST_RACE} ]] && EGO_RACE=" -race" - - # Prepares build flags for the go toolchain. - local EGO_BUILD_FLAGS="$( echo ${EGO_VERBOSE} ) $( echo ${EGO_PARALLEL} ) $( echo ${EGO_EXTRA_OPTIONS} )" - [[ -n ${EGO_RACE} ]] && EGO_BUILD_FLAGS+=" $( echo ${EGO_RACE} )" - - # Sanitizes vars from entra white spaces. - GOLANG_PKG_LDFLAGS="$( echo ${GOLANG_PKG_LDFLAGS} )" - GOLANG_PKG_TAGS="$( echo ${GOLANG_PKG_TAGS} )" - - # Defines sub-packages. - local EGO_SUBPACKAGES="${GOLANG_PKG_IMPORTPATH_ALIAS}/${GOLANG_PKG_NAME}${GOLANG_PKG_BUILDPATH}" - [[ -z ${GOLANG_PKG_IS_MULTIPLE} ]] || EGO_SUBPACKAGES="./..." - - # Detects the total number of packages. - local pkgs=0 ifs_save=${IFS} IFS=$' ' - for path in ${GOLANG_PKG_BUILDPATH[@]} ; do - pkgs=$(( $pkgs + 1 )) - done - [[ ${pkgs} -eq 0 ]] && pkgs=1 # there is always at least 1 package - IFS=${ifs_save} - - # Runs the Unit Tests - einfo "Testing ${pkgs} package(s):" - if [[ -n ${GOLANG_PKG_BUILDPATH} && ${GOLANG_PKG_BUILDPATH##*/} != "..." && ${pkgs} -gt 1 ]]; then - - # NOTE: This eclass trims all leading and trailing white spaces from the - # input of the following 'while read' loop, then appends an extra - # trailing space; this is necessary to avoid undefined behaviours - # within the loop when GOLANG_PKG_BUILDPATH is populated with only - # a single element. - while read -r -d $' ' cmd; do - # Ignores $cmd when it's empty or a string of white spaces - #einfo "cmd: |$cmd| cmd: |${cmd##*/}|" - [[ -n $cmd ]] || continue - - einfo "${EGO} test -ldflags '$GOLANG_PKG_LDFLAGS' -tags '$GOLANG_PKG_TAGS' ${EGO_BUILD_FLAGS} ${GOLANG_PKG_IMPORTPATH_ALIAS}/${GOLANG_PKG_NAME}${cmd}/..." - ${EGO} test \ - -ldflags "${GOLANG_PKG_LDFLAGS}" \ - -tags "${GOLANG_PKG_TAGS}" \ - ${EGO_BUILD_FLAGS} \ - "${GOLANG_PKG_IMPORTPATH_ALIAS}/${GOLANG_PKG_NAME}${cmd}/..." \ - || die - done <<< "$( echo ${GOLANG_PKG_BUILDPATH}) " - else - # It's a single package - einfo "${EGO} test -ldflags '$GOLANG_PKG_LDFLAGS' -tags '$GOLANG_PKG_TAGS' ${EGO_BUILD_FLAGS} ${EGO_SUBPACKAGES}" - ${EGO} test \ - -ldflags "${GOLANG_PKG_LDFLAGS}" \ - -tags "${GOLANG_PKG_TAGS}" \ - ${EGO_BUILD_FLAGS} \ - "${EGO_SUBPACKAGES}" \ - || die - fi -} - - -# @FUNCTION: golang_do_build -# @INTERNAL -# @USAGE: -# @DESCRIPTION: -# -# @CODE -# Example: -# GOLANG_PKG_LDFLAGS="-extldflags=-static" -# GOLANG_PKG_TAGS="netgo" -# -# golang_do_build ${EGO_BUILD_FLAGS} ${GOLANG_PKG_IMPORTPATH}/${GOLANG_PKG_NAME}${GOLANG_PKG_BUILDPATH} -# @CODE -golang_do_build() { - debug-print-function ${FUNCNAME} $* - - [[ ${GOLANG_VERSION} ]] || die "No GoLang implementation set (golang_setup not called?)." - - # Filters "=" chars from ldflags declaration. - # NOTE: from go1.5+ linker syntax is no more compatible with -# @DESCRIPTION: -# -# @CODE -# Example -# -# golang_add_vendor "${S}"/vendor -# golang_add_vendor "${S}"/${PN}/vendor -# @CODE -golang_add_vendor() { - debug-print-function ${FUNCNAME} $* - - [[ ${1} ]] || die "${FUNCNAME}: no paths given" - - [[ ${GOLANG_VERSION} ]] || die "No Golang implementation set (golang_setup not called?)." - - [[ ! -d "${1}" ]] && return - - # NOTE: this hack is required by Go v1.4 and older versions. - #if [[ ! -d "${1}"/src ]]; then - # ebegin "Fixing $1" - # ln -s "${1}" "${1}"/src || die - # eend - #fi - - GOLANG_PKG_VENDOR+=(${1}) -} - - -# @FUNCTION: golang_fix_importpath_alias -# @USAGE: -# @DESCRIPTION: -# Helper functions for generating a symbolic link for import path as -# . -# -# WARNING: Use this function only if GOLANG_PKG_DEPENDENCIES declaration of -# import path aliases doesn't work (e.g.: the package name differs from both the -# import path and the alias, or if the package name is case sensitive but the -# import path is not). -# -# @CODE -# Example: -# -# src_prepare() { -# golang-single_src_prepare -# -# golang_fix_importpath_alias \ -# "github.com/GoogleCloudPlatform/gcloud-golang" \ -# "google.golang.org/cloud" -# } -# @CODE -golang_fix_importpath_alias() { - debug-print-function ${FUNCNAME} "${@}" - - [[ ${1} ]] || die "${FUNCNAME}: no target specified" - [[ ${2} ]] || die "${FUNCNAME}: no alias specified" - - [[ ${EGO} ]] || die "No GoLang implementation set (golang_setup not called?)." - - - local TARGET="${1}" - local ALIAS="${2}" - - if [[ ${ALIAS%/*} != ${ALIAS} ]]; then - mkdir -p "${GOPATH}/src/${ALIAS%/*}" || die - fi - ebegin "Linking ${TARGET} as ${ALIAS}" - ln -s "${GOPATH}/src/${TARGET}" \ - "${GOPATH}/src/${ALIAS}" \ - || die - eend -} - - -fi diff --git a/eclass/golang-live.eclass b/eclass/golang-live.eclass deleted file mode 100644 index 2d8902f..0000000 --- a/eclass/golang-live.eclass +++ /dev/null @@ -1,157 +0,0 @@ -# Copyright 1999-2017 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Id$ - -# @ECLASS: golang-live.eclass -# @MAINTAINER: -# Mauro Toffanin -# @AUTHOR: -# Mauro Toffanin -# @BLURB: Eclass for fetching and unpacking HEAD shapshot of go repositories -# @DESCRIPTION: -# This eclass is written to ease the maintenance of live ebuilds -# of software written in the Go programming language. - -inherit golang-common - -EXPORT_FUNCTIONS src_prepare src_unpack src_configure src_compile src_install src_test - -if [[ -z ${_GOLANG_LIVE_ECLASS} ]]; then -_GOLANG_LIVE_ECLASS=1 - - -# @ECLASS-VARIABLE: EGO_LIVESTORE_DIR -# @INTERNAL -# @DESCRIPTION: -# Storage directory for Go sources. -# Ebuilds must not set it. - -# @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 then switch over to building with FEATURES=userpriv. -# Or vice-versa. Shouldn't be a security issue here as anyone who has -# portage group write access already can screw the system over in more -# creative ways. - - -# Validates use of GOLANG_PKG_DEPENDENCIES. -# NOTE: a live ebuild should not have go dependencies. -# TODO: check also if GOLANG_PKG_DEPENDENCIES is an array -if [[ -n ${GOLANG_PKG_DEPENDENCIES} ]]; then - eerror "Ebuild ${CATEGORY}/${PF} specifies GOLANG_PKG_DEPENDENCIES." - eerror "Please, fix it by removing GOLANG_PKG_DEPENDENCIES entirely." - die "Banned variable GOLANG_PKG_DEPENDENCIES is set" -fi - - -# @FUNCTION: golang-live_src_fetch -# @DESCRIPTION: -# Fetch a go package along with its dependencies. -golang-live_src_fetch() { - debug-print-function ${FUNCTION} "$@" - - [[ -z ${EGO_LIVESTORE_DIR} ]] && die "No EGO_LIVESTORE_DIR set (golang-live_src_unpack not called?)." - - # Fetch the go package - [[ -n ${EVCS_UMASK} ]] && eumask_push ${EVCS_UMASK} - - set -- env \ - GOPATH="${EGO_LIVESTORE_DIR}" \ - go get -d -u -v -t -tags="${GOLANG_PKG_TAGS}" ${@} - echo "$@" - "$@" || die - - [[ -n ${EVCS_UMASK} ]] && eumask_pop -} - -# @FUNCTION: golang-live_src_unpack -# @DESCRIPTION: -# Unpack the source archive. -golang-live_src_unpack() { - debug-print-function ${FUNCNAME} "$@" - - # Creates EGO_LIVESTORE_DIR if necessary. - local distdir=${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}} - : EGO_LIVESTORE_DIR=${EGO_LIVESTORE_DIR:=${distdir}/go-${PN}-livesrc} - - [[ -n ${EVCS_UMASK} ]] && eumask_push ${EVCS_UMASK} - - if [[ ! -d ${EGO_LIVESTORE_DIR} ]]; then - ( - addwrite / - mkdir -p "${EGO_LIVESTORE_DIR}" - ) || die "${ECLASS}: unable to create ${EGO_LIVESTORE_DIR}" - fi - - addwrite "${EGO_LIVESTORE_DIR}" - - [[ -n ${EVCS_UMASK} ]] && eumask_pop - - # Retrieves the GOLANG_PKG_IMPORTPATH go package. - golang-live_src_fetch "${GOLANG_PKG_IMPORTPATH}/${GOLANG_PKG_NAME}"/... - - # Creates SOURCE directory. - mkdir -p "${S}" || die -} - - -# @FUNCTION: golang-live_src_prepare -# @DESCRIPTION: -# Prepare source code. -golang-live_src_prepare() { - debug-print-function ${FUNCNAME} "${@}" - - # Sets up GoLang build environment. - golang_setup - - # Imports all go dependencies - ebegin "Importing all the sources in ${GOPATH}" - cp -r "${EGO_LIVESTORE_DIR}/src" "${GOPATH}" || die "Unable to copy sources to ${GOPATH}" - eend - - golang-common_src_prepare -} - - -# @FUNCTION: golang-live_src_configure -# @DESCRIPTION: -# Configure the package. -golang-live_src_configure() { - debug-print-function ${FUNCNAME} "$@" - - golang-common_src_configure -} - -# @FUNCTION: golang-live_src_compile -# @DESCRIPTION: -# Compiles the package. -golang-live_src_compile() { - debug-print-function ${FUNCNAME} "$@" - - golang-common_src_compile -} - -# @FUNCTION: golang-live_src_install -# @DESCRIPTION: -# Installs binaries and documents from DOCS or HTML_DOCS arrays. -golang-live_src_install() { - debug-print-function ${FUNCNAME} "$@" - - golang-common_src_install -} - -# @FUNCTION: golang-live_src_test -# @DESCRIPTION: -# Runs the unit tests for the main package. -golang-live_src_test() { - debug-print-function ${FUNCNAME} "$@" - - golang-common_src_test -} - - -fi diff --git a/eclass/golang-single.eclass b/eclass/golang-single.eclass deleted file mode 100644 index e8007f7..0000000 --- a/eclass/golang-single.eclass +++ /dev/null @@ -1,185 +0,0 @@ -# Copyright 1999-2017 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Id$ - -# @ECLASS: golang-single.eclass -# @MAINTAINER: -# Mauro Toffanin -# @AUTHOR: -# Mauro Toffanin -# @BLURB: An eclass for GoLang packages not installed inside GOPATH/GOBIN. -# @DESCRIPTION: -# This eclass allows to install arbitrary packages written in GoLang which -# don't support being installed inside the Go environment. -# This mostly includes traditional packages (C/C++/GUI) embedding tools written -# in GoLang, and GoLang packages that need to be compiled with GCC instead of -# the standard Go interpreter. -# -# @EXAMPLE: -# Typical ebuild using golang-single.eclass: -# -# @CODE -# EAPI=5 -# -# GOLANG_PKG_IMPORTPATH="github.com/captObvious" -# GOLANG_PKG_ARCHIVESUFFIX=".zip" -# GOLANG_PKG_HAVE_TEST -# inherit golang-single qt4-r2 -# -# DESCRIPTION="Foo bar application" -# HOMEPAGE="http://example.org/foo/" -# -# LICENSE="MIT" -# KEYWORDS="~amd64 ~x86" -# SLOT="0" -# IUSE="doc qt4" -# -# CDEPEND=" -# qt4? ( -# dev-qt/qtcore:4 -# dev-qt/qtgui:4 -# )" -# RDEPEND="${CDEPEND} -# !media-gfx/bar" -# DEPEND="${CDEPEND} -# doc? ( app-doc/doxygen )" -# -# DOCS=(AUTHORS ChangeLog README "Read me.txt" TODO) -# -# PATCHES=( -# "${FILESDIR}/${P}-qt4.patch" # bug 123458 -# "${FILESDIR}/${P}-as-needed.patch" -# ) -# -# src_install() { -# use doc && HTML_DOCS=("${BUILD_DIR}/apidocs/html/") -# autotools-utils_src_install -# if use examples; then -# dobin "${BUILD_DIR}"/foo_example{1,2,3} \\ -# || die 'dobin examples failed' -# fi -# } -# -# @CODE - - -inherit golang-common - -EXPORT_FUNCTIONS src_prepare src_unpack src_configure src_compile src_install src_test - -if [[ -z ${_GOLANG_SINGLE_ECLASS} ]]; then -_GOLANG_SINGLE_ECLASS=1 - - -# This eclass uses GOLANG_PKG_IMPORTPATH to populate SRC_URI. -SRC_URI="${SRC_URI:="https://${GOLANG_PKG_IMPORTPATH}/${GOLANG_PKG_NAME}/archive/${GOLANG_PKG_ARCHIVEPREFIX}${GOLANG_PKG_VERSION}${GOLANG_PKG_ARCHIVESUFFIX} -> ${P}${GOLANG_PKG_ARCHIVESUFFIX}"}" - -# This eclass uses GOLANG_PKG_DEPENDENCIES associative array to populate SRC_URI -# with the required snapshots of the supplied GoLang dependencies. -if [[ ${#GOLANG_PKG_DEPENDENCIES[@]} -gt 0 ]]; then - - for i in ${!GOLANG_PKG_DEPENDENCIES[@]} ; do - - # Collects all the tokens of the dependency. - local -A DEPENDENCY=() - while read -d $'\n' key value; do - [[ -z ${key} ]] && continue - DEPENDENCY[$key]="${value}" - done <<-EOF - $( _factorize_dependency_entities "${GOLANG_PKG_DEPENDENCIES[$i]}" ) - EOF - - # Debug - debug-print "${FUNCNAME}: DEPENDENCY = ${GOLANG_PKG_DEPENDENCIES[$i]}" - debug-print "${FUNCNAME}: importpath = ${DEPENDENCY[importpath]}" - debug-print "${FUNCNAME}: revision = ${DEPENDENCY[revision]}" - - # Downloads the archive. - case ${DEPENDENCY[importpath]} in - github*) - SRC_URI+=" https://${DEPENDENCY[importpath]}/archive/${DEPENDENCY[revision]}${GOLANG_PKG_ARCHIVESUFFIX} -> ${DEPENDENCY[importpath]//\//-}-${DEPENDENCY[revision]}${GOLANG_PKG_ARCHIVESUFFIX}" - ;; - bitbucket*) - SRC_URI+=" https://${DEPENDENCY[importpath]}/get/${DEPENDENCY[revision]}.zip -> ${DEPENDENCY[importpath]//\//-}-${DEPENDENCY[revision]}.zip" - ;; - code.google*) - SRC_URI+=" https://${DEPENDENCY[project_name]}.googlecode.com/archive/${DEPENDENCY[revision]}.tar.gz -> ${DEPENDENCY[importpath]//\//-}-${DEPENDENCY[revision]}.tar.gz" - ;; - *) die "This eclass doesn't support '${DEPENDENCY[importpath]}'" ;; - esac - - done -fi - - -# @FUNCTION: golang-single_src_unpack -# @DESCRIPTION: -# Unpack the source archive. -golang-single_src_unpack() { - debug-print-function ${FUNCNAME} "${@}" - - default - - # Creates S. - mkdir -p "${S%/*}" || die - - # Moves main GoLang package from WORKDIR into GOPATH. - if [[ "${GOLANG_PKG_IMPORTPATH}" != "${GOLANG_PKG_IMPORTPATH_ALIAS}" ]]; then - local alias_abspath="${WORKDIR}/gopath/src/${GOLANG_PKG_IMPORTPATH_ALIAS}/${GOLANG_PKG_NAME}" - mkdir -p "${alias_abspath%/*}" || die - mv "${GOLANG_PKG_NAME}-${GOLANG_PKG_VERSION}" "${alias_abspath}"/ || die - else - mv "${GOLANG_PKG_NAME}-${GOLANG_PKG_VERSION}" "${S}"/ || die - fi -} - - -# @FUNCTION: golang-single_src_prepare -# @DESCRIPTION: -# Prepare source code. -golang-single_src_prepare() { - debug-print-function ${FUNCNAME} "$@" - - # Sets up GoLang build environment. - golang_setup - - golang-common_src_prepare -} - -# @FUNCTION: golang-single_src_configure -# @DESCRIPTION: -# Configure the package. -golang-single_src_configure() { - debug-print-function ${FUNCNAME} "$@" - - golang-common_src_configure -} - -# @FUNCTION: golang-single_src_compile -# @DESCRIPTION: -# Compiles the package. -golang-single_src_compile() { - debug-print-function ${FUNCNAME} "$@" - - golang-common_src_compile -} - -# @FUNCTION: golang-single_src_install -# @DESCRIPTION: -# Installs binaries and documents from DOCS or HTML_DOCS arrays. -golang-single_src_install() { - debug-print-function ${FUNCNAME} "$@" - - golang-common_src_install -} - -# @FUNCTION: golang-single_src_test -# @DESCRIPTION: -# Runs the unit tests for the main package. -golang-single_src_test() { - debug-print-function ${FUNCNAME} "$@" - - golang-common_src_test -} - -fi diff --git a/net-analyzer/amass/amass-9999.ebuild b/net-analyzer/amass/amass-9999.ebuild index b130786..0049921 100644 --- a/net-analyzer/amass/amass-9999.ebuild +++ b/net-analyzer/amass/amass-9999.ebuild @@ -10,6 +10,7 @@ inherit go-module if [[ ${PV} == *9999* ]]; then inherit git-r3 EGIT_REPO_URI="https://${EGO_PN}.git" + EGO_VER="devel" src_unpack() { git-r3_src_unpack @@ -18,17 +19,14 @@ if [[ ${PV} == *9999* ]]; then else EGO_VER="v${PV}" #SRC_URI="https://${EGO_PN}/archive/${EGO_VER}.tar.gz -> ${P}.tar.gz" - - #SRC_URI+="${EGO_SUM_SRC_URI}" - #S="${WORKDIR}/Amass-${PV}" inherit git-r3 EGIT_REPO_URI="https://${EGO_PN}.git" EGIT_COMMIT="${EGO_VER}" - src_unpack() { - git-r3_src_unpack - go-module_live_vendor - } + src_unpack() { + git-r3_src_unpack + go-module_live_vendor + } KEYWORDS="~amd64 ~x86 ~arm64 ~arm" fi @@ -45,17 +43,18 @@ src_compile() { use pie && local build_pie="-buildmode=pie" local build_flags="$( echo ${EGO_BUILD_FLAGS} ) $( echo ${build_pie} )" + local ld_flags="" set -- env \ CGO_ENABLED=0 \ - go build -o "bin/${PN}" -mod=vendor -v -work -x ${build_flags} \ + go build -o "bin/${PN}" -mod=vendor -v -work -x "${build_flags}" -ldflags "${ld_flags}" \ ./cmd/${PN} echo "$@" "$@" || die } src_install() { - dobin bin/${PN} + dobin bin/* insinto /etc/amass doins "${S}"/examples/config.ini diff --git a/net-misc/BaiduPCS-Go/BaiduPCS-Go-9999.ebuild b/net-misc/BaiduPCS-Go/BaiduPCS-Go-9999.ebuild index 54d5e7c..01efabe 100644 --- a/net-misc/BaiduPCS-Go/BaiduPCS-Go-9999.ebuild +++ b/net-misc/BaiduPCS-Go/BaiduPCS-Go-9999.ebuild @@ -43,11 +43,11 @@ src_compile() { use pie && local build_pie="-buildmode=pie" local build_flags="$( echo ${EGO_BUILD_FLAGS} ) $( echo ${build_pie} )" + local ld_flags="$( echo "-s -w -X 'main.Version='${EGO_VER}'" )" set -- env \ CGO_ENABLED=0 \ - go build -o "bin/baidu-pcs" -mod=vendor -v -work -x ${build_flags} \ - -ldflags '-s -w -X main.Version='${EGO_VER} \ + go build -o "bin/baidu-pcs" -mod=vendor -v -work -x "${build_flags}" -ldflags "${ld_flags}" \ . echo "$@" "$@" || die diff --git a/net-misc/curlie/curlie-9999.ebuild b/net-misc/curlie/curlie-9999.ebuild index 8f1b6c4..ac9812b 100644 --- a/net-misc/curlie/curlie-9999.ebuild +++ b/net-misc/curlie/curlie-9999.ebuild @@ -43,10 +43,11 @@ src_compile() { use pie && local build_pie="-buildmode=pie" local build_flags="$( echo ${EGO_BUILD_FLAGS} ) $( echo ${build_pie} )" + local ld_flags="$( echo "-s -w -X 'main.version=${EGO_VER}' -X 'main.commit=${EGIT_VERSION}' -X 'main.date=$(date --iso-8601=seconds)'" )" set -- env \ CGO_ENABLED=0 \ - go build -o "bin/${PN}" -mod=vendor -v -work -x ${build_flags} \ + go build -o "bin/${PN}" -mod=vendor -v -work -x "${build_flags}" -ldflags "${ld_flags}" \ . echo "$@" "$@" || die diff --git a/net-misc/hargo/Manifest b/net-misc/hargo/Manifest deleted file mode 100644 index 4f1a461..0000000 --- a/net-misc/hargo/Manifest +++ /dev/null @@ -1,8 +0,0 @@ -DIST github.com-blang-semver-v3.5.1.tar.gz 14831 BLAKE2B e0c6d3f33add029913f6235667993f50901050482667121a362f6e56cfd2d9cbef585056d5a031162b162fd458d78380d48e8bb1be575c051206e064aef7c15b SHA512 836a218f54e20c5ca322fee39d6757f45ab34341d1eca639d584774b0aefe0136441ef36bf91b4695346e769c35402f3083c17878839c428291dddc5130ae0ca -DIST github.com-golang-net-ba9fcec4b297.tar.gz 1100219 BLAKE2B 763e2e4b38adf4f7abed20974aaeadbd22356f7224957b6f8d99146d07355ba6924727e93ef71f0e3b0416a7f5269539321223c56c9b3b4667160ff947a544b5 SHA512 8ad57611de7fcc6766da4ff1c29adf2e9d21eb888dcf0c1160b31b310f1f94d4c3bd45a1a3627d9f2ab9fcc8f4c0960beceae3771083b8a2cddc2568f5c4f1a2 -DIST github.com-golang-sys-953cdadca894.tar.gz 1355032 BLAKE2B 117c73ebb46b736c5747d4e7e4fd6a67bb33724724259766217743e363d4359f8ddb44ec50707394d2b3f9842df50fba8abc48a7021a15d35a89cc9d524bcb7a SHA512 2be9fe83c5cb252ae915c77dc6e905b5057a70aebd6a9f38cc3fbc85996c486e6ea108ad554c8354be28e5da21932fc1037ea86969322b0d99d2cd40adb53f6f -DIST github.com-golang-text-v0.3.0.tar.gz 6102619 BLAKE2B c92e68014a8c157d76741c02acd708771d66bd3dda5b19285f5aa3e073e0fe3fccb9054744d35ea62b681ae4421bb7489238d6868f9314fb26f88e002287abe8 SHA512 bd60dfaa7d9dbfca171a3ba40b51f5663c01257cf3b12b618d35689a97ab2212d316d5716ff09681bf40b099f7e20a0e0df8cfc065699cb6a07ad1dc2e2bc189 -DIST github.com-influxdata-influxdb1-client-fc22c7df067e.tar.gz 58365 BLAKE2B e47caf550688580386e192af4a934949ebc1c91bda9ac32c78b19af21b2f94e4bd01e1a629bc9c9bfeaafe22cd0f2ab15ac06d90ff8644c1abb3dc6d20324abf SHA512 120bf09267f6719a952c0ad4727079bf31432b0b020ae7c8637f13df169df677c20730cf2861b40481030c4686e4123dc84370a5f20f52f35ea5bb9a1eadfc81 -DIST github.com-sirupsen-logrus-v1.4.2.tar.gz 41373 BLAKE2B 3675dd82fd9c174fddf93eea87f3ca2c2671d9719ba148b03136c35ce6a3ce95866c57cb706a641a14522a522606dc9ea9ec9f0a6c7da6f8cf18f46b9f4bd3ee SHA512 c29689e5ea0ff919afc6fe1c492898d8b898e6831c442d3fc45c29508bdfda08604b1ea09d3b17db401bddca69fd5f8f744610075ee3c0577df6a537e0980a13 -DIST github.com-urfave-cli-v1.21.0.tar.gz 68419 BLAKE2B 4fe7091cfe3dd58d1c73d7ade84c70efbfeda354f8dfeb1cf7572b8792ed15c14432b4815107aae900a7d45e08a81dd261c97edac1a94a2e9557c3e595824e20 SHA512 8bd1dc64220eb5388da99a9d98971097b7e64dc054cdaff54c86fd427667962aa8add7edaeb045d17515bb15df885c369f939a5d374e8bcc010c7f0fdd554763 -DIST hargo-0.1.2.tar.gz 51331 BLAKE2B adf51fa4442c6586deeb29e43f0bff547e64871b40783fcef5f38de89b0f846f74468711ecbf5569ad64988634720b7effe916dba3ee25ba83f093bdf42f6cda SHA512 9dc03622d99672e3c6f4077c2f2cb5bf4e26ab05b3d098afb7e91d9d930bff2d7d943b5acff873708bfe9ebc98870bdaa6db15e1e3c90096ae43d936d9d50d08 diff --git a/net-misc/hargo/hargo-0.1.2-r1.ebuild b/net-misc/hargo/hargo-0.1.2-r1.ebuild new file mode 120000 index 0000000..ff01121 --- /dev/null +++ b/net-misc/hargo/hargo-0.1.2-r1.ebuild @@ -0,0 +1 @@ +hargo-9999.ebuild \ No newline at end of file diff --git a/net-misc/hargo/hargo-0.1.2.ebuild b/net-misc/hargo/hargo-0.1.2.ebuild deleted file mode 100644 index 4b046d9..0000000 --- a/net-misc/hargo/hargo-0.1.2.ebuild +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright 1999-2019 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=7 - -EGO_PN="github.com/mrichman/${PN}" -EGO_VENDOR=( - "github.com/blang/semver v3.5.1" - "github.com/influxdata/influxdb1-client fc22c7df067e" - "github.com/sirupsen/logrus v1.4.2" - "github.com/urfave/cli v1.21.0" - "golang.org/x/net ba9fcec4b297 github.com/golang/net" - "golang.org/x/sys 953cdadca894 github.com/golang/sys" - "golang.org/x/text v0.3.0 github.com/golang/text" -) - -inherit golang-build golang-vcs-snapshot - -DESCRIPTION="A command line utility that parses HAR files, written in GoLang" -ARCHIVE_URI="https://${EGO_PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz - ${EGO_VENDOR_URI}" -SRC_URI="${ARCHIVE_URI}" -RESTRICT="mirror" - -LICENSE="MIT" -SLOT="0/${PVR}" -KEYWORDS="~amd64 ~x86 ~arm" -IUSE="+pie" - -src_compile() { - # -buildmode=pie forces external linking mode, even CGO_ENABLED=0 - # https://github.com/golang/go/issues/18968 - use pie && local build_pie="-buildmode=pie" - - local build_flags="$( echo ${EGO_BUILD_FLAGS} ) $( echo ${build_pie} )" - - set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \ - GOCACHE="${T}/go-cache" \ - CGO_ENABLED=0 \ - GO111MODULE=off \ - go install -v -work -x ${build_flags} ${EGO_PN}/cmd/hargo - echo "$@" - "$@" || die -} - -src_install() { - dobin bin/* -} diff --git a/net-misc/hargo/hargo-9999.ebuild b/net-misc/hargo/hargo-9999.ebuild new file mode 100644 index 0000000..efebab5 --- /dev/null +++ b/net-misc/hargo/hargo-9999.ebuild @@ -0,0 +1,58 @@ +# Copyright 2019-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +EGO_PN="github.com/mrichman/${PN}" + +inherit go-module + +if [[ ${PV} == *9999* ]]; then + inherit git-r3 + EGIT_REPO_URI="https://${EGO_PN}.git" + EGO_VER="devel" + + src_unpack() { + git-r3_src_unpack + go-module_live_vendor + } +else + EGO_VER="v${PV}" + #SRC_URI="https://${EGO_PN}/archive/${EGO_VER}.tar.gz -> ${P}.tar.gz" + inherit git-r3 + EGIT_REPO_URI="https://${EGO_PN}.git" + EGIT_COMMIT="${EGO_VER}" + + src_unpack() { + git-r3_src_unpack + go-module_live_vendor + } + + KEYWORDS="~amd64 ~x86 ~arm64 ~arm" +fi + +DESCRIPTION="A command line utility that parses HAR files, written in GoLang" +LICENSE="MIT" +SLOT="0/${PVR}" +RESTRICT="mirror" +IUSE="+pie" + +src_compile() { + # -buildmode=pie forces external linking mode, even CGO_ENABLED=0 + # https://github.com/golang/go/issues/18968 + use pie && local build_pie="-buildmode=pie" + + local build_flags="$( echo ${EGO_BUILD_FLAGS} ) $( echo ${build_pie} )" + local ld_flags="$( echo "-s -w -X 'main.Version=${EGO_VER}' -X 'main.CommitHash=${EGIT_VERSION}' -X 'main.CompileDate=$(date --iso-8601=seconds)'" )" + + set -- env \ + CGO_ENABLED=0 \ + go build -o "bin/${PN}" -mod=vendor -v -work -x "${build_flags}" -ldflags "${ld_flags}" \ + ./cmd/${PN} + echo "$@" + "$@" || die +} + +src_install() { + dobin bin/* +} diff --git a/net-vpn/cloudflared/Manifest b/net-vpn/cloudflared/Manifest index c3d7e26..05d0228 100644 --- a/net-vpn/cloudflared/Manifest +++ b/net-vpn/cloudflared/Manifest @@ -1 +1 @@ -DIST cloudflared-2022.1.0.tar.gz 8446189 BLAKE2B 9b138a39af9db8608d755b4c1ebeffb9054ae3e892ac83bd80c54c250a6fa04e08147ad67258e3403888fd9909320686e0bda928a7ee91e2f8e90bbc8705ca85 SHA512 c0d450cefaa10ed34fee7462fbd1790db5437d0fe33604fcd2e62550e478eb30123f6ce0cc1ae91c2260449fb527ef91263da85fcd1cc87382372fd09352df63 +DIST cloudflared-2022.3.1.tar.gz 8698091 BLAKE2B 96f22be962e88851a8070290052e3ab01f47ed4a885c4d52ff74c3003cf0e9fe23664851f0e806219f75969fccc9ff427c44c380ff764666e17fe9264d09ed82 SHA512 14c75b060cc5fbac7e56416bfb38bb90df4041903e220853e8aa3fffcbccbad65d9bdba4cdd8c16f185159298651a1932cca978bc514c7c390f3c40ebcce334e diff --git a/net-vpn/cloudflared/cloudflared-2022.1.0.ebuild b/net-vpn/cloudflared/cloudflared-2022.1.0.ebuild deleted file mode 120000 index 91902b4..0000000 --- a/net-vpn/cloudflared/cloudflared-2022.1.0.ebuild +++ /dev/null @@ -1 +0,0 @@ -cloudflared-9999.ebuild \ No newline at end of file diff --git a/net-vpn/cloudflared/cloudflared-2022.3.1.ebuild b/net-vpn/cloudflared/cloudflared-2022.3.1.ebuild new file mode 120000 index 0000000..91902b4 --- /dev/null +++ b/net-vpn/cloudflared/cloudflared-2022.3.1.ebuild @@ -0,0 +1 @@ +cloudflared-9999.ebuild \ No newline at end of file diff --git a/net-vpn/cloudflared/cloudflared-9999.ebuild b/net-vpn/cloudflared/cloudflared-9999.ebuild index 06bc94f..ec917c5 100644 --- a/net-vpn/cloudflared/cloudflared-9999.ebuild +++ b/net-vpn/cloudflared/cloudflared-9999.ebuild @@ -1,7 +1,7 @@ # Copyright 2019-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 -EAPI=7 +EAPI=8 EGO_PN="github.com/cloudflare/${PN}" @@ -10,21 +10,24 @@ inherit go-module systemd if [[ ${PV} == *9999* ]]; then inherit git-r3 EGIT_REPO_URI="https://${EGO_PN}.git" + EGO_VER="devel" src_unpack() { git-r3_src_unpack #go-module_live_vendor } else - EGO_VER="${P}" + EGO_VER="${PV}" SRC_URI="https://${EGO_PN}/archive/${EGO_VER}.tar.gz -> ${P}.tar.gz" + #inherit git-r3 + #EGIT_REPO_URI="https://${EGO_PN}.git" + #EGIT_COMMIT="${EGO_VER}" - EGO_SUM=( - ) - go-module_set_globals + #src_unpack() { + # git-r3_src_unpack + # go-module_live_vendor + #} - SRC_URI+="${EGO_SUM_SRC_URI}" - S="${WORKDIR}/${EGO_VER}" KEYWORDS="~amd64 ~x86 ~arm64 ~arm" fi @@ -40,19 +43,18 @@ src_compile() { use pie && local build_pie="-buildmode=pie" local build_flags="$( echo ${EGO_BUILD_FLAGS} ) $( echo ${build_pie} )" + local ld_flags="$( echo "-s -w -X 'main.Version=${EGO_VER}' -X 'main.BuildTime=$(date -R)'" )" set -- env \ - GOCACHE="${T}/go-cache" \ CGO_ENABLED=0 \ - go build -o "bin/${PN}" -mod=vendor -v -work -x ${build_flags} \ - -ldflags "-X \"main.Version=${PV}\" -X \"main.BuildTime=$(date -u '+%Y-%m-%d-%H%M UTC')\"" \ - ${EGO_PN}/cmd/${PN} + go build -o "bin/${PN}" -mod=vendor -v -work -x "${build_flags}" -ldflags "${ld_flags}" \ + ./cmd/${PN} echo "$@" "$@" || die } src_install() { - dobin bin/${PN} + dobin bin/* insinto /etc/cloudflared doins "${FILESDIR}"/config.yml -- cgit v1.2.3-65-gdbad