public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: www-servers/caddy/
Date: Fri,  9 Feb 2024 05:08:11 +0000 (UTC)	[thread overview]
Message-ID: <1707451278.ab49687466a4ae53cb5f4fc8d9590371b797ae7d.zmedico@gentoo> (raw)

commit:     ab49687466a4ae53cb5f4fc8d9590371b797ae7d
Author:     Rahil Bhimjiani <me <AT> rahil <DOT> rocks>
AuthorDate: Thu Feb  8 14:05:29 2024 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Feb  9 04:01:18 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ab496874

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 <AT> rahil.rocks>
Closes: https://github.com/gentoo/gentoo/pull/35232
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 www-servers/caddy/Manifest                         |  1 +
 .../{caddy-9999.ebuild => caddy-2.7.6-r1.ebuild}   | 49 ++++++++++++++++++----
 www-servers/caddy/caddy-9999.ebuild                | 49 ++++++++++++++++++----
 www-servers/caddy/metadata.xml                     |  7 ++++
 4 files changed, 92 insertions(+), 14 deletions(-)

diff --git a/www-servers/caddy/Manifest b/www-servers/caddy/Manifest
index 73698a62c2e7..da79d9aa35ce 100644
--- a/www-servers/caddy/Manifest
+++ b/www-servers/caddy/Manifest
@@ -6,4 +6,5 @@ DIST caddy-2.7.5-docs.tar.gz 24578 BLAKE2B e08bfa37b157d8d4300198384bfc4c19cb0f5
 DIST caddy-2.7.5.tar.gz 611282 BLAKE2B 86c28922f80f931452e81b0c3fa52ed0b86b2325eb2a1adf1de830a7a339772063955fd3cb5ee888cbf8c1c905b98bb6a292b592a2983012ad4fefe33c361e82 SHA512 45f6790b7c3683a8001445e932d5678fd27d204500f7301d92c4d8421f24574e113bf7c335bd277b16abe07eb3d24258358f87c68cee38905fa6d0e6bcc1c24c
 DIST caddy-2.7.6-deps.tar.xz 128958740 BLAKE2B ffbe682df64a88dac9f50e9712f1d6697e58f2d9854c270321f7a0325f0b5ead7f93316756136a4435b70c5e08742c7130ce507ee4aa4696f4fb906f4eba8754 SHA512 f467144e235e09a7718cffe5ed3c40ec2d63038a6a948fe4f85d34717877af8a9959ef7e2c3ac32fd0cce522d693ccac883877f061f5cefc9512f7eed556b336
 DIST caddy-2.7.6-docs.tar.gz 24583 BLAKE2B d3dbbb701d86cbfaf538f10911fdd3613b8c3c0f49ef9e229487d2a4fcef9eff79b56e9852d5c1ccd5a8d1d1898861fc8183c343c129901562b03a9092af9e61 SHA512 62e534d41e714b47265fd8089ad9e03a1a89903460976d8af27fa5f71173e076bab8574282213595e495be701b769e1a70ff9e7ec9576fbf8e821e672207faa5
+DIST caddy-2.7.6-r1-deps.tar.xz 129331604 BLAKE2B 50b83c012c70637936c83ec765758cdcd80014ca224d76a746de8640a6b36ae15ce11ec57d9fdb20a5f7b3add946209c6dde7bb4e4bd4a47ffe3ffc8971725db SHA512 a4bc56de4f7ec8e9967dde3d7ca4cbb74cba9ce0b8906ffe16f8dae3f52fff1164827942df8154eadbae80cce3ee603535b9135cf8a5126d84a9017e8aece078
 DIST caddy-2.7.6.tar.gz 606077 BLAKE2B 1237edc164ec6095c9dff27c332925c4ce9d91a60e629770463bbffb1503b8b11e36033e852df3eb5bb69ffa448833b6ee2891dc0ba6dc9b43b6cce27d492179 SHA512 ef0cb6fd7f6f2a296290b4bb520300e043ad31cc612e734632ffa25cdaa23fd7d601ac4ceaa1c76285d54a07ee773360f795103ef3c2ec79516a4f18a5e844b5

