Skip to content

Instantly share code, notes, and snippets.

@code-of-kpp
Last active August 5, 2019 19:35
Show Gist options
  • Save code-of-kpp/9dec1556db15f23beadc8e5e3b776f8c to your computer and use it in GitHub Desktop.
Save code-of-kpp/9dec1556db15f23beadc8e5e3b776f8c to your computer and use it in GitHub Desktop.
# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
EGO_VENDOR=(
"github.com/BurntSushi/toml v0.3.0"
"github.com/armon/go-radix 1fca145dffbc"
"github.com/coreos/go-systemd 95778dfbb74e"
"github.com/davecgh/go-spew v1.1.0"
"github.com/dgryski/go-farm ac7624ea8da3"
"github.com/eapache/channels v1.1.0"
"github.com/eapache/queue v1.0.2"
"github.com/fsnotify/fsnotify v1.4.2"
"github.com/golang/protobuf 748d386b5c1e"
"github.com/hashicorp/hcl 392dba7d905e"
"github.com/inconshreveable/mousetrap v1.0.0"
"github.com/jessevdk/go-flags v1.3.0"
"github.com/kr/pretty cfb55aafdaf3"
"github.com/kr/text 7cafcd837844"
"github.com/magiconair/properties v1.7.3"
"github.com/mitchellh/mapstructure d0303fe80992"
"github.com/pelletier/go-buffruneio v0.2.0"
"github.com/pelletier/go-toml v1.0.0"
"github.com/pmezard/go-difflib v1.0.0"
"github.com/satori/go.uuid 36e9d2ebbde5"
"github.com/sirupsen/logrus a3f95b5c4235"
"github.com/spf13/afero 9be650865eab"
"github.com/spf13/cast v1.1.0"
"github.com/spf13/cobra b26b538f6930"
"github.com/spf13/jwalterweatherman 0efa5202c046"
"github.com/spf13/pflag v1.0.0"
"github.com/spf13/viper v1.0.0"
"github.com/stretchr/testify v1.1.4"
"github.com/vishvananda/netlink a95659537721"
"github.com/vishvananda/netns 86bef332bfc3"
"golang.org/x/net f5079bd7f6f7 github.com/golang/net"
"golang.org/x/sync 37e7f081c4d4 github.com/golang/sync"
"golang.org/x/sys e312636bdaa2 github.com/golang/sys"
"golang.org/x/text 3bd178b88a81 github.com/golang/text"
"google.golang.org/genproto 09f6ed296fc6 github.com/google/go-genproto"
"google.golang.org/grpc v1.5.1 github.com/grpc/grpc-go"
"gopkg.in/check.v1 788fd7840127 github.com/go-check/check"
"gopkg.in/yaml.v2 25c4ec802a7d github.com/go-yaml/yaml"
)
EGO_PN="github.com/osrg/${PN}"
inherit golang-build golang-vcs-snapshot bash-completion-r1
EGIT_COMMIT="805d02fdfbc5092ef7a676b1c3a63dfb32571b47"
ARCHIVE_URI="https://${EGO_PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
KEYWORDS="~amd64 ~x86 ~arm ~arm64"
DESCRIPTION="BGP implemented in the Go Programming Language"
HOMEPAGE="https://osrg.github.io/gobgp/"
SRC_URI="${ARCHIVE_URI}
${EGO_VENDOR_URI}"
LICENSE="Apache-2.0"
SLOT="0"
IUSE="bash-completion gccgo doc +client server static"
DEPEND="
gccgo? ( sys-devel/gcc[go] )
bash-completion? ( app-shells/bash )
"
src_compile() {
pushd src/${EGO_PN}/cmd || die
local ldflags="-X 'main.version=${PV}' "
ldflags+="-X '/main.commit=${EGIT_COMMIT}' "
ldflags+="-X '/main.date=$(date -u +%FT%T%z)' "
local gccgoflags=""
use gccgo && gccgoflags+="${GCCGOFLAGS} "
if use gccgo; then
gccgoflags+="$(usex static "-static ${LDFLAGS}" "${LDFLAGS}")"
else
ldflags+=$(usex static "-extldflags '-static ${LDFLAGS}' " "-extldflags '${LDFLAGS}' ")
fi
use gccgo && (
sed -i "s@version = \"master\"@version = \"${PV}\"@" ./${PN}{,d}/main.go || die
)
local cgo="$(usex static 0 1)"
local gccgo="$(usex gccgo "-compiler=gccgo" "")"
use server && (
CGO_ENABLED=${cgo} GOPATH="${S}" \
go build -a ${gccgo} -gccgoflags "${gccgoflags}" -ldflags "${ldflags}" \
-x -v -o ../${PN}d ./${PN}d || die)
use client && (
CGO_ENABLED=${cgo} GOPATH="${S}" \
go build -a ${gccgo} -gccgoflags "${gccgoflags}" -ldflags "${ldflags}" \
-x -v -o ../${PN} ./${PN} || die
../${PN} --gen-cmpl --bash-cmpl-file ../bash-completion
)
popd || die
}
src_install() {
pushd src/${EGO_PN} || die
use client && (dobin ${PN} || die)
use server && (dobin ${PN}d || die)
use doc && dodoc README.md docs/sources/*
use bash-completion && (
newbashcomp bash-completion ${PN} || \
newbashcomp tools/completion/gobgp-completion.bash ${PN} || die
)
popd || die
use server && (
newinitd "${FILESDIR}"/gobgpd.initd gobgpd
newconfd "${FILESDIR}"/gobgpd.confd gobgpd
insinto /etc/logrotate.d
newins "${FILESDIR}"/gobgpd.logrotated gobgpd
insinto /etc/gobgpd
newins "${FILESDIR}"/gobgpd.toml gobgp.conf
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment