From nobody Thu Sep 22 16:30:20 2022 X-Original-To: dev-commits-ports-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MYLNr3H2Bz4ckxq; Thu, 22 Sep 2022 16:30:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MYLNr2myHz3TPQ; Thu, 22 Sep 2022 16:30:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663864220; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cLjFi8HdAAYNuZx0mvbpcHOzhsuLHUbmn0C6dLWzjmY=; b=HIlWQ2UXbACb9MSkVR09D+U4aGlINVtulpGAcoGhFUykzzEs5SBC1/qM9s8SRdqS10uZG+ bcD0xiIzaGTcE2/UM0DZHPXcRJSlUg18aNeDXOe+DRWzHOPEvA0FaSl94R50iM2UiITuDd H8lQ14P5GOt2Vtbi7fgxKSJIGrs/o7phFZJ1NLIwF39ygCMdrgR4z/MpHv/FeLis9lkg0a Pc5+vFSnO5COqrdMtOHOjJCjOnatvvl8bsRyvzqQuDApsuPJrVC/w7yE9+f17uxMnhDwtH VfKs7F1aBhLeohOBlONpBO+2//49LG0M5Rj9QQCmX4hu7gSs3wt53O/YfmmPQg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MYLNr1rsWzShG; Thu, 22 Sep 2022 16:30:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 28MGUK4E070804; Thu, 22 Sep 2022 16:30:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28MGUKZ2070801; Thu, 22 Sep 2022 16:30:20 GMT (envelope-from git) Date: Thu, 22 Sep 2022 16:30:20 GMT Message-Id: <202209221630.28MGUKZ2070801@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Adam Weinberger Subject: git: 25057f927b52 - main - www/caddy: Provide a version string List-Id: Commit messages for all branches of the ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-all@freebsd.org X-BeenThere: dev-commits-ports-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: adamw X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 25057f927b52736d34e6d4e0c4cb43f47907b5de Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663864220; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cLjFi8HdAAYNuZx0mvbpcHOzhsuLHUbmn0C6dLWzjmY=; b=jpuvngAGx8r38Aa9pzhi+X0wvCMoDyTcrlStLhESg1pmIf/D+cbQ2X7qSgU20d0DmxUtWs LHrfAbVk2oc2CT5ElPOF4RTcUOpMmyBIkeKq/DBlTYXDvwklHmOICGT/klWHJkVe/o/v5q TF4DUBiKSNGMI+tLptCRJjbli3enC0tSP52slUJUxj4q0/5Rdb+VxqRL+hkW+ccHHoXbWd B2mz5LBOFU7TVl4THfoUPLG89wPgIjO3E4vOc14WIYF5K+1PGYZ78E7u4AXNDZVmzSFxPy EqX2uIYh0VjE8LBW9VDanlI97PRPQyB18zDwVlBBGXdqa05jlc2cgS0LColTIw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1663864220; a=rsa-sha256; cv=none; b=uZy+HyS/+lWEuk2BdDF0R8HmSnDL6tbk6Fpalhz2sSab/pIHDkZ48MauDFCwmqiTyO5cCH xMQ1gCUxG6yMrjWoawjcdn36Tti1nNx7g6YDaaYocx7OjqIOZb7uMWEgiTB0CrJn7IVSMM aHhXxI96/+vQTyZLhnyJqchtBnTALqE6oYhyLN02QOiKndrJ8/UhPlQpfGOqTFrA0gTpyq 1I6oL2TbJs7GV1GW6wtdpNGo7kkVpUnlrwz+nPnN/iE2Ar+C5I0F3yyjdmVYz2G6pQRvsX EzDaREnSUAJFORDK4DjVjtGcfOhFAkSISdhO6ALfDvXtoMXf0Z0MGbNZPB/RaA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by adamw: URL: https://cgit.FreeBSD.org/ports/commit/?id=25057f927b52736d34e6d4e0c4cb43f47907b5de commit 25057f927b52736d34e6d4e0c4cb43f47907b5de Author: Adam Weinberger AuthorDate: 2022-09-22 16:24:03 +0000 Commit: Adam Weinberger CommitDate: 2022-09-22 16:30:14 +0000 www/caddy: Provide a version string When build from ports, `caddy version` returns an empty string. Upstream likes caddy to be built from their xcaddy command, for which FreeBSD has a port (www/xcaddy) and a package (pkg install xcaddy). However, our package builders cannot use xcaddy itself, as it needs external network access. Caddy itself contains no ability to set the version without the extensive patching that xcaddy performs. This commit adds a version string to allow the version to be set. When built with xcaddy, the version string can contain a checksum of some sort, but we are just using ${DISTVERSIONFULL} here (e.g. v2.6.1). The lack of a version string has been brought up a number of times to me, so I'm happy to put this issue to bed. See https://github.com/caddyserver/caddy/issues/5065 for the latest discussion about it. --- www/caddy/Makefile | 3 +++ www/caddy/files/patch-caddy.go | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/www/caddy/Makefile b/www/caddy/Makefile index 0e1e3bde8cfe..58338dfa1f1d 100644 --- a/www/caddy/Makefile +++ b/www/caddy/Makefile @@ -1,6 +1,7 @@ PORTNAME= caddy DISTVERSIONPREFIX= v DISTVERSION= 2.6.1 +PORTREVISION= 1 CATEGORIES= www DIST_SUBDIR= caddy @@ -20,6 +21,8 @@ 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 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