summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRahil Bhimjiani <me@rahil.rocks>2024-02-08 19:35:29 +0530
committerZac Medico <zmedico@gentoo.org>2024-02-08 20:01:18 -0800
commitab49687466a4ae53cb5f4fc8d9590371b797ae7d (patch)
treea574d3c7a984dbffdfc320eaf0d8c718621d7a10 /www-servers/caddy/caddy-9999.ebuild
parentsci-mathematics/z3: Remove old (diff)
downloadgentoo-ab49687466a4ae53cb5f4fc8d9590371b797ae7d.tar.gz
gentoo-ab49687466a4ae53cb5f4fc8d9590371b797ae7d.tar.bz2
gentoo-ab49687466a4ae53cb5f4fc8d9590371b797ae7d.zip
www-servers/caddy: add new USE flag - events_handlers_exec
Compiles caddy with events.handlers.exec module[1] This module lets user 'exec'ute arbitrary command with args when some events occur in Caddy.[2] Example use: Run a script which notifies (via mail/telegram etc) web admin when some reverse_proxy's upstream becomes healthy/unhealthy or when something goes wrong while obtaining/renewing TLS certificate automatically. [1] https://caddyserver.com/docs/modules/events.handlers.exec [2] https://caddyserver.com/docs/caddyfile/options#event-options Signed-off-by: Rahil Bhimjiani <me@rahil.rocks> Closes: https://github.com/gentoo/gentoo/pull/35232 Signed-off-by: Zac Medico <zmedico@gentoo.org>
Diffstat (limited to 'www-servers/caddy/caddy-9999.ebuild')
-rw-r--r--www-servers/caddy/caddy-9999.ebuild49
1 files changed, 42 insertions, 7 deletions
diff --git a/www-servers/caddy/caddy-9999.ebuild b/www-servers/caddy/caddy-9999.ebuild
index 5657c0607730..daa4e4571bd8 100644
--- a/www-servers/caddy/caddy-9999.ebuild
+++ b/www-servers/caddy/caddy-9999.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2023 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
@@ -12,16 +12,23 @@ if [[ "${PV}" == 9999* ]]; then
inherit git-r3
EGIT_REPO_URI="https://github.com/caddyserver/caddy.git"
else
- SRC_URI="https://github.com/caddyserver/caddy/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"
- SRC_URI+=" https://github.com/caddyserver/dist/archive/refs/tags/v${PV}.tar.gz -> ${P}-docs.tar.gz"
+ SRC_URI="
+ https://github.com/caddyserver/caddy/archive/v${PV}.tar.gz -> ${P}.tar.gz
+ https://github.com/rahilarious/gentoo-distfiles/releases/download/${P}/deps.tar.xz -> ${P}-deps.tar.xz
+ https://github.com/caddyserver/dist/archive/refs/tags/v${PV}.tar.gz -> ${P}-docs.tar.gz
+"
KEYWORDS="~amd64 ~arm64 ~loong ~riscv"
fi
+# MAIN
LICENSE="Apache-2.0"
+# deps
LICENSE+=" BSD ECL-2.0 MIT CC0-1.0"
SLOT="0"
+
+IUSE='events-handlers-exec'
RESTRICT="test"
+
RDEPEND="
acct-user/http
acct-group/http"
@@ -35,12 +42,26 @@ PATCHES=(
"${FILESDIR}"/remove-binary-altering-commands-2.7.5.patch
)
+# takes a module as an only arg
+add_custom_module() {
+ local LINE_NO=$(grep -n 'plug in Caddy modules here' cmd/caddy/main.go | awk -F: '{print $1;}')
+ sed -i -e "${LINE_NO:?}a \ _ \"$1\"" cmd/caddy/main.go || die
+}
+
src_unpack() {
if [[ "${PV}" == 9999* ]]; then
- # unpack code
+ # clone main git repo
git-r3_src_unpack
- # unpack docs and misc
+ # get extra modules
+ if use events-handlers-exec; then
+ pushd "${P}"
+ add_custom_module 'github.com/mholt/caddy-events-exec' || die
+ ego get github.com/mholt/caddy-events-exec
+ popd
+ fi
+
+ # clone dist repo (docs and misc)
EGIT_REPO_URI="https://github.com/caddyserver/dist.git"
EGIT_CHECKOUT_DIR="${WORKDIR}/dist-${PV}"
git-r3_src_unpack
@@ -51,9 +72,23 @@ src_unpack() {
fi
}
-src_prepare(){
+src_prepare() {
default
sed -i -e "s|User=caddy|User=http|g;s|Group=caddy|Group=http|g;" ../dist-"${PV}"/init/*service || die
+
+ if use events-handlers-exec && [[ "${PV}" != 9999* ]]; then
+ add_custom_module 'github.com/mholt/caddy-events-exec' || die
+ cat <<-EOF >> go.sum || die
+ github.com/mholt/caddy-events-exec v0.0.0-20231121214933-055bfd2e8b82 h1:uRsPaFNQJRDrYcSsgnH0hFhCWFXfgB8QVH8yjX+u154=
+ github.com/mholt/caddy-events-exec v0.0.0-20231121214933-055bfd2e8b82/go.mod h1:Y9JjT8YLxpmk7PeUkvsWAhzzRdC6rXP7QjAHiwmvjD0=
+ EOF
+
+ cat <<-EOF >> go.mod || die
+ require (
+ github.com/mholt/caddy-events-exec v0.0.0-20231121214933-055bfd2e8b82 // indirect
+ )
+ EOF
+ fi
}
src_compile() {