diff --git a/lib/vagrant/action/general/package.rb b/lib/vagrant/action/general/package.rb index 8dc5da016..58b36b540 100644 --- a/lib/vagrant/action/general/package.rb +++ b/lib/vagrant/action/general/package.rb @@ -68,7 +68,13 @@ module Vagrant files_to_copy.each do |from, to| @env.ui.info I18n.t("vagrant.actions.general.package.packaging", :file => from) FileUtils.mkdir_p(to.parent) - FileUtils.cp(from, to) + + # Copy direcotry contents recursively. + if File.directory?(from) + FileUtils.cp_r(Dir.glob(from), to.parent) + else + FileUtils.cp(from, to) + end end end diff --git a/test/vagrant/action/general/package_test.rb b/test/vagrant/action/general/package_test.rb index 049365d08..be71bbb61 100644 --- a/test/vagrant/action/general/package_test.rb +++ b/test/vagrant/action/general/package_test.rb @@ -173,11 +173,25 @@ class PackageGeneralActionTest < Test::Unit::TestCase seq = sequence("seq") @instance.files_to_copy.each do |from, to| FileUtils.expects(:mkdir_p).with(to.parent).in_sequence(seq) + File.expects(:directory?).with(from).returns(false).in_sequence(seq) FileUtils.expects(:cp).with(from, to).in_sequence(seq) end @instance.copy_include_files end + + should "create the include directory and recursively copy globbed files to it" do + @env["package.include"] = ["foo*.txt"] + seq = sequence("seq") + @instance.files_to_copy.each do |from, to| + FileUtils.expects(:mkdir_p).with(to.parent).in_sequence(seq) + File.expects(:directory?).with(from).returns(true).in_sequence(seq) + Dir.expects(:glob).with(from).returns(from).in_sequence(seq) + FileUtils.expects(:cp_r).with(from, to.parent).in_sequence(seq) + end + + @instance.copy_include_files + end end context "compression" do