Merge pull request #5226 from hashicorp/2433_symlinks

update atlas-go to fix symlink-related packer push failures
This commit is contained in:
Matthew Hooker 2017-08-08 11:49:42 -07:00 committed by GitHub
commit f2a47a581d
2 changed files with 20 additions and 31 deletions

View File

@ -372,6 +372,8 @@ func copyDirWalkFn(
return filepath.Walk(target, copyDirWalkFn( return filepath.Walk(target, copyDirWalkFn(
tarW, target, subpath, opts, vcsInclude)) tarW, target, subpath, opts, vcsInclude))
} }
// return now so that we don't try to copy twice
return nil
} }
return copyConcreteEntry(tarW, subpath, path, info) return copyConcreteEntry(tarW, subpath, path, info)
@ -418,7 +420,7 @@ func copyConcreteEntry(
if _, err = io.Copy(tarW, f); err != nil { if _, err = io.Copy(tarW, f); err != nil {
return fmt.Errorf( return fmt.Errorf(
"failed copying file to archive: %s", path) "failed copying file to archive: %s, %s", path, err)
} }
return nil 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) { func readLinkFull(path string, info os.FileInfo) (string, os.FileInfo, error) {
// Read the symlink continously until we reach a concrete file. target, err := filepath.EvalSymlinks(path)
target := path
tries := 0
for info.Mode()&os.ModeSymlink != 0 {
var err error
target, err = os.Readlink(target)
if err != nil { if err != nil {
return "", nil, err return "", nil, err
} }
if !filepath.IsAbs(target) {
target, err = filepath.Abs(target) target, err = filepath.Abs(target)
if err != nil { if err != nil {
return "", nil, err return "", nil, err
} }
}
info, err = os.Lstat(target) fi, err := os.Lstat(target)
if err != nil { if err != nil {
return "", nil, err return "", nil, err
} }
tries++ return target, fi, nil
if tries > 100 {
return "", nil, fmt.Errorf(
"Symlink for %s is too deep, over 100 levels deep",
path)
}
}
return target, info, nil
} }
// readCloseRemover is an io.ReadCloser implementation that will remove // readCloseRemover is an io.ReadCloser implementation that will remove

6
vendor/vendor.json vendored
View File

@ -579,11 +579,11 @@
"revisionTime": "2017-06-23T01:44:30Z" "revisionTime": "2017-06-23T01:44:30Z"
}, },
{ {
"checksumSHA1": "FUiF2WLrih0JdHsUTMMDz3DRokw=", "checksumSHA1": "izBSRxLAHN+a/XpAku0in05UzlY=",
"comment": "20141209094003-92-g95fa852", "comment": "20141209094003-92-g95fa852",
"path": "github.com/hashicorp/atlas-go/archive", "path": "github.com/hashicorp/atlas-go/archive",
"revision": "1792bd8de119ba49b17fd8d3c3c1f488ec613e62", "revision": "17522f63497eefcffc90d528ca1eeaded2b529d3",
"revisionTime": "2016-11-07T20:49:10Z" "revisionTime": "2017-08-08T16:18:53Z"
}, },
{ {
"checksumSHA1": "IR7S+SOsSUnPnLxgRrfemXfCqNM=", "checksumSHA1": "IR7S+SOsSUnPnLxgRrfemXfCqNM=",