aboutsummaryrefslogtreecommitdiff
blob: b3a5dfffd2757fccd0387148d6d2fedee2f8bebf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Copyright 2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8
MY_PN=${PN//-cni-plugin}
MY_P=${MY_PN}-${PV}

inherit go-module

DESCRIPTION="name resolution for containers"
HOMEPAGE="https://github.com/containers/dnsname"

if [[ ${PV} == *9999 ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/containers/dnsname.git"
	RESTRICT="fetch mirror test"
else
	SRC_URI="https://github.com/containers/dnsname/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"
	SRC_URI+=" ${P}-deps.tar.xz"
	KEYWORDS="~amd64 ~arm64"
	RESTRICT="mirror test"
	S="${WORKDIR}"/${MY_P}
fi

LICENSE="Apache-2.0"
SLOT="0"

DEPEND="
	app-containers/podman
	net-misc/cni-plugins
	net-dns/dnsmasq
"
RDEPEND="${DEPEND}"

src_unpack() {
	default
	if [[ ${PV} == *9999 ]]; then
		git-r3_src_unpack
		pushd ${P}/plugins/meta/dnsname || die "location change for module building failed"
		ego get
		popd || die "location reset from module building failed"
	fi
}

src_prepare() {
	default
	rm LICENSE || die "removal of unneeded LICENSE failed"
	rm CODE-OF-CONDUCT.md || die "removal of unneeded CODE-OF-CONDUCT.md failed"
	rm RELEASE_NOTES.md || die "removal of unneeded RELEASE_NOTES.md failed"
	rm OWNERS || die "a removal of an unneeded documentation file failed"
}

src_compile() {
	local git_commit=${EGIT_COMMIT}
	export -n GOCACHE GOPATH XDG_CACHE_HOME
	GOBIN="${S}/bin" \
	emake all \
		GIT_BRANCH=master \
		GIT_BRANCH_CLEAN=master \
		COMMIT_NO="${git_commit}" \
		GIT_COMMIT="${git_commit}"
}

src_install() {
	exeinto /opt/cni/bin
	doexe bin/*
	dodoc README.md README_PODMAN.md SECURITY.md
}