Use bsdtar to repackage boxes
This commit is contained in:
parent
2d2f9577af
commit
35aef1aa0b
|
@ -1,10 +1,10 @@
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
|
|
||||||
require 'archive/tar/minitar'
|
|
||||||
require "json"
|
require "json"
|
||||||
require "log4r"
|
require "log4r"
|
||||||
|
|
||||||
require "vagrant/util/platform"
|
require "vagrant/util/platform"
|
||||||
|
require "vagrant/util/subprocess"
|
||||||
|
|
||||||
module Vagrant
|
module Vagrant
|
||||||
# Represents a "box," which is a package Vagrant environment that is used
|
# Represents a "box," which is a package Vagrant environment that is used
|
||||||
|
@ -68,26 +68,12 @@ module Vagrant
|
||||||
def repackage(path)
|
def repackage(path)
|
||||||
@logger.debug("Repackaging box '#{@name}' to: #{path}")
|
@logger.debug("Repackaging box '#{@name}' to: #{path}")
|
||||||
|
|
||||||
path.open(Util::Platform.tar_file_options) do |f|
|
Dir.chdir(@directory) do
|
||||||
Archive::Tar::Minitar::Output.open(f) do |output|
|
# Find all the files in our current directory and tar it up!
|
||||||
# Store the current working directory since we need to change
|
files = Dir.glob(File.join(".", "**", "*"))
|
||||||
# for the tar library.
|
|
||||||
current_dir = FileUtils.pwd
|
|
||||||
|
|
||||||
begin
|
# Package!
|
||||||
FileUtils.cd(@directory)
|
Util::Subprocess.execute("bsdtar", "-czf", path.to_s, *files)
|
||||||
|
|
||||||
# Find all the files in our current directory and tar it up!
|
|
||||||
Dir.glob(File.join(".", "**", "*")).each do |entry|
|
|
||||||
@logger.debug("Packing file: #{entry}")
|
|
||||||
Archive::Tar::Minitar.pack_file(entry, output)
|
|
||||||
end
|
|
||||||
ensure
|
|
||||||
# Make sure we always cd back into our previous working
|
|
||||||
# directory.
|
|
||||||
FileUtils.cd(current_dir)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@logger.info("Repackaged box '#{@name}' successfully: #{path}")
|
@logger.info("Repackaged box '#{@name}' successfully: #{path}")
|
||||||
|
|
Loading…
Reference in New Issue