diff options
author | Wilfried JEANNIARD <willou.com@gmail.com> | 2016-04-28 22:48:27 +0200 |
---|---|---|
committer | Wilfried JEANNIARD <willou.com@gmail.com> | 2016-04-28 22:48:27 +0200 |
commit | 9856652c0834a8c073158d574924352643a27fbb (patch) | |
tree | 41801d46f98580b7a955545d2cbd0a58ae0f4223 | |
parent | a5200b235f01adaf723dff672db00030875299f0 (diff) | |
download | chef-9856652c0834a8c073158d574924352643a27fbb.tar.gz |
Detect version of tar and use option --force-local if needed
-rw-r--r-- | lib/chef/knife/cookbook_site_install.rb | 11 |
1 files changed, 10 insertions, 1 deletions
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 |