Skip to content

Commit da2b4a4

Browse files
authored
Merge pull request #1306 from cyphar/obey-source_date_epoch
man: obey SOURCE_DATE_EPOCH when generating man pages
2 parents 98cc7dc + 2635ccf commit da2b4a4

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

man/generate.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"log"
77
"os"
88
"path/filepath"
9+
"strconv"
10+
"time"
911

1012
"github.com/docker/cli/cli/command"
1113
"github.com/docker/cli/cli/command/commands"
@@ -24,6 +26,17 @@ func generateManPages(opts *options) error {
2426
Source: "Docker Community",
2527
}
2628

29+
// If SOURCE_DATE_EPOCH is set, in order to allow reproducible package
30+
// builds, we explicitly set the build time to SOURCE_DATE_EPOCH.
31+
if epoch := os.Getenv("SOURCE_DATE_EPOCH"); epoch != "" {
32+
unixEpoch, err := strconv.ParseInt(epoch, 10, 64)
33+
if err != nil {
34+
return fmt.Errorf("invalid SOURCE_DATE_EPOCH: %v", err)
35+
}
36+
now := time.Unix(unixEpoch, 0)
37+
header.Date = &now
38+
}
39+
2740
stdin, stdout, stderr := term.StdStreams()
2841
dockerCli := command.NewDockerCli(stdin, stdout, stderr, false, nil)
2942
cmd := &cobra.Command{Use: "docker"}

0 commit comments

Comments
 (0)