Package now puts auto-generated Vagrantfile with MAC address in root.
This commit is contained in:
parent
ecdec218b4
commit
9498226c83
|
@ -51,6 +51,17 @@ module Vagrant
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# This method creates the auto-generated Vagrantfile at the root of the
|
||||||
|
# box. This Vagrantfile contains the MAC address so that the user doesn't
|
||||||
|
# have to worry about it.
|
||||||
|
def create_vagrantfile
|
||||||
|
File.open(File.join(temp_path, "Vagrantfile"), "w") do |f|
|
||||||
|
f.write(TemplateRenderer.render("package_Vagrantfile", {
|
||||||
|
:base_mac => @runner.env.config.vm.base_mac
|
||||||
|
}))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def compress
|
def compress
|
||||||
logger.info "Packaging VM into #{tar_path}..."
|
logger.info "Packaging VM into #{tar_path}..."
|
||||||
File.open(tar_path, File::CREAT | File::WRONLY, 0644) do |tar|
|
File.open(tar_path, File::CREAT | File::WRONLY, 0644) do |tar|
|
||||||
|
@ -59,6 +70,7 @@ module Vagrant
|
||||||
current_dir = FileUtils.pwd
|
current_dir = FileUtils.pwd
|
||||||
|
|
||||||
copy_include_files
|
copy_include_files
|
||||||
|
create_vagrantfile
|
||||||
|
|
||||||
FileUtils.cd(temp_path)
|
FileUtils.cd(temp_path)
|
||||||
Dir.glob(File.join(".", "**", "*")).each do |entry|
|
Dir.glob(File.join(".", "**", "*")).each do |entry|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
Vagrant::Config.run do |config|
|
||||||
|
# This Vagrantfile is auto-generated by `vagrant package` to contain
|
||||||
|
# the MAC address of the box. Custom configuration should be placed in
|
||||||
|
# the actual `Vagrantfile` in this box.
|
||||||
|
config.vm.base_mac = "<%= base_mac %>"
|
||||||
|
end
|
|
@ -87,6 +87,25 @@ class PackageActionTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "creating vagrantfile" do
|
||||||
|
setup do
|
||||||
|
@temp_path = "foo"
|
||||||
|
@action.stubs(:temp_path).returns(@temp_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "write the rendered vagrantfile to temp_path Vagrantfile" do
|
||||||
|
f = mock("file")
|
||||||
|
rendered = mock("rendered")
|
||||||
|
File.expects(:open).with(File.join(@action.temp_path, "Vagrantfile"), "w").yields(f)
|
||||||
|
Vagrant::Util::TemplateRenderer.expects(:render).returns(rendered).with("package_Vagrantfile", {
|
||||||
|
:base_mac => @runner.env.config.vm.base_mac
|
||||||
|
})
|
||||||
|
f.expects(:write).with(rendered)
|
||||||
|
|
||||||
|
@action.create_vagrantfile
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "compression" do
|
context "compression" do
|
||||||
setup do
|
setup do
|
||||||
@tar_path = "foo"
|
@tar_path = "foo"
|
||||||
|
@ -109,6 +128,9 @@ class PackageActionTest < Test::Unit::TestCase
|
||||||
@tar = Archive::Tar::Minitar
|
@tar = Archive::Tar::Minitar
|
||||||
Archive::Tar::Minitar::Output.stubs(:open).yields(@output)
|
Archive::Tar::Minitar::Output.stubs(:open).yields(@output)
|
||||||
@tar.stubs(:pack_file)
|
@tar.stubs(:pack_file)
|
||||||
|
|
||||||
|
@action.stubs(:copy_include_files)
|
||||||
|
@action.stubs(:create_vagrantfile)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "open the tar file with the tar path properly" do
|
should "open the tar file with the tar path properly" do
|
||||||
|
@ -130,6 +152,7 @@ class PackageActionTest < Test::Unit::TestCase
|
||||||
|
|
||||||
FileUtils.expects(:pwd).once.returns(@pwd).in_sequence(compress_seq)
|
FileUtils.expects(:pwd).once.returns(@pwd).in_sequence(compress_seq)
|
||||||
@action.expects(:copy_include_files).once.in_sequence(compress_seq)
|
@action.expects(:copy_include_files).once.in_sequence(compress_seq)
|
||||||
|
@action.expects(:create_vagrantfile).once.in_sequence(compress_seq)
|
||||||
FileUtils.expects(:cd).with(@temp_path).in_sequence(compress_seq)
|
FileUtils.expects(:cd).with(@temp_path).in_sequence(compress_seq)
|
||||||
Dir.expects(:glob).returns(@files).in_sequence(compress_seq)
|
Dir.expects(:glob).returns(@files).in_sequence(compress_seq)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue