diff options
Diffstat (limited to 'www-servers/caddy')
-rw-r--r-- | www-servers/caddy/Manifest | 3 | ||||
-rw-r--r-- | www-servers/caddy/caddy-2.7.5.ebuild | 98 | ||||
-rw-r--r-- | www-servers/caddy/caddy-9999.ebuild | 28 | ||||
-rw-r--r-- | www-servers/caddy/files/confd-2.7.5 | 5 | ||||
-rw-r--r-- | www-servers/caddy/files/initd-2.7.5 | 53 | ||||
-rw-r--r-- | www-servers/caddy/files/remove-binary-altering-commands-2.7.5.patch | 61 |
6 files changed, 240 insertions, 8 deletions
diff --git a/www-servers/caddy/Manifest b/www-servers/caddy/Manifest index 306f0fd1dbad..25194e18138c 100644 --- a/www-servers/caddy/Manifest +++ b/www-servers/caddy/Manifest @@ -7,3 +7,6 @@ DIST caddy-2.6.4.tar.gz 568213 BLAKE2B 4837c8511002538ed6d7ac92743a834e76bdba3a3 DIST caddy-2.7.4-deps.tar.xz 146920768 BLAKE2B 25d99c7d73f7c9a63868ab496f27571d15181cee298e16a83c02b652b8b89cab615969897d11faadfdc3e9ca389783c3b610e219a16b0a146748d0ea2e3309ca SHA512 5cdb95bcf7435a76385d0fc9277bdaa317261698f1bf15b54e081b89bd971927c0f5ca9f42a693127fabca9c6a6eae81978c6b4978ff9962f67a83591d104e6a DIST caddy-2.7.4-docs.tar.gz 25264 BLAKE2B 2282ac0ddd76b0837d33cf24d01f13ac9c0c8e0abf043cf5ade0ec3a51fda2d7c15589574b159df00e2c25733f10ccc6f4cf6b3a97f9f831aa276f3adee84fd9 SHA512 179a13b89b0da1771dcaf798e33000b60f202804e728d8aca85a23a68b055ee6d12e5f75eb30257a412621ffd105035bd371bd7e448f876eeb91544fd3092344 DIST caddy-2.7.4.tar.gz 625647 BLAKE2B be4749a2298d2e00e2a24324ee31090847be9ec4de49f47715c86e65750d01698b5a4a21990430cc7622fecce5b375ae8e3fb2ef832515ce9dcca8f2d26a9911 SHA512 e988ec4fa526d16b91a86f28fc13c606ab159815d5be45a2ea65bf91b5579a25efc8ff415b0aa98699f72bd3106ed02d49e48303d9c80e7fe6805ade416e7dff +DIST caddy-2.7.5-deps.tar.xz 161234532 BLAKE2B 130e3fd75d7d2976ef27c2afe0cede8da957ad1c8db7b2140ef69a732cf25c6a04bde43c836832a0f7c14dbb4ab9cd48b496b8ea644da411181ba79b4116d892 SHA512 3dcc834e8cc9851f114d173a812de4b3a5256f8458f2d20ed0c66109d1ede1ee8e1d85053347a194818495cdfcaab2bf86d1b12f94fe2f917e22bf25b8d9c411 +DIST caddy-2.7.5-docs.tar.gz 24578 BLAKE2B e08bfa37b157d8d4300198384bfc4c19cb0f539cc293311eaedcddffd4469026605c92f4388202db68beeadb2353666860daf3845ff5d69bb11afdb29eefe02b SHA512 635fdc1f2767cceacbddbbf56ba7207d558475c66ff9434a2b6edffd59d3711be0c6a4b4ffd2a6cf2eee53dcf22097c2b11eb44f0e9cc1d8455c1ea7c01bc498 +DIST caddy-2.7.5.tar.gz 611282 BLAKE2B 86c28922f80f931452e81b0c3fa52ed0b86b2325eb2a1adf1de830a7a339772063955fd3cb5ee888cbf8c1c905b98bb6a292b592a2983012ad4fefe33c361e82 SHA512 45f6790b7c3683a8001445e932d5678fd27d204500f7301d92c4d8421f24574e113bf7c335bd277b16abe07eb3d24258358f87c68cee38905fa6d0e6bcc1c24c diff --git a/www-servers/caddy/caddy-2.7.5.ebuild b/www-servers/caddy/caddy-2.7.5.ebuild new file mode 100644 index 000000000000..4940f75d7169 --- /dev/null +++ b/www-servers/caddy/caddy-2.7.5.ebuild @@ -0,0 +1,98 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit fcaps go-module systemd shell-completion + +DESCRIPTION="Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS" +HOMEPAGE="https://caddyserver.com" + +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" + KEYWORDS="~amd64 ~arm64 ~loong ~riscv" +fi + +LICENSE="Apache-2.0" +LICENSE+=" BSD ECL-2.0 MIT CC0-1.0" +SLOT="0" +RESTRICT="test" +RDEPEND=" + acct-user/http + acct-group/http" +DEPEND="${RDEPEND}" + +FILECAPS=( + -m 755 'cap_net_bind_service=+ep' usr/bin/"${PN}" +) + +PATCHES=( + "${FILESDIR}"/remove-binary-altering-commands-2.7.5.patch +) + +src_unpack() { + if [[ "${PV}" == *9999* ]]; then + # unpack code + git-r3_src_unpack + + # unpack docs and misc + EGIT_REPO_URI="https://github.com/caddyserver/dist.git" + EGIT_CHECKOUT_DIR="${WORKDIR}/dist-${PV}" + git-r3_src_unpack + + go-module_live_vendor + else + go-module_src_unpack + fi +} + +src_prepare(){ + default + sed -i -e "s|User=caddy|User=http|g;s|Group=caddy|Group=http|g;" ../dist-"${PV}"/init/*service || die +} + +src_compile() { + # https://github.com/caddyserver/caddy/blob/master/caddy.go#L843 + if [[ ${PV} == 9999* ]]; then + local CUSTOM_VER="git-$(git rev-parse --short HEAD)" + else + local CUSTOM_VER="${PV}" + fi + + ego build -ldflags "-X github.com/caddyserver/caddy/v2.CustomVersion=${CUSTOM_VER}" ./cmd/caddy + local sh + for sh in bash fish zsh; do + ./caddy completion "${sh}" > completion."${sh}" || die + done + ./caddy manpage -o manpages || die +} + +src_install() { + default + + dobin "${PN}" + insinto /etc/"${PN}" + doins ../dist-"${PV}"/config/Caddyfile + systemd_dounit ../dist-"${PV}"/init/*.service + newinitd "${FILESDIR}"/initd-2.7.5 "${PN}" + newconfd "${FILESDIR}"/confd-2.7.5 "${PN}" + insinto /etc/logrotate.d + newins "${FILESDIR}/logrotated" "${PN}" + insinto /usr/share/"${PN}" + doins ../dist-"${PV}"/welcome/index.html + + newbashcomp completion.bash "${PN}" + newfishcomp completion.fish "${PN}".fish + newzshcomp completion.zsh _"${PN}" + newdoc ../dist-"${PV}"/init/README.md systemd-services-README.md + doman manpages/* +} + +pkg_postinst() { + fcaps_pkg_postinst +} diff --git a/www-servers/caddy/caddy-9999.ebuild b/www-servers/caddy/caddy-9999.ebuild index e60c54e02eb3..4940f75d7169 100644 --- a/www-servers/caddy/caddy-9999.ebuild +++ b/www-servers/caddy/caddy-9999.ebuild @@ -13,12 +13,13 @@ if [[ "${PV}" == *9999* ]]; then 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://dev.gentoo.org/~williamh/dist/${P}-deps.tar.xz" + 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" KEYWORDS="~amd64 ~arm64 ~loong ~riscv" fi -LICENSE="Apache-2.0 BSD ECL-2.0 MIT CC0-1.0" +LICENSE="Apache-2.0" +LICENSE+=" BSD ECL-2.0 MIT CC0-1.0" SLOT="0" RESTRICT="test" RDEPEND=" @@ -30,6 +31,10 @@ FILECAPS=( -m 755 'cap_net_bind_service=+ep' usr/bin/"${PN}" ) +PATCHES=( + "${FILESDIR}"/remove-binary-altering-commands-2.7.5.patch +) + src_unpack() { if [[ "${PV}" == *9999* ]]; then # unpack code @@ -48,12 +53,19 @@ src_unpack() { src_prepare(){ default - sed -i -e "s|User=caddy|User=http|g;" ../dist-"${PV}"/init/*service || die - sed -i -e "s|Group=caddy|Group=http|g;" ../dist-"${PV}"/init/*service || die + sed -i -e "s|User=caddy|User=http|g;s|Group=caddy|Group=http|g;" ../dist-"${PV}"/init/*service || die } src_compile() { - ego build ./cmd/caddy + # https://github.com/caddyserver/caddy/blob/master/caddy.go#L843 + if [[ ${PV} == 9999* ]]; then + local CUSTOM_VER="git-$(git rev-parse --short HEAD)" + else + local CUSTOM_VER="${PV}" + fi + + ego build -ldflags "-X github.com/caddyserver/caddy/v2.CustomVersion=${CUSTOM_VER}" ./cmd/caddy + local sh for sh in bash fish zsh; do ./caddy completion "${sh}" > completion."${sh}" || die done @@ -65,10 +77,10 @@ src_install() { dobin "${PN}" insinto /etc/"${PN}" - newins ../dist-"${PV}"/config/Caddyfile Caddyfile.example + doins ../dist-"${PV}"/config/Caddyfile systemd_dounit ../dist-"${PV}"/init/*.service - newinitd "${FILESDIR}/initd" "${PN}" - newconfd "${FILESDIR}/confd" "${PN}" + newinitd "${FILESDIR}"/initd-2.7.5 "${PN}" + newconfd "${FILESDIR}"/confd-2.7.5 "${PN}" insinto /etc/logrotate.d newins "${FILESDIR}/logrotated" "${PN}" insinto /usr/share/"${PN}" diff --git a/www-servers/caddy/files/confd-2.7.5 b/www-servers/caddy/files/confd-2.7.5 new file mode 100644 index 000000000000..62cca711638a --- /dev/null +++ b/www-servers/caddy/files/confd-2.7.5 @@ -0,0 +1,5 @@ +# command_user="http:http" +# logfile="/var/log/caddy/caddy.log" +# +# caddy_config="/etc/caddy/Caddyfile" +# command_args="run --config ${caddy_config}" diff --git a/www-servers/caddy/files/initd-2.7.5 b/www-servers/caddy/files/initd-2.7.5 new file mode 100644 index 000000000000..408405c42a28 --- /dev/null +++ b/www-servers/caddy/files/initd-2.7.5 @@ -0,0 +1,53 @@ +#!/sbin/openrc-run +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +extra_commands="checkconfig" +extra_started_commands="reload" + +description="Caddy web server" +pidfile=${pidfile:-"/run/${RC_SVCNAME}.pid"} +command="/usr/bin/caddy" +command_user="${command_user:-"http:http"}" +caddy_config="${caddy_config:-"/etc/caddy/Caddyfile"}" +command_args="${command_args:-"run --config ${caddy_config}"}" +command_background="true" +logfile="${logfile:-"/var/log/${RC_SVCNAME}/${RC_SVCNAME}.log"}" +start_stop_daemon_args="--user ${command_user%:*} --group ${command_user#*:} + --stdout ${logfile} --stderr ${logfile}" + +: "${supervisor:=supervise-daemon}" +: "${respawn_delay:=5}" +: "${respawn_max:=10}" +: "${respawn_period:=60}" + +depend() { + need net +} + +checkconfig() { + if [ ! -f "${caddy_config}" ] ; then + ewarn "${caddy_config} does not exist." + return 1 + fi + "${command}" validate --config "${caddy_config}" >> "${logfile}" 2>&1 +} + +start() { + checkconfig || { eerror "Invalid configuration file !" && return 1; } + checkpath --directory --mode 755 --owner root "${pidfile%/*}" + checkpath --directory --mode 755 --owner "${command_user}" "${logfile%/*}" + default_start +} + +reload() { + if ! service_started "${SVCNAME}" ; then + eerror "${SVCNAME} isn't running" + return 1 + fi + checkconfig || { eerror "Invalid configuration file !" && return 1; } + + ebegin "Reloading ${SVCNAME}" + "${command}" reload --force --config "${caddy_config}" > /dev/null 2>&1 + eend $? +} diff --git a/www-servers/caddy/files/remove-binary-altering-commands-2.7.5.patch b/www-servers/caddy/files/remove-binary-altering-commands-2.7.5.patch new file mode 100644 index 000000000000..54d2c4d91df9 --- /dev/null +++ b/www-servers/caddy/files/remove-binary-altering-commands-2.7.5.patch @@ -0,0 +1,61 @@ +# Remove commands which can modify binary outside of Portage. +# Inspired from: +# https://src.fedoraproject.org/rpms/caddy/blob/rawhide/f/0001-Disable-commands-that-can-alter-the-binary.patch +# https://salsa.debian.org/go-team/packages/caddy/-/blob/debian/sid/debian/patches/0005-Remove-obsolote-subcommands.patch?ref_type=heads +--- a/cmd/commands.go ++++ a/cmd/commands.go +@@ -393,54 +393,10 @@ + cmd.RunE = WrapCommandFuncForCobra(cmdFmt) + }, + }) + + RegisterCommand(Command{ +- Name: "upgrade", +- Short: "Upgrade Caddy (EXPERIMENTAL)", +- Long: ` +-Downloads an updated Caddy binary with the same modules/plugins at the +-latest versions. EXPERIMENTAL: May be changed or removed. +-`, +- CobraFunc: func(cmd *cobra.Command) { +- cmd.Flags().BoolP("keep-backup", "k", false, "Keep the backed up binary, instead of deleting it") +- cmd.RunE = WrapCommandFuncForCobra(cmdUpgrade) +- }, +- }) +- +- RegisterCommand(Command{ +- Name: "add-package", +- Usage: "<packages...>", +- Short: "Adds Caddy packages (EXPERIMENTAL)", +- Long: ` +-Downloads an updated Caddy binary with the specified packages (module/plugin) +-added. Retains existing packages. Returns an error if the any of packages are +-already included. EXPERIMENTAL: May be changed or removed. +-`, +- CobraFunc: func(cmd *cobra.Command) { +- cmd.Flags().BoolP("keep-backup", "k", false, "Keep the backed up binary, instead of deleting it") +- cmd.RunE = WrapCommandFuncForCobra(cmdAddPackage) +- }, +- }) +- +- RegisterCommand(Command{ +- Name: "remove-package", +- Func: cmdRemovePackage, +- Usage: "<packages...>", +- Short: "Removes Caddy packages (EXPERIMENTAL)", +- Long: ` +-Downloads an updated Caddy binaries without the specified packages (module/plugin). +-Returns an error if any of the packages are not included. +-EXPERIMENTAL: May be changed or removed. +-`, +- CobraFunc: func(cmd *cobra.Command) { +- cmd.Flags().BoolP("keep-backup", "k", false, "Keep the backed up binary, instead of deleting it") +- cmd.RunE = WrapCommandFuncForCobra(cmdRemovePackage) +- }, +- }) +- +- RegisterCommand(Command{ + Name: "manpage", + Usage: "--directory <path>", + Short: "Generates the manual pages for Caddy commands", + Long: ` + Generates the manual pages for Caddy commands into the designated directory |