From 629424b5b4238b972c4f686aa3b098ec30da1d10 Mon Sep 17 00:00:00 2001 From: Patrick Pichler Date: Sun, 28 Feb 2021 17:54:10 +0100 Subject: [PATCH] caddy: upgrade to 2.3.0 As there is currently a bug with go build info a patch is needed to fix printing the correct version number of the binary. Once the bug is fixed, the patch can be dropped. Fixes #22092 --- srcpkgs/caddy/INSTALL | 3 +-- srcpkgs/caddy/INSTALL.md | 4 +++ srcpkgs/caddy/files/caddy/run | 6 ++--- .../caddy/patches/fix_version_command.patch | 25 +++++++++++++++++++ srcpkgs/caddy/template | 16 ++++++------ 5 files changed, 42 insertions(+), 12 deletions(-) create mode 100644 srcpkgs/caddy/INSTALL.md create mode 100644 srcpkgs/caddy/patches/fix_version_command.patch diff --git a/srcpkgs/caddy/INSTALL b/srcpkgs/caddy/INSTALL index db063595f43..03302bbf41d 100644 --- a/srcpkgs/caddy/INSTALL +++ b/srcpkgs/caddy/INSTALL @@ -1,6 +1,5 @@ case "${ACTION}" in post) - setcap CAP_NET_BIND_SERVICE=+ep usr/bin/caddy - chown -R caddy:caddy etc/caddy + setcap CAP_NET_BIND_SERVICE=+ep bin/caddy ;; esac diff --git a/srcpkgs/caddy/INSTALL.md b/srcpkgs/caddy/INSTALL.md new file mode 100644 index 00000000000..10ef8e8213f --- /dev/null +++ b/srcpkgs/caddy/INSTALL.md @@ -0,0 +1,4 @@ +WARNING: The config syntax has changed from caddy 1.x to 2.x + +Be sure to upgrade all your configuration files! + diff --git a/srcpkgs/caddy/files/caddy/run b/srcpkgs/caddy/files/caddy/run index ff0cc9c8030..80d9e10c5e1 100644 --- a/srcpkgs/caddy/files/caddy/run +++ b/srcpkgs/caddy/files/caddy/run @@ -2,7 +2,7 @@ [ -r ./conf ] && . ./conf -export CADDYPATH=/var/lib/caddy +export HOME=/var/lib/caddy ulimit -n ${MAX_OPEN_FILES:-8192} -cd /etc/caddy -exec chpst -u caddy caddy + +exec chpst -u caddy caddy run --environ --config /etc/caddy/Caddyfile diff --git a/srcpkgs/caddy/patches/fix_version_command.patch b/srcpkgs/caddy/patches/fix_version_command.patch new file mode 100644 index 00000000000..094d59b285a --- /dev/null +++ b/srcpkgs/caddy/patches/fix_version_command.patch @@ -0,0 +1,25 @@ +Return fake module info to show correct build version. + +TODO: remove once https://github.com/golang/go/issues/29228 is + fixed and replace with proper solution + +--- caddy.go ++++ caddy.go +@@ -554,18 +554,4 @@ +- bi, ok := debug.ReadBuildInfo() +- if ok { +- mod.Path = bi.Main.Path +- // The recommended way to build Caddy involves +- // creating a separate main module, which +- // TODO: track related Go issue: https://github.com/golang/go/issues/29228 +- // once that issue is fixed, we should just be able to use bi.Main... hopefully. +- for _, dep := range bi.Deps { +- if dep.Path == ImportPath { +- return dep +- } +- } +- return &bi.Main +- } +- return mod ++ return mod + } diff --git a/srcpkgs/caddy/template b/srcpkgs/caddy/template index 6fe986419c9..5737ce56a57 100644 --- a/srcpkgs/caddy/template +++ b/srcpkgs/caddy/template @@ -1,26 +1,28 @@ # Template file for 'caddy' pkgname=caddy -version=1.0.5 +version=2.3.0 revision=1 build_style=go -# XXX: use caddy/v2 when updating -go_import_path=github.com/caddyserver/caddy -go_package="${go_import_path}/caddy" +go_import_path=github.com/caddyserver/caddy/v2 +go_package="${go_import_path}/cmd/caddy" hostmakedepends="git" short_desc="Fast, cross-platform HTTP/2 web server with automatic HTTPS" maintainer="Dominic Monroe " license="Apache-2.0" homepage="https://caddyserver.com" distfiles="https://github.com/caddyserver/caddy/archive/v${version}.tar.gz" -checksum=0e7dc07e4f61f9a00a4c962755098e19ebf8c8a8e0d72e311597ce021b7a2a5e +checksum=4688b122ac05be39622aa81324d1635f1642e4a66d731e82d210aef78cf2766a system_accounts="caddy" +caddy_homedir="/var/lib/caddy" +caddy_descr="caddy daemon" + make_dirs=" /etc/caddy 0700 caddy caddy /var/lib/caddy 0700 caddy caddy" -pre_build() { - vsed -e 's,var EnableTelemetry = true,var EnableTelemetry = false,g' -i caddy/caddymain/run.go +post_extract() { + vsed -e "s,unknown,${version},g" -i ${wrksrc}/caddy.go } post_install() {