corrected bit mask for package output on windows
This commit is contained in:
parent
b949861186
commit
74aefa5c3d
|
@ -48,16 +48,11 @@ module Vagrant
|
||||||
|
|
||||||
def with_tempfile
|
def with_tempfile
|
||||||
logger.info "Creating tempfile for storing box file..."
|
logger.info "Creating tempfile for storing box file..."
|
||||||
File.open(box_temp_path, file_options) do |tempfile|
|
File.open(box_temp_path, Platform.tar_file_options) do |tempfile|
|
||||||
yield tempfile
|
yield tempfile
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def file_options
|
|
||||||
# create, write only, fail if the file exists, binary if windows
|
|
||||||
File::WRONLY|File::EXCL|File::CREAT|(Mario::Platform.windows? ? File::BINARY : 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
def box_temp_path
|
def box_temp_path
|
||||||
File.join(@runner.env.tmp_path, BASENAME + Time.now.to_i.to_s)
|
File.join(@runner.env.tmp_path, BASENAME + Time.now.to_i.to_s)
|
||||||
end
|
end
|
||||||
|
|
|
@ -64,7 +64,7 @@ module Vagrant
|
||||||
|
|
||||||
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, Platform.tar_file_options) do |tar|
|
||||||
Archive::Tar::Minitar::Output.open(tar) do |output|
|
Archive::Tar::Minitar::Output.open(tar) do |output|
|
||||||
begin
|
begin
|
||||||
current_dir = FileUtils.pwd
|
current_dir = FileUtils.pwd
|
||||||
|
|
|
@ -2,11 +2,16 @@ module Vagrant
|
||||||
module Util
|
module Util
|
||||||
# This class just contains some platform checking code.
|
# This class just contains some platform checking code.
|
||||||
class Platform
|
class Platform
|
||||||
class <<self
|
class << self
|
||||||
def leopard?
|
def leopard?
|
||||||
RUBY_PLATFORM.downcase.include?("darwin9")
|
RUBY_PLATFORM.downcase.include?("darwin9")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def tar_file_options
|
||||||
|
# create, write only, fail if the file exists, binary if windows
|
||||||
|
File::WRONLY|File::EXCL|File::CREAT|(Mario::Platform.windows? ? File::BINARY : 0)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -93,7 +93,6 @@ class DownloadBoxActionTest < Test::Unit::TestCase
|
||||||
@action.with_tempfile
|
@action.with_tempfile
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
should "yield the tempfile object" do
|
should "yield the tempfile object" do
|
||||||
@tempfile = mock("tempfile")
|
@tempfile = mock("tempfile")
|
||||||
File.expects(:open).yields(@tempfile)
|
File.expects(:open).yields(@tempfile)
|
||||||
|
@ -104,22 +103,6 @@ class DownloadBoxActionTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "file options" do
|
|
||||||
should "include add binary bit to options on windows platform" do
|
|
||||||
# This constant is not defined on non-windows platforms, so define it here
|
|
||||||
File::BINARY = 4096 unless defined?(File::BINARY)
|
|
||||||
|
|
||||||
Mario::Platform.expects(:windows?).returns(true)
|
|
||||||
assert_equal @action.file_options, File::CREAT|File::EXCL|File::WRONLY|File::BINARY
|
|
||||||
end
|
|
||||||
|
|
||||||
should "not include binary bit on other platforms" do
|
|
||||||
Mario::Platform.expects(:windows?).returns(false)
|
|
||||||
assert_equal @action.file_options, File::CREAT|File::EXCL|File::WRONLY
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
context "cleaning up" do
|
context "cleaning up" do
|
||||||
setup do
|
setup do
|
||||||
@temp_path = "foo"
|
@temp_path = "foo"
|
||||||
|
|
|
@ -138,7 +138,7 @@ class PackageActionTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "open the tar file with the tar path properly" do
|
should "open the tar file with the tar path properly" do
|
||||||
File.expects(:open).with(@tar_path, File::CREAT | File::WRONLY, 0644).once
|
File.expects(:open).with(@tar_path, Vagrant::Util::Platform.tar_file_options).once
|
||||||
@action.compress
|
@action.compress
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
||||||
|
|
||||||
|
class PlatformTest < Test::Unit::TestCase
|
||||||
|
context "file options" do
|
||||||
|
should "include add binary bit to options on windows platform" do
|
||||||
|
# This constant is not defined on non-windows platforms, so define it here
|
||||||
|
File::BINARY = 4096 unless defined?(File::BINARY)
|
||||||
|
|
||||||
|
Mario::Platform.expects(:windows?).returns(true)
|
||||||
|
assert_equal Vagrant::Util::Platform.tar_file_options, File::CREAT|File::EXCL|File::WRONLY|File::BINARY
|
||||||
|
end
|
||||||
|
|
||||||
|
should "not include binary bit on other platforms" do
|
||||||
|
Mario::Platform.expects(:windows?).returns(false)
|
||||||
|
assert_equal Vagrant::Util::Platform.tar_file_options, File::CREAT|File::EXCL|File::WRONLY
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
120
vagrant.gemspec
120
vagrant.gemspec
|
@ -170,6 +170,7 @@ Gem::Specification.new do |s|
|
||||||
"test/vagrant/util/error_helper_test.rb",
|
"test/vagrant/util/error_helper_test.rb",
|
||||||
"test/vagrant/util/output_helper_test.rb",
|
"test/vagrant/util/output_helper_test.rb",
|
||||||
"test/vagrant/util/plain_logger_test.rb",
|
"test/vagrant/util/plain_logger_test.rb",
|
||||||
|
"test/vagrant/util/platform_test.rb",
|
||||||
"test/vagrant/util/stacked_proc_runner_test.rb",
|
"test/vagrant/util/stacked_proc_runner_test.rb",
|
||||||
"test/vagrant/util/template_renderer_test.rb",
|
"test/vagrant/util/template_renderer_test.rb",
|
||||||
"test/vagrant/util/translator_test.rb",
|
"test/vagrant/util/translator_test.rb",
|
||||||
|
@ -182,71 +183,72 @@ Gem::Specification.new do |s|
|
||||||
s.rubygems_version = %q{1.3.6}
|
s.rubygems_version = %q{1.3.6}
|
||||||
s.summary = %q{Vagrant is a tool for building and distributing virtualized development environments.}
|
s.summary = %q{Vagrant is a tool for building and distributing virtualized development environments.}
|
||||||
s.test_files = [
|
s.test_files = [
|
||||||
"test/test_helper.rb",
|
"test/vagrant/box_test.rb",
|
||||||
"test/vagrant/vm_test.rb",
|
|
||||||
"test/vagrant/command_test.rb",
|
|
||||||
"test/vagrant/environment_test.rb",
|
|
||||||
"test/vagrant/box_test.rb",
|
|
||||||
"test/vagrant/busy_test.rb",
|
|
||||||
"test/vagrant/provisioners/base_test.rb",
|
|
||||||
"test/vagrant/provisioners/chef_test.rb",
|
|
||||||
"test/vagrant/provisioners/chef_server_test.rb",
|
|
||||||
"test/vagrant/provisioners/chef_solo_test.rb",
|
|
||||||
"test/vagrant/systems/linux_test.rb",
|
|
||||||
"test/vagrant/config_test.rb",
|
|
||||||
"test/vagrant/actions/base_test.rb",
|
|
||||||
"test/vagrant/actions/runner_test.rb",
|
|
||||||
"test/vagrant/actions/box/verify_test.rb",
|
|
||||||
"test/vagrant/actions/box/destroy_test.rb",
|
|
||||||
"test/vagrant/actions/box/add_test.rb",
|
|
||||||
"test/vagrant/actions/box/unpackage_test.rb",
|
|
||||||
"test/vagrant/actions/box/download_test.rb",
|
|
||||||
"test/vagrant/actions/collection_test.rb",
|
|
||||||
"test/vagrant/actions/vm/reload_test.rb",
|
|
||||||
"test/vagrant/actions/vm/suspend_test.rb",
|
|
||||||
"test/vagrant/actions/vm/boot_test.rb",
|
|
||||||
"test/vagrant/actions/vm/package_test.rb",
|
|
||||||
"test/vagrant/actions/vm/down_test.rb",
|
|
||||||
"test/vagrant/actions/vm/shared_folders_test.rb",
|
|
||||||
"test/vagrant/actions/vm/destroy_test.rb",
|
|
||||||
"test/vagrant/actions/vm/halt_test.rb",
|
|
||||||
"test/vagrant/actions/vm/import_test.rb",
|
|
||||||
"test/vagrant/actions/vm/customize_test.rb",
|
|
||||||
"test/vagrant/actions/vm/start_test.rb",
|
|
||||||
"test/vagrant/actions/vm/move_hard_drive_test.rb",
|
|
||||||
"test/vagrant/actions/vm/up_test.rb",
|
|
||||||
"test/vagrant/actions/vm/export_test.rb",
|
|
||||||
"test/vagrant/actions/vm/provision_test.rb",
|
|
||||||
"test/vagrant/actions/vm/resume_test.rb",
|
|
||||||
"test/vagrant/actions/vm/forward_ports_test.rb",
|
|
||||||
"test/vagrant/active_list_test.rb",
|
|
||||||
"test/vagrant/commands/base_test.rb",
|
|
||||||
"test/vagrant/commands/reload_test.rb",
|
|
||||||
"test/vagrant/commands/ssh_config_test.rb",
|
|
||||||
"test/vagrant/commands/suspend_test.rb",
|
|
||||||
"test/vagrant/commands/package_test.rb",
|
|
||||||
"test/vagrant/commands/status_test.rb",
|
|
||||||
"test/vagrant/commands/init_test.rb",
|
|
||||||
"test/vagrant/commands/destroy_test.rb",
|
|
||||||
"test/vagrant/commands/halt_test.rb",
|
|
||||||
"test/vagrant/commands/box/remove_test.rb",
|
|
||||||
"test/vagrant/commands/box/add_test.rb",
|
|
||||||
"test/vagrant/commands/box/list_test.rb",
|
|
||||||
"test/vagrant/commands/up_test.rb",
|
|
||||||
"test/vagrant/commands/provision_test.rb",
|
|
||||||
"test/vagrant/commands/resume_test.rb",
|
|
||||||
"test/vagrant/commands/ssh_test.rb",
|
|
||||||
"test/vagrant/resource_logger_test.rb",
|
"test/vagrant/resource_logger_test.rb",
|
||||||
|
"test/vagrant/ssh_test.rb",
|
||||||
|
"test/vagrant/environment_test.rb",
|
||||||
|
"test/vagrant/provisioners/base_test.rb",
|
||||||
|
"test/vagrant/provisioners/chef_solo_test.rb",
|
||||||
|
"test/vagrant/provisioners/chef_server_test.rb",
|
||||||
|
"test/vagrant/provisioners/chef_test.rb",
|
||||||
|
"test/vagrant/commands/ssh_test.rb",
|
||||||
|
"test/vagrant/commands/destroy_test.rb",
|
||||||
|
"test/vagrant/commands/resume_test.rb",
|
||||||
|
"test/vagrant/commands/halt_test.rb",
|
||||||
|
"test/vagrant/commands/provision_test.rb",
|
||||||
|
"test/vagrant/commands/status_test.rb",
|
||||||
|
"test/vagrant/commands/base_test.rb",
|
||||||
|
"test/vagrant/commands/up_test.rb",
|
||||||
|
"test/vagrant/commands/reload_test.rb",
|
||||||
|
"test/vagrant/commands/package_test.rb",
|
||||||
|
"test/vagrant/commands/init_test.rb",
|
||||||
|
"test/vagrant/commands/ssh_config_test.rb",
|
||||||
|
"test/vagrant/commands/box/list_test.rb",
|
||||||
|
"test/vagrant/commands/box/add_test.rb",
|
||||||
|
"test/vagrant/commands/box/remove_test.rb",
|
||||||
|
"test/vagrant/commands/suspend_test.rb",
|
||||||
|
"test/vagrant/config_test.rb",
|
||||||
|
"test/vagrant/vm_test.rb",
|
||||||
"test/vagrant/downloaders/base_test.rb",
|
"test/vagrant/downloaders/base_test.rb",
|
||||||
"test/vagrant/downloaders/file_test.rb",
|
|
||||||
"test/vagrant/downloaders/http_test.rb",
|
"test/vagrant/downloaders/http_test.rb",
|
||||||
"test/vagrant/util/stacked_proc_runner_test.rb",
|
"test/vagrant/downloaders/file_test.rb",
|
||||||
|
"test/vagrant/command_test.rb",
|
||||||
|
"test/vagrant/active_list_test.rb",
|
||||||
|
"test/vagrant/busy_test.rb",
|
||||||
|
"test/vagrant/systems/linux_test.rb",
|
||||||
"test/vagrant/util/output_helper_test.rb",
|
"test/vagrant/util/output_helper_test.rb",
|
||||||
|
"test/vagrant/util/plain_logger_test.rb",
|
||||||
|
"test/vagrant/util/stacked_proc_runner_test.rb",
|
||||||
|
"test/vagrant/util/error_helper_test.rb",
|
||||||
|
"test/vagrant/util/platform_test.rb",
|
||||||
"test/vagrant/util/template_renderer_test.rb",
|
"test/vagrant/util/template_renderer_test.rb",
|
||||||
"test/vagrant/util/translator_test.rb",
|
"test/vagrant/util/translator_test.rb",
|
||||||
"test/vagrant/util/error_helper_test.rb",
|
"test/vagrant/actions/vm/start_test.rb",
|
||||||
"test/vagrant/util/plain_logger_test.rb",
|
"test/vagrant/actions/vm/destroy_test.rb",
|
||||||
"test/vagrant/ssh_test.rb"
|
"test/vagrant/actions/vm/customize_test.rb",
|
||||||
|
"test/vagrant/actions/vm/resume_test.rb",
|
||||||
|
"test/vagrant/actions/vm/halt_test.rb",
|
||||||
|
"test/vagrant/actions/vm/provision_test.rb",
|
||||||
|
"test/vagrant/actions/vm/import_test.rb",
|
||||||
|
"test/vagrant/actions/vm/up_test.rb",
|
||||||
|
"test/vagrant/actions/vm/boot_test.rb",
|
||||||
|
"test/vagrant/actions/vm/reload_test.rb",
|
||||||
|
"test/vagrant/actions/vm/shared_folders_test.rb",
|
||||||
|
"test/vagrant/actions/vm/package_test.rb",
|
||||||
|
"test/vagrant/actions/vm/move_hard_drive_test.rb",
|
||||||
|
"test/vagrant/actions/vm/forward_ports_test.rb",
|
||||||
|
"test/vagrant/actions/vm/suspend_test.rb",
|
||||||
|
"test/vagrant/actions/vm/down_test.rb",
|
||||||
|
"test/vagrant/actions/vm/export_test.rb",
|
||||||
|
"test/vagrant/actions/base_test.rb",
|
||||||
|
"test/vagrant/actions/runner_test.rb",
|
||||||
|
"test/vagrant/actions/collection_test.rb",
|
||||||
|
"test/vagrant/actions/box/destroy_test.rb",
|
||||||
|
"test/vagrant/actions/box/download_test.rb",
|
||||||
|
"test/vagrant/actions/box/verify_test.rb",
|
||||||
|
"test/vagrant/actions/box/unpackage_test.rb",
|
||||||
|
"test/vagrant/actions/box/add_test.rb",
|
||||||
|
"test/test_helper.rb"
|
||||||
]
|
]
|
||||||
|
|
||||||
if s.respond_to? :specification_version then
|
if s.respond_to? :specification_version then
|
||||||
|
|
Loading…
Reference in New Issue