From 742e366367f13946554310d54e406f9ca231e4ee Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Thu, 29 Mar 2018 14:21:54 -0700 Subject: [PATCH] conditionally set tar header on go >= 1.10 --- post-processor/vagrant/tar_fix.go | 9 +++++++++ post-processor/vagrant/tar_fix_go110.go | 12 ++++++++++++ post-processor/vagrant/util.go | 6 ++---- 3 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 post-processor/vagrant/tar_fix.go create mode 100644 post-processor/vagrant/tar_fix_go110.go diff --git a/post-processor/vagrant/tar_fix.go b/post-processor/vagrant/tar_fix.go new file mode 100644 index 000000000..32f05d933 --- /dev/null +++ b/post-processor/vagrant/tar_fix.go @@ -0,0 +1,9 @@ +// +build !go1.10 + +package vagrant + +import "archive/tar" + +func setHeaderFormat(header *tar.Header) { + // no-op +} diff --git a/post-processor/vagrant/tar_fix_go110.go b/post-processor/vagrant/tar_fix_go110.go new file mode 100644 index 000000000..e9092ac08 --- /dev/null +++ b/post-processor/vagrant/tar_fix_go110.go @@ -0,0 +1,12 @@ +// +build go1.10 + +package vagrant + +import "archive/tar" + +func setHeaderFormat(header *tar.Header) { + // We have to set the Format explicitly because of a bug in + // libarchive. This affects eg. the tar in macOS listing huge + // files with zero byte length. + header.Format = tar.FormatGNU +} diff --git a/post-processor/vagrant/util.go b/post-processor/vagrant/util.go index d7597f74a..defc3e302 100644 --- a/post-processor/vagrant/util.go +++ b/post-processor/vagrant/util.go @@ -126,10 +126,8 @@ func DirToBox(dst, dir string, ui packer.Ui, level int) error { return err } - // We have to set the Format explicitly because of a bug in - // libarchive. This affects eg. the tar in macOS listing huge - // files with zero byte length. - header.Format = tar.FormatGNU + // workaround for large archive formats on go >=1.10 + setHeaderFormat(header) // We have to set the Name explicitly because it is supposed to // be a relative path to the root. Otherwise, the tar ends up