diff --git a/www-servers/caddy/caddy-9999.ebuild b/www-servers/caddy/caddy-2.7.6-r1.ebuild
similarity index 59%
copy from www-servers/caddy/caddy-9999.ebuild
copy to www-servers/caddy/caddy-2.7.6-r1.ebuild
index 5657c0607730..c9b5a47b3c6f 100644
--- a/www-servers/caddy/caddy-9999.ebuild
+++ b/www-servers/caddy/caddy-2.7.6-r1.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/${PF}/deps.tar.xz -> ${PF}-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() {

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() {

diff --git a/www-servers/caddy/metadata.xml b/www-servers/caddy/metadata.xml
index 94c564bbfc25..ede41c6d550d 100644
--- a/www-servers/caddy/metadata.xml
+++ b/www-servers/caddy/metadata.xml
@@ -13,6 +13,13 @@
     <email>proxy-maint@gentoo.org</email>
     <name>Proxy Maintainers</name>
   </maintainer>
+  <use>
+    <flag name="events-handlers-exec">
+      Builds a module which lets user exec command on Caddy events
+      https://caddyserver.com/docs/modules/events.handlers.exec
+      https://caddyserver.com/docs/caddyfile/options#event-options
+    </flag>
+  </use>
   <upstream>
     <remote-id type="github">caddyserver/caddy</remote-id>
     <bugs-to>https://github.com/caddyserver/caddy/issues</bugs-to>


             reply	other threads:[~2024-02-09  5:08 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-09  5:08 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-06-29  3:15 [gentoo-commits] repo/gentoo:master commit in: www-servers/caddy/ Zac Medico
2024-06-29  3:15 Zac Medico
2024-06-29  3:15 Zac Medico
2024-06-16 23:07 Zac Medico
2024-05-13 12:37 Arthur Zamarin
2024-05-12 22:05 Zac Medico
2024-05-12 22:05 Zac Medico
2024-05-11 15:16 Arthur Zamarin
2024-04-14 20:50 Zac Medico
2024-03-16 22:44 Zac Medico
2024-03-16 22:44 Zac Medico
2024-03-15 16:13 Arthur Zamarin
2024-03-15 15:37 Arthur Zamarin
2024-02-09  5:08 Zac Medico
2024-01-12  6:43 Joonas Niilola
2024-01-11 18:32 Sam James
2023-12-10 22:54 Zac Medico
2023-12-10 22:54 Zac Medico
2023-11-24 20:38 Sam James
2023-10-31 17:19 Mike Gilbert
2023-10-30  2:07 Zac Medico
2023-10-30  2:07 Zac Medico
2023-09-29  7:27 WANG Xuerui
2023-09-29  7:27 WANG Xuerui
2023-09-25  4:08 Zac Medico
2023-09-08 14:10 William Hubbs
2023-09-07 20:31 William Hubbs
2023-04-30 23:50 Sam James
2023-02-21  0:28 Zac Medico
2022-10-14  1:21 Zac Medico
2022-09-15  4:20 Zac Medico
2022-07-23  0:54 Zac Medico
2022-07-23  0:54 Zac Medico
2022-07-15 17:43 Zac Medico
2022-06-03  2:09 Zac Medico
2022-06-03  2:09 Zac Medico
2022-05-15 22:07 Zac Medico
2022-05-15 22:07 Zac Medico
2022-05-12  0:02 William Hubbs
2022-05-08 16:37 Zac Medico
2022-05-07 16:44 Zac Medico
2022-05-07 16:36 Zac Medico
2022-03-18  4:40 Zac Medico
2022-03-18  4:23 Zac Medico
2021-11-08 22:32 Zac Medico
2021-10-20  3:02 Zac Medico
2021-09-01 16:42 William Hubbs
2021-06-14 17:30 Zac Medico
2021-06-14 17:21 Zac Medico
2021-04-05 16:55 Zac Medico
2021-04-04 10:26 Zac Medico
2021-04-04 10:25 Zac Medico
2021-04-04 10:21 Zac Medico
2021-01-18  9:28 Joonas Niilola
2020-10-26 13:16 Joonas Niilola
2020-07-12 18:58 William Hubbs
2020-06-22 15:48 William Hubbs
2019-09-11 16:21 Michał Górny
2019-02-07 10:53 Manuel Rüger
2018-08-20 14:54 Manuel Rüger
2018-07-01 16:41 Sebastian Pipping
2018-02-21 14:33 Manuel Rüger
2018-02-21 14:33 Manuel Rüger
2017-10-09 14:07 Manuel Rüger
2017-09-18 11:08 Manuel Rüger
2017-09-14 13:14 Manuel Rüger
2017-09-10 10:49 Manuel Rüger
2017-09-08 22:02 Manuel Rüger
2017-08-12 12:25 Manuel Rüger
2017-08-01 12:31 Manuel Rüger
2017-08-01 12:30 Manuel Rüger
2017-07-19 14:56 Manuel Rüger
2017-05-16 20:34 Manuel Rüger
2017-04-21 15:03 Manuel Rüger
2017-03-13 15:49 Manuel Rüger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1707451278.ab49687466a4ae53cb5f4fc8d9590371b797ae7d.zmedico@gentoo \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox