1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
From: Peymaneh <peymaneh@posteo.net>
Date: Sat, 14 Jan 2023 17:54:50 +0100
Subject: Add variable for reproducible manpage time stamps
---
cmd/commands.go | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
--- a/cmd/commands.go
+++ b/cmd/commands.go
@@ -20,12 +20,21 @@
"os"
"regexp"
"strings"
+ "time"
"github.com/caddyserver/caddy/v2"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)
+// CustomDate will be used by the cobra manpage generator to generate a
+// reproducible timestamp. If the "Date" header passed to cobra is empty, it
+// will derive the time at build time, which is not reproducible.
+// can be passed to during `go build` with `-ldflags`:
+//
+// -ldflags '-X github.com/caddyserver/caddy/v2/cmd.CustomDate=DD.MM.YYYY'
+var CustomDate string
+
// Command represents a subcommand. Name, Func,
// and Short are required.
type Command struct {
@@ -339,6 +348,16 @@
if err := os.MkdirAll(dir, 0755); err != nil {
return caddy.ExitCodeFailedQuit, err
}
+ if CustomDate != "" {
+ date, _ := time.Parse(time.RFC3339, CustomDate)
+ if err := doc.GenManTree(rootCmd, &doc.GenManHeader{
+ Title: "Caddy",
+ Section: "8", // https://en.wikipedia.org/wiki/Man_page#Manual_sections
+ Date: &date,
+ }, dir); err != nil {
+ return caddy.ExitCodeFailedQuit, err
+ }
+ }
if err := doc.GenManTree(rootCmd, &doc.GenManHeader{
Title: "Caddy",
Section: "8", // https://en.wikipedia.org/wiki/Man_page#Manual_sections
|