From 535268cf855f292b6b92164a9e911541f44868f9 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Tue, 8 Aug 2017 09:40:44 -0700 Subject: [PATCH] update atlas-go to fix symlink-related packer push failures --- .../hashicorp/atlas-go/archive/archive.go | 45 +++++++------------ vendor/vendor.json | 6 +-- 2 files changed, 20 insertions(+), 31 deletions(-) diff --git a/vendor/github.com/hashicorp/atlas-go/archive/archive.go b/vendor/github.com/hashicorp/atlas-go/archive/archive.go index 0a025b21f..91310ad5a 100644 --- a/vendor/github.com/hashicorp/atlas-go/archive/archive.go +++ b/vendor/github.com/hashicorp/atlas-go/archive/archive.go @@ -372,6 +372,8 @@ func copyDirWalkFn( return filepath.Walk(target, copyDirWalkFn( tarW, target, subpath, opts, vcsInclude)) } + // return now so that we don't try to copy twice + return nil } return copyConcreteEntry(tarW, subpath, path, info) @@ -418,7 +420,7 @@ func copyConcreteEntry( if _, err = io.Copy(tarW, f); err != nil { return fmt.Errorf( - "failed copying file to archive: %s", path) + "failed copying file to archive: %s, %s", path, err) } return nil @@ -474,35 +476,22 @@ func copyExtras(w *tar.Writer, extra map[string]string) error { } func readLinkFull(path string, info os.FileInfo) (string, os.FileInfo, error) { - // Read the symlink continously until we reach a concrete file. - target := path - tries := 0 - for info.Mode()&os.ModeSymlink != 0 { - var err error - target, err = os.Readlink(target) - if err != nil { - return "", nil, err - } - if !filepath.IsAbs(target) { - target, err = filepath.Abs(target) - if err != nil { - return "", nil, err - } - } - info, err = os.Lstat(target) - if err != nil { - return "", nil, err - } - - tries++ - if tries > 100 { - return "", nil, fmt.Errorf( - "Symlink for %s is too deep, over 100 levels deep", - path) - } + target, err := filepath.EvalSymlinks(path) + if err != nil { + return "", nil, err } - return target, info, nil + target, err = filepath.Abs(target) + if err != nil { + return "", nil, err + } + + fi, err := os.Lstat(target) + if err != nil { + return "", nil, err + } + + return target, fi, nil } // readCloseRemover is an io.ReadCloser implementation that will remove diff --git a/vendor/vendor.json b/vendor/vendor.json index e1719e3e4..280a829b0 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -579,11 +579,11 @@ "revisionTime": "2017-06-23T01:44:30Z" }, { - "checksumSHA1": "FUiF2WLrih0JdHsUTMMDz3DRokw=", + "checksumSHA1": "izBSRxLAHN+a/XpAku0in05UzlY=", "comment": "20141209094003-92-g95fa852", "path": "github.com/hashicorp/atlas-go/archive", - "revision": "1792bd8de119ba49b17fd8d3c3c1f488ec613e62", - "revisionTime": "2016-11-07T20:49:10Z" + "revision": "17522f63497eefcffc90d528ca1eeaded2b529d3", + "revisionTime": "2017-08-08T16:18:53Z" }, { "checksumSHA1": "IR7S+SOsSUnPnLxgRrfemXfCqNM=",