Skip to content

Commit

Permalink
fix: rename to mtime
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Dec 6, 2023
1 parent c7c6539 commit 02b7c5a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
10 changes: 5 additions & 5 deletions arch/arch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions deb/deb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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),
}
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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
}
Expand Down
10 changes: 5 additions & 5 deletions nfpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:"-"`
}

Expand Down Expand Up @@ -478,7 +478,7 @@ func PrepareForPackager(info *Info, packager string) (err error) {
info.Umask,
packager,
info.DisableGlobbing,
info.Date,
info.MTime,
)

return err
Expand All @@ -503,7 +503,7 @@ func Validate(info *Info) (err error) {
info.Umask,
packager,
info.DisableGlobbing,
info.Date,
info.MTime,
)
if err != nil {
return err
Expand Down Expand Up @@ -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":
Expand Down
4 changes: 2 additions & 2 deletions nfpm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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,
},
Expand Down
4 changes: 2 additions & 2 deletions rpm/rpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion www/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 02b7c5a

Please sign in to comment.