diff --git a/www/caddy/Makefile b/www/caddy/Makefile index 0e1e3bde8cfe..58338dfa1f1d 100644 --- a/www/caddy/Makefile +++ b/www/caddy/Makefile @@ -1,33 +1,36 @@ PORTNAME= caddy DISTVERSIONPREFIX= v DISTVERSION= 2.6.1 +PORTREVISION= 1 CATEGORIES= www DIST_SUBDIR= caddy MAINTAINER= adamw@FreeBSD.org COMMENT= Fast, cross-platform HTTP/2 web server with automatic HTTPS WWW= https://caddyserver.com LICENSE= APACHE20 LICENSE_FILE= ${WRKSRC}/LICENSE USES= cpe go:modules CPE_VENDOR= caddyserver USE_RC_SUBR= caddy SUB_FILES= Caddyfile.sample caddy pkg-message PLIST_FILES= bin/${PORTNAME} \ "@sample ${ETCDIR_REL}/Caddyfile.sample" +GO_BUILDFLAGS+= -ldflags='-X github.com/caddyserver/caddy/v2.VersionString=${DISTVERSIONFULL}' + GO_TARGET= ./cmd/caddy # If go.mod is sufficient: GO_MODULE= github.com/caddyserver/caddy/v2 # If modules must be specified manually: #.include "${.CURDIR}/modules.mk" post-install: ${MKDIR} ${STAGEDIR}${ETCDIR} ${INSTALL_DATA} ${WRKDIR}/Caddyfile.sample ${STAGEDIR}${ETCDIR} .include diff --git a/www/caddy/files/patch-caddy.go b/www/caddy/files/patch-caddy.go new file mode 100644 index 000000000000..bc79644ad6b7 --- /dev/null +++ b/www/caddy/files/patch-caddy.go @@ -0,0 +1,25 @@ +--- caddy.go.orig 2022-09-22 16:12:41 UTC ++++ caddy.go +@@ -824,6 +824,10 @@ func InstanceID() (uuid.UUID, error) { + return uuid.ParseBytes(uuidFileBytes) + } + ++// VersionString uses a predefined version string to short-circuit ++// the Version() function below, to simplify vendor packaging. ++var VersionString string ++ + // Version returns the Caddy version in a simple/short form, and + // a full version string. The short form will not have spaces and + // is intended for User-Agent strings and similar, but may be +@@ -841,6 +845,11 @@ func InstanceID() (uuid.UUID, error) { + // + // This function is experimental and subject to change or removal. + func Version() (simple, full string) { ++ // Use VersionString if provided (eg. through -ldflags -X) ++ if VersionString != "" { ++ return VersionString, VersionString ++ } ++ + // the currently-recommended way to build Caddy involves + // building it as a dependency so we can extract version + // information from go.mod tooling; once the upstream