summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2016-05-10 18:17:00 +0100
committerThom May <thom@may.lt>2016-05-10 18:17:00 +0100
commita1441e7354980338dd9cac47e551c4cdb8bde689 (patch)
treea12de14579c002755d6fe7038f170e87ec4b3c0e
parentdcf9b3064ff753fe4cbe12f7bcec78dc09905f11 (diff)
parentda42813f915183055d3e152e5d839ffff4ce8e92 (diff)
downloadchef-a1441e7354980338dd9cac47e551c4cdb8bde689.tar.gz
Merge pull request #4867 from willoucom/untar-under-windows
cookbook site install : tar error on windows
-rw-r--r--lib/chef/knife/cookbook_site_install.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/chef/knife/cookbook_site_install.rb b/lib/chef/knife/cookbook_site_install.rb
index 802fdd792b..45f3061d87 100644
--- a/lib/chef/knife/cookbook_site_install.rb
+++ b/lib/chef/knife/cookbook_site_install.rb
@@ -141,10 +141,15 @@ class Chef
def extract_cookbook(upstream_file, version)
ui.info("Uncompressing #{@cookbook_name} version #{version}.")
- # FIXME: Detect if we have the bad tar from git on Windows: https://github.com/opscode/chef/issues/1753
extract_command = "tar zxvf \"#{convert_path upstream_file}\""
if Chef::Platform.windows?
- extract_command << " --force-local"
+ tar_version = shell_out("tar --version").stdout.tr("\n", " ")
+ if tar_version =~ /GNU tar/
+ Chef::Log.debug("GNU tar detected, adding --force-local")
+ extract_command << " --force-local"
+ else
+ Chef::Log.debug("non-GNU tar detected, not adding --force-local")
+ end
end
shell_out!(extract_command, :cwd => @install_path)
end