Sha256: 37f82b33866d071da12e611aa70495b981c2779cf494e371cad7ce3834b17d41

Contents?: true

Size: 1.17 KB

Versions: 13

Compression:

Stored size: 1.17 KB

Contents

require "fileutils"
require 'optparse'
require "pathname"

module VagrantPlugins
  module CommandBox
    module Command
      class Repackage < Vagrant.plugin("2", :command)
        def execute
          opts = OptionParser.new do |o|
            o.banner = "Usage: vagrant box repackage <name> <provider>"
          end

          # Parse the options
          argv = parse_options(opts)
          return if !argv
          raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length < 2

          box_name     = argv[0]
          box_provider = argv[1].to_sym

          # Verify the box exists that we want to repackage
          box = nil
          begin
            box = @env.boxes.find(box_name, box_provider)
          rescue Vagrant::Errors::BoxUpgradeRequired
            @env.boxes.upgrade(box_name)
            retry
          end

          raise Vagrant::Errors::BoxNotFound, :name => box_name if !box

          # Repackage the box
          output_path = Pathname.new(File.expand_path(@env.config_global.package.name, FileUtils.pwd))
          box.repackage(output_path)

          # Success, exit status 0
          0
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 5 rubygems

Version Path
vagrant-shell-0.2.9 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/plugins/commands/box/command/repackage.rb
tnargav-1.2.3 plugins/commands/box/command/repackage.rb
vagrant-shell-0.2.8 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/plugins/commands/box/command/repackage.rb
vagrant-shell-0.2.6 vendor/bundle/gems/tnargav-1.2.2/plugins/commands/box/command/repackage.rb
vagrant-shell-0.2.5 vendor/bundle/gems/tnargav-1.2.2/plugins/commands/box/command/repackage.rb
tnargav-1.2.2 plugins/commands/box/command/repackage.rb
vagrantup-1.1.3 plugins/commands/box/command/repackage.rb
vagrantup-1.1.2 plugins/commands/box/command/repackage.rb
vagrantup-1.1.1 plugins/commands/box/command/repackage.rb
vagrantup-1.1.0 plugins/commands/box/command/repackage.rb
vagrantup-1.1.4 plugins/commands/box/command/repackage.rb
vagrant-actionio-0.0.9 vendor/bundle/bundler/gems/vagrant-c74251a1d9c0/plugins/commands/box/command/repackage.rb
vagrant-lxc-0.0.1 vendor/vagrant/plugins/commands/box/command/repackage.rb