From eb7c3ef377949055094c0542e9e50de75c0a3558 Mon Sep 17 00:00:00 2001 From: Bryan Berry Date: Tue, 22 May 2012 19:33:45 +0200 Subject: [PATCH] fix bug where it fails to strip leading directory for zip files --- files/default/tests/minitest/test_test.rb | 5 +++++ libraries/provider_ark.rb | 6 ++++++ recipes/test.rb | 8 ++++++++ 3 files changed, 19 insertions(+) diff --git a/files/default/tests/minitest/test_test.rb b/files/default/tests/minitest/test_test.rb index bb9f2c0..87d95c0 100644 --- a/files/default/tests/minitest/test_test.rb +++ b/files/default/tests/minitest/test_test.rb @@ -54,6 +54,11 @@ directory( "/usr/local/foo_dont_strip/foo_sub").must_exist end + it "does strip for zip file" do + file("/usr/local/foo_zip_strip/foo1.txt").must_exist + end + + it "successfully compiles haproxy" do file("/usr/local/haproxy-1.5/haproxy").must_exist end diff --git a/libraries/provider_ark.rb b/libraries/provider_ark.rb index 131f078..dbe3bcd 100644 --- a/libraries/provider_ark.rb +++ b/libraries/provider_ark.rb @@ -254,6 +254,12 @@ def unzip cmd.run_command cmd.error! subdirectory_children = Dir.glob("#{tmpdir}/**") + if subdirectory_children.length == 1 + subdir = subdirectory_children[0] + subdirectory_children = Dir.glob("#{subdir}/**") + end + require 'pry' + binding.pry FileUtils.mv subdirectory_children, new_resource.path FileUtils.rm_rf tmpdir else diff --git a/recipes/test.rb b/recipes/test.rb index a8440cd..619d204 100644 --- a/recipes/test.rb +++ b/recipes/test.rb @@ -77,6 +77,14 @@ action :install end +ark "foo_zip_strip" do + version "2" + url 'https://github.com/bryanwb/chef-ark/raw/master/files/default/foo.zip' + checksum 'deea3a324115c9ca0f3078362f807250080bf1b27516f7eca9d34aad863a11e0' + action :install +end + + ark "haproxy" do url "http://haproxy.1wt.eu/download/1.5/src/snapshot/haproxy-ss-20120403.tar.gz" version "1.5"