From 02b7c5a7b582c161a5667db63d3f96fd8e0b0377 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 5 Dec 2023 23:36:52 -0300 Subject: [PATCH] fix: rename to mtime --- arch/arch.go | 10 +++++----- deb/deb.go | 22 +++++++++++----------- nfpm.go | 10 +++++----- nfpm_test.go | 4 ++-- rpm/rpm.go | 4 ++-- www/docs/configuration.md | 2 +- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/arch/arch.go b/arch/arch.go index 4e91862d..a2959f01 100644 --- a/arch/arch.go +++ b/arch/arch.go @@ -151,7 +151,7 @@ func (ArchLinux) Package(info *nfpm.Info, w io.Writer) error { // .PKGINFO must be the first entry in .MTREE entries = append([]MtreeEntry{*pkginfoEntry}, entries...) - err = createMtree(tw, entries, info.Date) + err = createMtree(tw, entries, info.MTime) if err != nil { return fmt.Errorf("create mtree: %w", err) } @@ -311,7 +311,7 @@ func createPkginfo(info *nfpm.Info, tw *tar.Writer, totalSize int64) (*MtreeEntr return nil, err } - builddate := strconv.FormatInt(info.Date.Unix(), 10) + builddate := strconv.FormatInt(info.MTime.Unix(), 10) totalSizeStr := strconv.FormatInt(totalSize, 10) err = writeKVPairs(buf, map[string]string{ @@ -376,7 +376,7 @@ func createPkginfo(info *nfpm.Info, tw *tar.Writer, totalSize int64) (*MtreeEntr Mode: 0o644, Name: ".PKGINFO", Size: int64(size), - ModTime: info.Date, + ModTime: info.MTime, }) if err != nil { return nil, err @@ -395,7 +395,7 @@ func createPkginfo(info *nfpm.Info, tw *tar.Writer, totalSize int64) (*MtreeEntr return &MtreeEntry{ Destination: ".PKGINFO", - Time: info.Date.Unix(), + Time: info.MTime.Unix(), Mode: 0o644, Size: int64(size), Type: files.TypeFile, @@ -562,7 +562,7 @@ func createScripts(info *nfpm.Info, tw *tar.Writer) error { Mode: 0o644, Name: ".INSTALL", Size: int64(buf.Len()), - ModTime: info.Date, + ModTime: info.MTime, }) if err != nil { return err diff --git a/deb/deb.go b/deb/deb.go index 79c2cb04..ffc2a55f 100644 --- a/deb/deb.go +++ b/deb/deb.go @@ -125,15 +125,15 @@ func (d *Deb) Package(info *nfpm.Info, deb io.Writer) (err error) { // nolint: f return fmt.Errorf("cannot write ar header to deb file: %w", err) } - if err := addArFile(w, "debian-binary", debianBinary, info.Date); err != nil { + if err := addArFile(w, "debian-binary", debianBinary, info.MTime); err != nil { return fmt.Errorf("cannot pack debian-binary: %w", err) } - if err := addArFile(w, "control.tar.gz", controlTarGz, info.Date); err != nil { + if err := addArFile(w, "control.tar.gz", controlTarGz, info.MTime); err != nil { return fmt.Errorf("cannot add control.tar.gz to deb: %w", err) } - if err := addArFile(w, dataTarballName, dataTarball, info.Date); err != nil { + if err := addArFile(w, dataTarballName, dataTarball, info.MTime); err != nil { return fmt.Errorf("cannot add data.tar.gz to deb: %w", err) } @@ -143,7 +143,7 @@ func (d *Deb) Package(info *nfpm.Info, deb io.Writer) (err error) { // nolint: f return err } - if err := addArFile(w, "_gpg"+sigType, sig, info.Date); err != nil { + if err := addArFile(w, "_gpg"+sigType, sig, info.MTime); err != nil { return &nfpm.ErrSigningFailure{ Err: fmt.Errorf("add signature to ar file: %w", err), } @@ -255,7 +255,7 @@ func newDpkgSigFileLine(name string, fileContent []byte) dpkgSigFileLine { func readDpkgSigData(info *nfpm.Info, debianBinary, controlTarGz, dataTarball []byte) (io.Reader, error) { data := dpkgSigData{ Signer: info.Deb.Signature.Signer, - Date: info.Date, + Date: info.MTime, Role: info.Deb.Signature.Type, Files: []dpkgSigFileLine{ newDpkgSigFileLine("debian-binary", debianBinary), @@ -510,7 +510,7 @@ func createChangelogInsideDataTar( return 0, err } - if err = newFileInsideTar(tarw, fileName, changelogData, info.Date); err != nil { + if err = newFileInsideTar(tarw, fileName, changelogData, info.MTime); err != nil { return 0, err } @@ -554,18 +554,18 @@ func createControl(instSize int64, md5sums []byte, info *nfpm.Info) (controlTarG return nil, err } - if err := newFileInsideTar(out, "./control", body.Bytes(), info.Date); err != nil { + if err := newFileInsideTar(out, "./control", body.Bytes(), info.MTime); err != nil { return nil, err } - if err := newFileInsideTar(out, "./md5sums", md5sums, info.Date); err != nil { + if err := newFileInsideTar(out, "./md5sums", md5sums, info.MTime); err != nil { return nil, err } - if err := newFileInsideTar(out, "./conffiles", conffiles(info), info.Date); err != nil { + if err := newFileInsideTar(out, "./conffiles", conffiles(info), info.MTime); err != nil { return nil, err } if triggers := createTriggers(info); len(triggers) > 0 { - if err := newFileInsideTar(out, "./triggers", triggers, info.Date); err != nil { + if err := newFileInsideTar(out, "./triggers", triggers, info.MTime); err != nil { return nil, err } } @@ -612,7 +612,7 @@ func createControl(instSize int64, md5sums []byte, info *nfpm.Info) (controlTarG path, destMode.fileName, destMode.mode, - info.Date, + info.MTime, ); err != nil { return nil, err } diff --git a/nfpm.go b/nfpm.go index 1d7a9343..9181034d 100644 --- a/nfpm.go +++ b/nfpm.go @@ -275,7 +275,7 @@ type Info struct { License string `yaml:"license,omitempty" json:"license,omitempty" jsonschema:"title=package license,example=MIT"` Changelog string `yaml:"changelog,omitempty" json:"changelog,omitempty" jsonschema:"title=package changelog,example=changelog.yaml,description=see https://github.com/goreleaser/chglog for more details"` DisableGlobbing bool `yaml:"disable_globbing,omitempty" json:"disable_globbing,omitempty" jsonschema:"title=whether to disable file globbing,default=false"` - Date time.Time `yaml:"time,omitempty" json:"time,omitempty" jsonschema:"title=time to set into the files generated by nFPM,default=$SOURCE_DATE_EPOCH"` + MTime time.Time `yaml:"mtime,omitempty" json:"mtime,omitempty" jsonschema:"title=time to set into the files generated by nFPM"` Target string `yaml:"-" json:"-"` } @@ -478,7 +478,7 @@ func PrepareForPackager(info *Info, packager string) (err error) { info.Umask, packager, info.DisableGlobbing, - info.Date, + info.MTime, ) return err @@ -503,7 +503,7 @@ func Validate(info *Info) (err error) { info.Umask, packager, info.DisableGlobbing, - info.Date, + info.MTime, ) if err != nil { return err @@ -536,8 +536,8 @@ func WithDefaults(info *Info) *Info { if info.Umask == 0 { info.Umask = 0o02 } - if info.Date.IsZero() { - info.Date = getSourceDateEpoch() + if info.MTime.IsZero() { + info.MTime = getSourceDateEpoch() } switch info.VersionSchema { case "none": diff --git a/nfpm_test.go b/nfpm_test.go index 50d947ed..002725d3 100644 --- a/nfpm_test.go +++ b/nfpm_test.go @@ -100,7 +100,7 @@ func TestDefaults(t *testing.T) { Version: "2.4.1", Description: "no description given", Arch: "arm64", - Date: mtime, + MTime: mtime, Overridables: nfpm.Overridables{ Umask: 0o112, }, @@ -119,7 +119,7 @@ func TestDefaults(t *testing.T) { Version: "0.0.0", Prerelease: "rc0", Description: "no description given", - Date: mtime, + MTime: mtime, Overridables: nfpm.Overridables{ Umask: 0o002, }, diff --git a/rpm/rpm.go b/rpm/rpm.go index 05b11db1..b07cf156 100644 --- a/rpm/rpm.go +++ b/rpm/rpm.go @@ -256,7 +256,7 @@ func buildRPMMeta(info *nfpm.Info) (*rpmpack.RPMMetaData, error) { Suggests: suggests, Conflicts: conflicts, Compressor: info.RPM.Compression, - BuildTime: info.Date, + BuildTime: info.MTime, BuildHost: hostname, }, nil } @@ -372,7 +372,7 @@ func createFilesInsideRPM(info *nfpm.Info, rpm *rpmpack.RPM) (err error) { case files.TypeSymlink: file = asRPMSymlink(content) case files.TypeDir: - file = asRPMDirectory(content, info.Date) + file = asRPMDirectory(content, info.MTime) case files.TypeImplicitDir: // we don't need to add imlicit directories to RPMs continue diff --git a/www/docs/configuration.md b/www/docs/configuration.md index 06320569..b7abfbf1 100644 --- a/www/docs/configuration.md +++ b/www/docs/configuration.md @@ -105,7 +105,7 @@ license: MIT # Default is the value of $SOURCE_DATE_EPOCH (which should be an Unix time), # or the current time. # Read more about SOURCE_DATE_EPOCH at https://reproducible-builds.org/docs/source-date-epoch/ -date: "2009-11-10T23:00:00Z" +mtime: "2009-11-10T23:00:00Z" # Changelog YAML file, see: https://github.com/goreleaser/chglog changelog: "changelog.yaml"