Merge pull request #1306 from cyphar/obey-source_date_epoch

man: obey SOURCE_DATE_EPOCH when generating man pages
This commit is contained in:
Vincent Demeester 2018-11-29 09:49:44 +01:00 committed by GitHub
commit f64dc97aca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -6,6 +6,8 @@ import (
"log"
"os"
"path/filepath"
"strconv"
"time"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/commands"
@ -24,6 +26,17 @@ func generateManPages(opts *options) error {
Source: "Docker Community",
}
// If SOURCE_DATE_EPOCH is set, in order to allow reproducible package
// builds, we explicitly set the build time to SOURCE_DATE_EPOCH.
if epoch := os.Getenv("SOURCE_DATE_EPOCH"); epoch != "" {
unixEpoch, err := strconv.ParseInt(epoch, 10, 64)
if err != nil {
return fmt.Errorf("invalid SOURCE_DATE_EPOCH: %v", err)
}
now := time.Unix(unixEpoch, 0)
header.Date = &now
}
stdin, stdout, stderr := term.StdStreams()
dockerCli := command.NewDockerCli(stdin, stdout, stderr, false, nil)
cmd := &cobra.Command{Use: "docker"}