From 3445b5f60c0606a31d818da37d9da10ee25c9eb1 Mon Sep 17 00:00:00 2001 From: Rahil Bhimjiani Date: Mon, 6 Nov 2023 01:28:21 +0530 Subject: net-dns/coredns: add 1.11.1 & live 1) Following upstream's method of building using make 2) removing git commit for non-live versions 3) follow skel.ebuild syntax structure 4) split LICENSE & SRC_URI Signed-off-by: Rahil Bhimjiani Signed-off-by: Zac Medico --- net-dns/coredns/Manifest | 2 + net-dns/coredns/coredns-1.11.1.ebuild | 123 +++++++++++++++++++++ net-dns/coredns/coredns-9999.ebuild | 119 ++++++++++++++++++++ .../buildopts-gitcommit-makefile-1.11.1.patch | 29 +++++ net-dns/coredns/files/coredns.service | 4 +- 5 files changed, 276 insertions(+), 1 deletion(-) create mode 100644 net-dns/coredns/coredns-1.11.1.ebuild create mode 100644 net-dns/coredns/coredns-9999.ebuild create mode 100644 net-dns/coredns/files/buildopts-gitcommit-makefile-1.11.1.patch (limited to 'net-dns') diff --git a/net-dns/coredns/Manifest b/net-dns/coredns/Manifest index c48cabab3e06..cea4e5c8dea4 100644 --- a/net-dns/coredns/Manifest +++ b/net-dns/coredns/Manifest @@ -1,2 +1,4 @@ DIST coredns-1.10.1-deps.tar.xz 230970760 BLAKE2B 79e9199256ddcb5c6728aa1cab62608177099d278a44bc5393148ed49139fa97ebc82fd0e749847bb04f34b409165c44082cbec502e807e0e44c58b4f1df5f6f SHA512 2c1a5d6ba3392444a25ca0488c8c0ebae4090b601276a17fdc01c64b70c22fa45b297c8784dbb7214865ceafe4b93bb166d3e84b170a5e1b21ff3811b59ab885 DIST coredns-1.10.1.tar.gz 632459 BLAKE2B ade57e2f7028cf4c3b69e08396a7cd41cde79c6f0b9b1edeb4c9e73204e9eab295d9b44dce437f337900ca6a622832c6f784f7088b2eed7ac6759e6959e587bd SHA512 6906ecf64b6274f4d3957faec6930ec3ed4de0bddd9e2d72ea2794f43186689ede1f440d7626c5ea66956fdec41e354242f99fa489f1f992b86fede5f580a328 +DIST coredns-1.11.1-deps.tar.xz 252844888 BLAKE2B c249a6d52965ac4a6b7e06343d5155e3bc6f0528c11556fda9eb111beec1b4a71ac1b7cc8c76d0c593fedddccf3d3808a0da8145555a804b0284557280bb8dab SHA512 0a22fa25cdbe5e8686612d411b59758ab604a3cf9a92a02eed7b5487506c25dee90c113dcb479fb9da199a31ead2c818ebe856f6f7182967ba13b9852d6e785a +DIST coredns-1.11.1.tar.gz 647236 BLAKE2B 0f2c58608a6a13b57c7df45a8f750ef5b9b6da4be4e5b593cb992141dc6d0e238121789e4ca0b430a100963c3bf08c0257506c812da776ea47a164f83b4fd0cc SHA512 f8752811e9e7913311f47ae13f35c755ac86ea240572be1c1dabc1712b6c42380c60ac385fa9573c77d6fcf4c144df2bc00574f18e8d7b70da21ed8ae4fb87cd diff --git a/net-dns/coredns/coredns-1.11.1.ebuild b/net-dns/coredns/coredns-1.11.1.ebuild new file mode 100644 index 000000000000..fe735f43702c --- /dev/null +++ b/net-dns/coredns/coredns-1.11.1.ebuild @@ -0,0 +1,123 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit fcaps go-module multiprocessing systemd tmpfiles toolchain-funcs + +DESCRIPTION="CoreDNS is a DNS server that chains plugins" +HOMEPAGE="https://github.com/coredns/coredns" + +if [[ ${PV} == 9999* ]]; then + inherit git-r3 + EGIT_REPO_URI="https://github.com/coredns/coredns.git" +else + SRC_URI="https://github.com/${PN}/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz" + SRC_URI+=" https://github.com/rahilarious/gentoo-distfiles/releases/download/${P}/deps.tar.xz -> ${P}-deps.tar.xz" + KEYWORDS="~amd64" +fi + +# main +LICENSE="Apache-2.0" +# deps +LICENSE+=" MIT BSD ISC MPL-2.0 BSD-2" + +SLOT="0" +IUSE="test" +# TODO: debug test failure with deps tarball +RESTRICT="test" + +RDEPEND="acct-user/coredns + acct-group/coredns" + +FILECAPS=( + -m 755 'cap_net_bind_service=+ep' usr/bin/${PN} +) + +PATCHES=( + "${FILESDIR}/buildopts-gitcommit-makefile-1.11.1.patch" +) + +src_unpack() { + if [[ ${PV} == *9999* ]]; then + git-r3_src_unpack + go-module_live_vendor + else + go-module_src_unpack + fi +} + +src_prepare() { + default + use test || sed -i -e 's|coredns: $(CHECKS)|coredns:|' Makefile +} + +src_compile() { + # For non-live versions, prevent git operations which causes sandbox violations + # https://github.com/gentoo/gentoo/pull/33531#issuecomment-1786107493 + [[ ${PV} != 9999* ]] && export GITCOMMIT='' + + # Mimicking go-module.eclass's GOFLAGS + if use amd64 || use arm || use arm64 || + ( use ppc64 && [[ $(tc-endian) == "little" ]] ) || use s390 || use x86; then + local buildmode="-buildmode=pie" + fi + export BUILDOPTS="-buildvcs=false -modcacherw -v -x -p=$(makeopts_jobs) ${buildmode}" + + default +} + +src_install() { + dobin "${PN}" + einstalldocs + doman man/* + + newinitd "${FILESDIR}"/coredns.initd coredns + newconfd "${FILESDIR}"/coredns.confd coredns + + insinto /etc/coredns/ + newins "${FILESDIR}"/Corefile.example Corefile + + insinto /etc/logrotate.d + newins "${FILESDIR}"/coredns.logrotated coredns + + systemd_dounit "${FILESDIR}"/coredns.service + newtmpfiles "${FILESDIR}"/coredns.tmpfiles "${PN}.conf" +} + +src_test() { + # eclass default '-x' makes tests output unreadable + export GOFLAGS="-v -mod=readonly" + + local known_fail=( + "TestZoneExternalCNAMELookupWithProxy" + "TestMetricsSeveralBlocs" + "TestMetricsAvailable" + "TestMetricsAvailableAfterReload" + "TestMetricsAvailableAfterReloadAndFailedReload" + ) + # concat as '|^Test1$|^Test2$|^Test3...$': + local known_fail_re="$(printf '|^%s$' "${known_fail[@]}")" + # drop '|' in the begining: + known_fail_re="${known_fail_re:1}" + + local working_tests_re="$( + # get list of all test: + { GOFLAGS="-mod=readonly" go test -list . ./... || + die "Can't get list of tests"; } | + # skip "no tests" messages as well as know failures: + grep -v -E " |${known_fail_re}" | + # format a regexp: + sed -z 's/\n/$|^/g' + )" + # drop '|^' in the end: + working_tests_re="^${working_tests_re::-2}" + + go test -race -run "${working_tests_re}" ./... || die "Tests failed" + go test -race -run "${known_fail_re}" ./... || ewarn "Known test failure" +} + +pkg_postinst() { + fcaps_pkg_postinst + tmpfiles_process ${PN}.conf +} diff --git a/net-dns/coredns/coredns-9999.ebuild b/net-dns/coredns/coredns-9999.ebuild new file mode 100644 index 000000000000..52c5778f1173 --- /dev/null +++ b/net-dns/coredns/coredns-9999.ebuild @@ -0,0 +1,119 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit fcaps go-module multiprocessing systemd tmpfiles toolchain-funcs + +DESCRIPTION="CoreDNS is a DNS server that chains plugins" +HOMEPAGE="https://github.com/coredns/coredns" + +if [[ ${PV} == 9999* ]]; then + inherit git-r3 + EGIT_REPO_URI="https://github.com/coredns/coredns.git" +else + SRC_URI="https://github.com/${PN}/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz" + SRC_URI+=" https://github.com/rahilarious/gentoo-distfiles/releases/download/${P}/deps.tar.xz -> ${P}-deps.tar.xz" + KEYWORDS="~amd64" +fi + +# main +LICENSE="Apache-2.0" +# deps +LICENSE+=" MIT BSD ISC MPL-2.0 BSD-2" + +SLOT="0" +IUSE="test" +# TODO: debug test failure with deps tarball +RESTRICT="test" + +RDEPEND="acct-user/coredns + acct-group/coredns" + +FILECAPS=( + -m 755 'cap_net_bind_service=+ep' usr/bin/${PN} +) + +src_unpack() { + if [[ ${PV} == *9999* ]]; then + git-r3_src_unpack + go-module_live_vendor + else + go-module_src_unpack + fi +} + +src_prepare() { + default + use test || sed -i -e 's|coredns: $(CHECKS)|coredns:|' Makefile +} + +src_compile() { + # For non-live versions, prevent git operations which causes sandbox violations + # https://github.com/gentoo/gentoo/pull/33531#issuecomment-1786107493 + [[ ${PV} != 9999* ]] && export GITCOMMIT='' + + # Mimicking go-module.eclass's GOFLAGS + if use amd64 || use arm || use arm64 || + ( use ppc64 && [[ $(tc-endian) == "little" ]] ) || use s390 || use x86; then + local buildmode="-buildmode=pie" + fi + export BUILDOPTS="-buildvcs=false -modcacherw -v -x -p=$(makeopts_jobs) ${buildmode}" + + default +} + +src_install() { + dobin "${PN}" + einstalldocs + doman man/* + + newinitd "${FILESDIR}"/coredns.initd coredns + newconfd "${FILESDIR}"/coredns.confd coredns + + insinto /etc/coredns/ + newins "${FILESDIR}"/Corefile.example Corefile + + insinto /etc/logrotate.d + newins "${FILESDIR}"/coredns.logrotated coredns + + systemd_dounit "${FILESDIR}"/coredns.service + newtmpfiles "${FILESDIR}"/coredns.tmpfiles "${PN}.conf" +} + +src_test() { + # eclass default '-x' makes tests output unreadable + export GOFLAGS="-v -mod=readonly" + + local known_fail=( + "TestZoneExternalCNAMELookupWithProxy" + "TestMetricsSeveralBlocs" + "TestMetricsAvailable" + "TestMetricsAvailableAfterReload" + "TestMetricsAvailableAfterReloadAndFailedReload" + ) + # concat as '|^Test1$|^Test2$|^Test3...$': + local known_fail_re="$(printf '|^%s$' "${known_fail[@]}")" + # drop '|' in the begining: + known_fail_re="${known_fail_re:1}" + + local working_tests_re="$( + # get list of all test: + { GOFLAGS="-mod=readonly" go test -list . ./... || + die "Can't get list of tests"; } | + # skip "no tests" messages as well as know failures: + grep -v -E " |${known_fail_re}" | + # format a regexp: + sed -z 's/\n/$|^/g' + )" + # drop '|^' in the end: + working_tests_re="^${working_tests_re::-2}" + + go test -race -run "${working_tests_re}" ./... || die "Tests failed" + go test -race -run "${known_fail_re}" ./... || ewarn "Known test failure" +} + +pkg_postinst() { + fcaps_pkg_postinst + tmpfiles_process ${PN}.conf +} diff --git a/net-dns/coredns/files/buildopts-gitcommit-makefile-1.11.1.patch b/net-dns/coredns/files/buildopts-gitcommit-makefile-1.11.1.patch new file mode 100644 index 000000000000..97dd658786e6 --- /dev/null +++ b/net-dns/coredns/files/buildopts-gitcommit-makefile-1.11.1.patch @@ -0,0 +1,29 @@ +# https://github.com/coredns/coredns/pull/6384 +From 81938bca2041c9dddc1171d56f609191313b8b9d Mon Sep 17 00:00:00 2001 +From: Rahil Bhimjiani +Date: Sun, 5 Nov 2023 21:53:05 +0530 +Subject: [PATCH] Makefile: allow to use custom GITCOMMIT & BUILDOPTS + +?= means If GITCOMMIT/BUILDOPTS is defined then use that otherwise fallback to default + +Signed-off-by: Rahil Bhimjiani +--- + Makefile | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/Makefile b/Makefile +index 43d03e207ba..10fca3da1a1 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,9 +1,9 @@ + # Makefile for building CoreDNS +-GITCOMMIT:=$(shell git describe --dirty --always) ++GITCOMMIT?=$(shell git describe --dirty --always) + BINARY:=coredns + SYSTEM:= + CHECKS:=check +-BUILDOPTS:=-v ++BUILDOPTS?=-v + GOPATH?=$(HOME)/go + MAKEPWD:=$(dir $(realpath $(firstword $(MAKEFILE_LIST)))) + CGO_ENABLED?=0 diff --git a/net-dns/coredns/files/coredns.service b/net-dns/coredns/files/coredns.service index eab9aede713e..fc2ec10c5c43 100644 --- a/net-dns/coredns/files/coredns.service +++ b/net-dns/coredns/files/coredns.service @@ -1,7 +1,9 @@ [Unit] Description=CoreDNS DNS server +Documentation=man:coredns(1) Documentation=https://coredns.io -After=network.target +After=network-online.target +Wants=network-online.target [Service] PermissionsStartOnly=true -- cgit v1.2.3-65-gdbad