Included files in package now go into the include/ directory.
This commit is contained in:
parent
9f3e926566
commit
ecdec218b4
|
@ -36,6 +36,21 @@ module Vagrant
|
|||
export_action.temp_dir
|
||||
end
|
||||
|
||||
# This method copies the include files (passed in via command line)
|
||||
# to the temporary directory so they are included in a sub-folder within
|
||||
# the actual box
|
||||
def copy_include_files
|
||||
if include_files.length > 0
|
||||
include_dir = File.join(temp_path, "include")
|
||||
FileUtils.mkdir_p(include_dir)
|
||||
|
||||
include_files.each do |f|
|
||||
logger.info "Packaging additional file: #{f}"
|
||||
FileUtils.cp(f, include_dir)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def compress
|
||||
logger.info "Packaging VM into #{tar_path}..."
|
||||
File.open(tar_path, File::CREAT | File::WRONLY, 0644) do |tar|
|
||||
|
@ -43,14 +58,10 @@ module Vagrant
|
|||
begin
|
||||
current_dir = FileUtils.pwd
|
||||
|
||||
include_files.each do |f|
|
||||
logger.info "Packaging additional file: #{f}"
|
||||
Archive::Tar::Minitar.pack_file(f, output)
|
||||
end
|
||||
copy_include_files
|
||||
|
||||
FileUtils.cd(temp_path)
|
||||
|
||||
Dir.glob(File.join(".", "*")).each do |entry|
|
||||
Dir.glob(File.join(".", "**", "*")).each do |entry|
|
||||
Archive::Tar::Minitar.pack_file(entry, output)
|
||||
end
|
||||
ensure
|
||||
|
|
|
@ -3,8 +3,6 @@ begin
|
|||
rescue LoadError
|
||||
# Fallback on doing the resolve at runtime.
|
||||
require "rubygems"
|
||||
require "bundler"
|
||||
Bundler.setup
|
||||
end
|
||||
|
||||
# ruby-debug, not necessary, but useful if we have it
|
||||
|
|
|
@ -56,6 +56,37 @@ class PackageActionTest < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
context "copying include files" do
|
||||
setup do
|
||||
@include_files = []
|
||||
@action.stubs(:include_files).returns(@include_files)
|
||||
|
||||
@temp_path = "foo"
|
||||
@action.stubs(:temp_path).returns(@temp_path)
|
||||
end
|
||||
|
||||
should "do nothing if no include files are specified" do
|
||||
assert @action.include_files.empty?
|
||||
FileUtils.expects(:mkdir_p).never
|
||||
FileUtils.expects(:cp).never
|
||||
@action.copy_include_files
|
||||
end
|
||||
|
||||
should "create the include directory and copy files to it" do
|
||||
include_dir = File.join(@action.temp_path, "include")
|
||||
copy_seq = sequence("copy_seq")
|
||||
FileUtils.expects(:mkdir_p).with(include_dir).once.in_sequence(copy_seq)
|
||||
|
||||
5.times do |i|
|
||||
file = mock("f#{i}")
|
||||
@include_files << file
|
||||
FileUtils.expects(:cp).with(file, include_dir).in_sequence(copy_seq)
|
||||
end
|
||||
|
||||
@action.copy_include_files
|
||||
end
|
||||
end
|
||||
|
||||
context "compression" do
|
||||
setup do
|
||||
@tar_path = "foo"
|
||||
|
@ -98,6 +129,7 @@ class PackageActionTest < Test::Unit::TestCase
|
|||
compress_seq = sequence("compress_seq")
|
||||
|
||||
FileUtils.expects(:pwd).once.returns(@pwd).in_sequence(compress_seq)
|
||||
@action.expects(:copy_include_files).once.in_sequence(compress_seq)
|
||||
FileUtils.expects(:cd).with(@temp_path).in_sequence(compress_seq)
|
||||
Dir.expects(:glob).returns(@files).in_sequence(compress_seq)
|
||||
|
||||
|
@ -120,25 +152,6 @@ class PackageActionTest < Test::Unit::TestCase
|
|||
@action.compress
|
||||
}
|
||||
end
|
||||
|
||||
should "add included files when passed" do
|
||||
compress_seq = sequence("compress")
|
||||
@files = []
|
||||
5.times do |i|
|
||||
file = mock("file#{i}")
|
||||
@tar.expects(:pack_file).with(file, @output).once.in_sequence(compress_seq)
|
||||
@files << file
|
||||
end
|
||||
|
||||
@action.expects(:include_files).returns(@files)
|
||||
@action.compress
|
||||
end
|
||||
|
||||
should "not add files when none are specified" do
|
||||
@tar.expects(:pack_file).never
|
||||
Dir.expects(:glob).once.returns([])
|
||||
@action.compress
|
||||
end
|
||||
end
|
||||
|
||||
context "preparing the action" do
|
||||
|
|
Loading…
Reference in New Issue