From 9856652c0834a8c073158d574924352643a27fbb Mon Sep 17 00:00:00 2001 From: Wilfried JEANNIARD Date: Thu, 28 Apr 2016 22:48:27 +0200 Subject: Detect version of tar and use option --force-local if needed --- lib/chef/knife/cookbook_site_install.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/chef/knife/cookbook_site_install.rb b/lib/chef/knife/cookbook_site_install.rb index 3041270048..b08fe90170 100644 --- a/lib/chef/knife/cookbook_site_install.rb +++ b/lib/chef/knife/cookbook_site_install.rb @@ -141,8 +141,17 @@ 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? + # FIXED: Detect if we have the bad tar from git on Windows: https://github.com/opscode/chef/issues/1753 + tar_version = `tar --version`.tr("\n"," ") + if /GNU tar/.match(tar_version) + ui.info("GNU tar detected") + extract_command << " --force-local" + elsif /bsdtar/.match(tar_version) + ui.info("BSD tar detected") + end + end shell_out!(extract_command, :cwd => @install_path) end -- cgit v1.2.1