commit:     455aae69ed201dcef931219a5b17cf3a82d5c01b
Author:     Rahil Bhimjiani <me <AT> rahil <DOT> rocks>
AuthorDate: Mon Jan  1 05:20:55 2024 +0000
Commit:     Florian Schmaus <flow <AT> gentoo <DOT> org>
CommitDate: Mon Jan  1 05:20:55 2024 +0000
URL:        https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=455aae69

net-dns/AdGuardHome: Pi-Hole alternative written in Go

offers following features which lack in Pi-hole
* Encrypted DNS upstream servers (DNS-over-HTTPS, DNS-over-TLS,
DNSCrypt)
* Running as a DNS-over-HTTPS or DNS-over-TLS server

Signed-off-by: Rahil Bhimjiani <me <AT> rahil.rocks>

 net-dns/AdGuardHome/AdGuardHome-0.107.43.ebuild    | 106 +++++++++++++++++++++
 net-dns/AdGuardHome/Manifest                       |   3 +
 .../AdGuardHome/files/AdGuardHome-0.107.43.service |  22 +++++
 net-dns/AdGuardHome/metadata.xml                   |  13 +++
 4 files changed, 144 insertions(+)

diff --git a/net-dns/AdGuardHome/AdGuardHome-0.107.43.ebuild 
b/net-dns/AdGuardHome/AdGuardHome-0.107.43.ebuild
new file mode 100644
index 0000000000..c1a9f54336
--- /dev/null
+++ b/net-dns/AdGuardHome/AdGuardHome-0.107.43.ebuild
@@ -0,0 +1,106 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit fcaps go-module systemd
+
+DESCRIPTION="Network-wide ads & trackers blocking DNS server like Pi-Hole with 
web ui"
+HOMEPAGE="https://github.com/AdguardTeam/AdGuardHome/";
+
+SRC_URI="
+       https://github.com/AdguardTeam/${PN}/archive/refs/tags/v${PV}.tar.gz -> 
${P}.tar.gz
+       
https://github.com/AdguardTeam/${PN}/releases/download/v${PV}/AdGuardHome_frontend.tar.gz
 -> ${P}-frontend.tar.gz
+       
https://github.com/rahilarious/gentoo-distfiles/releases/download/${P}/deps.tar.xz
 -> ${P}-deps.tar.xz
+"
+
+# main
+LICENSE="GPL-3"
+# deps
+LICENSE+=" Apache-2.0 BSD BSD-2 MIT ZLIB"
+
+SLOT="0"
+KEYWORDS="~amd64"
+
+FILECAPS=(
+       -m 755 'cap_net_bind_service=+eip cap_net_raw=+eip' usr/bin/${PN}
+)
+
+src_prepare() {
+       default
+       # move frontend to project directory
+       rm build/gitkeep && mv ../build ./ || die
+}
+
+src_compile() {
+       # mimicking 
https://github.com/AdguardTeam/AdGuardHome/blob/master/scripts/make/go-build.sh
+
+       local MY_LDFLAGS="-s -w"
+       MY_LDFLAGS+=" -X 
github.com/AdguardTeam/AdGuardHome/internal/version.version=${PV}"
+       MY_LDFLAGS+=" -X 
github.com/AdguardTeam/AdGuardHome/internal/version.channel=release"
+       MY_LDFLAGS+=" -X 
github.com/AdguardTeam/AdGuardHome/internal/version.committime=$(date +%s)"
+       if [ "$(go env GOARM)" != '' ]
+       then
+               MY_LDFLAGS+=" -X 
github.com/AdguardTeam/AdGuardHome/internal/version.goarm=$(go env GOARM)"
+       elif [ "$(go env GOMIPS)" != '' ]
+       then
+               MY_LDFLAGS+=" -X 
github.com/AdguardTeam/AdGuardHome/internal/version.gomips=$(go env GOMIPS)"
+       fi
+
+       ego build -ldflags "${MY_LDFLAGS}" -trimpath
+}
+
+src_test() {
+
+       # mimicking 
https://github.com/AdguardTeam/AdGuardHome/blob/master/scripts/make/go-test.sh
+       count_flags='--count=1'
+       cover_flags='--coverprofile=./coverage.txt'
+       shuffle_flags='--shuffle=on'
+       timeout_flags="--timeout=30s"
+       fuzztime_flags="--fuzztime=20s"
+       readonly count_flags cover_flags shuffle_flags timeout_flags 
fuzztime_flags
+
+       # race only works when pie is disabled
+       export GOFLAGS="${GOFLAGS/-buildmode=pie/}"
+
+       # following test is failing without giving any reason. Tried disabling 
internal/updater internal/whois tests toggling race, but still failing.
+       # ego test\
+       #         "$count_flags"\
+       #         "$cover_flags"\
+       #         "$shuffle_flags"\
+       #         --race=1\
+       #         "$timeout_flags"\
+       #         ./...
+
+       # mimicking 
https://github.com/AdguardTeam/AdGuardHome/blob/master/scripts/make/go-bench.sh
+       ego test\
+                 "$count_flags"\
+                 "$shuffle_flags"\
+                 --race=0\
+                 "$timeout_flags"\
+                 --bench='.'\
+                 --benchmem\
+                 --benchtime=1s\
+                 --run='^$'\
+                 ./...
+
+       # mimicking 
https://github.com/AdguardTeam/AdGuardHome/blob/master/scripts/make/go-fuzz.sh
+       ego test\
+                 "$count_flags"\
+                 "$shuffle_flags"\
+                 --race=0\
+                 "$timeout_flags"\
+                 "$fuzztime_flags"\
+                 --fuzz='.'\
+                 --run='^$'\
+                 ./internal/filtering/rulelist/\
+               ;
+
+}
+
+src_install() {
+       dobin "${PN}"
+       einstalldocs
+
+       systemd_newunit "${FILESDIR}"/AdGuardHome-0.107.43.service 
"${PN}".service
+}

