commands/box/repackage: works with new stuff [GH-3372]

This commit is contained in:
Mitchell Hashimoto 2014-04-12 17:57:51 -07:00
parent 4de887c1a8
commit adca39b471
1 changed files with 8 additions and 10 deletions

View File

@ -8,28 +8,26 @@ module VagrantPlugins
class Repackage < Vagrant.plugin("2", :command) class Repackage < Vagrant.plugin("2", :command)
def execute def execute
opts = OptionParser.new do |o| opts = OptionParser.new do |o|
o.banner = "Usage: vagrant box repackage <name> <provider>" o.banner = "Usage: vagrant box repackage <name> <provider> <version>"
end end
# Parse the options # Parse the options
argv = parse_options(opts) argv = parse_options(opts)
return if !argv return if !argv
raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length != 2 raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length != 3
box_name = argv[0] box_name = argv[0]
box_provider = argv[1].to_sym box_provider = argv[1].to_sym
box_version = argv[2]
# Verify the box exists that we want to repackage # Verify the box exists that we want to repackage
box = nil box = @env.boxes.find(box_name, box_provider, "= #{box_version}")
begin if !box
box = @env.boxes.find(box_name, box_provider) raise Vagrant::Errors::BoxNotFound,
rescue Vagrant::Errors::BoxUpgradeRequired :name => box_name,
@env.boxes.upgrade(box_name) :provider => box_provider
retry
end end
raise Vagrant::Errors::BoxNotFound, :name => box_name, :provider => box_provider if !box
# Repackage the box # Repackage the box
output_name = @env.vagrantfile.config.package.name || "package.box" output_name = @env.vagrantfile.config.package.name || "package.box"
output_path = Pathname.new(File.expand_path(output_name, FileUtils.pwd)) output_path = Pathname.new(File.expand_path(output_name, FileUtils.pwd))