deso

Gentoo > Writing a Go ebuild

Get the project's source code

wget https://github.com/derailed/popeye/archive/refs/tags/v0.9.8.tar.gz
tar -xf v0.9.8.tar.gz
cd popeye-0.9.8

Create a dependency tarball

GOPROXY=https://proxy.golang.org,direct GOMODCACHE="${PWD}/go-mod" go mod download -modcacherw
tar -acf "$(basename $PWD)-deps.tar.xz" go-mod

GOPROXY should be set to a valid Go proxy URL to avoid downloading Git repositories as they will significantly increase the size of the archive later.

Put the dependency tarball somewhere

The dependency tarball must be located at an accessible location, for example a file server: https://dist.deso.onl/

Write the ebuild

EAPI=8

inherit go-module

DESCRIPTION="Popeye - A Kubernetes Cluster Sanitizer"
HOMEPAGE="https://github.com/derailed/popeye"

SRC_URI="https://github.com/derailed/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"

SRC_URI+=" https://dist.deso.onl/${P}-deps.tar.xz"

LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="amd64 arm64"

RESTRICT=" test"

src_compile() {
        emake GOFLAGS="${GOFLAGS}" build
}

src_install() {
        dobin execs/${PN}
}

Build it

doas ebuild popeye-0.9.8 manifest
doas ebuild popeye-0.9.8 install

21:00 20.02.2022