`vagrant package` uses bsdtar

This commit is contained in:
Mitchell Hashimoto 2013-01-28 13:20:14 -08:00
parent 35aef1aa0b
commit d4cf03d6c5
1 changed files with 11 additions and 14 deletions

View File

@ -1,5 +1,6 @@
require 'fileutils'
require 'archive/tar/minitar'
require 'vagrant/util/subprocess'
module Vagrant
module Action
@ -73,21 +74,17 @@ module Vagrant
# Compress the exported file into a package
def compress
@env[:ui].info I18n.t("vagrant.actions.general.package.compressing", :tar_path => tar_path)
File.open(tar_path, Platform.tar_file_options) do |tar|
Archive::Tar::Minitar::Output.open(tar) do |output|
begin
current_dir = FileUtils.pwd
# Copy over the included files
copy_include_files
FileUtils.cd(@env["package.directory"])
Dir.glob(File.join(".", "**", "*")).each do |entry|
Archive::Tar::Minitar.pack_file(entry, output)
end
ensure
FileUtils.cd(current_dir)
end
end
# Switch into that directory and package everything up
Dir.chdir(@env["package.directory"]) do
# Find all the files in our current directory and tar it up!
files = Dir.glob(File.join(".", "**", "*"))
# Package!
Util::Subprocess.execute("bsdtar", "-czf", tar_path.to_s, *files)
end
end