diff --git a/plugins/commands/box/command/repackage.rb b/plugins/commands/box/command/repackage.rb index 396df577b..edcaa1571 100644 --- a/plugins/commands/box/command/repackage.rb +++ b/plugins/commands/box/command/repackage.rb @@ -1,3 +1,4 @@ +require "fileutils" require 'optparse' module VagrantPlugins @@ -8,17 +9,24 @@ module VagrantPlugins options = {} opts = OptionParser.new do |opts| - opts.banner = "Usage: vagrant box repackage " + opts.banner = "Usage: vagrant box repackage " end # Parse the options argv = parse_options(opts) return if !argv - raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length < 1 + raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length < 2 - b = @env.boxes.find(argv[0]) - raise Vagrant::Errors::BoxNotFound, :name => argv[0] if !b - b.repackage + box_name = argv[0] + box_provider = argv[1].to_sym + + # Verify the box exists that we want to repackage + box = @env.boxes.find(box_name, box_provider) + raise Vagrant::Errors::BoxNotFound, :name => box_name if !b + + # Repackage the box + output_path = File.expand_path(@env.config.global.package.name, FileUtils.pwd) + box.repackage(output_path) # Success, exit status 0 0