diff --git a/net-dns/AdGuardHome/Manifest b/net-dns/AdGuardHome/Manifest
new file mode 100644
index 0000000000..ced137539c
--- /dev/null
+++ b/net-dns/AdGuardHome/Manifest
@@ -0,0 +1,3 @@
+DIST AdGuardHome-0.107.43-deps.tar.xz 104529544 BLAKE2B 
4fde3b1e2f85cf85209eb2149c40a5478e4d55cbae90847fafdb5f056b7af2a8234a5880fac6bbed1b62e64d7e849162abbc9e5fef3b262ecea8760fcb21c21c
 SHA512 
44458c3d1d46c7ccf50308227ff765927e1b6d4876065af13004bd0ec2c82c7727e76a81bfc52cf920ea2dee361e5c761db73ed610d04b23568c6e7611301348
+DIST AdGuardHome-0.107.43-frontend.tar.gz 2781809 BLAKE2B 
72d42f40a5f671f5dab72a7fcbd77fdfbd58126b67c73fd6e1dbec5f956c017ff64c01cb8c89ec5c72ef2058640e7cea5b93fe1b3c2c7b76edc6de32ab7f4801
 SHA512 
1c1fd527638c3e35fa21b5738868dae04b41a0bbb04942c94cc36d1dc7f6961bd202c7862fdfffe3ed52039c75b3f358e399c17ccd121e78432ec58fa837f4a0
+DIST AdGuardHome-0.107.43.tar.gz 2227903 BLAKE2B 
a4811969b2e156a33d6267edeca4be3535e095e8133c6c8d761e132e5f95d21403df37f8ac5567d85994b89ff8912f1799f21f648d6a26a6bf7971d02bd11ffd
 SHA512 
cc9f7602ada6e40ff7c8449bfc1c40fb184c848019ff95b1db46a974f4a72606c587015d440e25094c51cc0b6d01eb68686765d0a92f01752615db63e4527803

diff --git a/net-dns/AdGuardHome/files/AdGuardHome-0.107.43.service 
b/net-dns/AdGuardHome/files/AdGuardHome-0.107.43.service
new file mode 100644
index 0000000000..2311ee1497
--- /dev/null
+++ b/net-dns/AdGuardHome/files/AdGuardHome-0.107.43.service
@@ -0,0 +1,22 @@
+# This unit is inspired from
+# `AdGuardHome -s install` on systemd machine and
+# https://aur.archlinux.org/cgit/aur.git/tree/adguardhome.service?h=adguardhome
+
+[Unit]
+Description=Network-wide ads & trackers blocking DNS server with WebUI
+After=network-online.target
+ConditionFileIsExecutable=/usr/bin/AdGuardHome
+
+[Service]
+StartLimitInterval=5
+StartLimitBurst=10
+DynamicUser=true
+StateDirectory=AdGuardHome
+WorkingDirectory=/var/lib/AdGuardHome
+AmbientCapabilities=CAP_NET_BIND_SERVICE CAP_NET_RAW
+CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_NET_RAW
+ExecStart=/usr/bin/AdGuardHome --no-check-update --work-dir 
/var/lib/AdGuardHome
+ExecReload=/usr/bin/kill -HUP $MAINPID
+
+[Install]
+WantedBy=multi-user.target

diff --git a/net-dns/AdGuardHome/metadata.xml b/net-dns/AdGuardHome/metadata.xml
new file mode 100644
index 0000000000..2aeba77180
--- /dev/null
+++ b/net-dns/AdGuardHome/metadata.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd";>
+<pkgmetadata>
+  <maintainer type="person">
+    <email>[email protected]</email>
+    <name>Rahil Bhimjiani</name>
+  </maintainer>
+  <upstream>
+    <remote-id type="github">AdguardTeam/AdGuardHome</remote-id>
+    <bugs-to>https://github.com/AdguardTeam/AdGuardHome/issues</bugs-to>
+    <doc>https://github.com/AdguardTeam/AdGuardHome/</doc>
+  </upstream>
+</pkgmetadata>

Reply via email to