macinbox icon indicating copy to clipboard operation
macinbox copied to clipboard

Allow to set box version

Open andreiborisov opened this issue 4 years ago • 4 comments

As far as I understand, macinbox sets box version based on macOS version.

This is a bit inconvenient since the box version and OS version are not the same in general. I propose to change defaults to 1.0.0 or allow to specify the version as a parameter.

andreiborisov avatar Apr 26 '20 01:04 andreiborisov

Another problem with the current behavior is that if the box already exists and is built again, the version is incremented automatically to the next integer. For example, I have built a Catalina box, which creates ~/.vagrant.d/boxes/macinbox/10.15.6 as expected. But if I then build a newer version of a Catalina box (e.g., because I want to change some build-time default setting, such as --no-gui), then the new box is created under ~/.vagrant.d/boxes/macinbox/11. This is not only confusing, but creates a potential conflict when we anticipate that to indicate Big Sur.

A workaround is to (re)move the box directory, or to set a custom $VAGRANT_HOME.

But ideally, it should be possible to specify a box version independently of the macOS version, as the issue description already states.

psibre avatar Aug 05 '20 10:08 psibre

The current behavior is to automatically use the OS version (e.g. 10.15.6), but if box with that version already exists then the first number is incremented (e.g. to 11, then 12, and 13) until there is no conflict.

I hear a couple of ideas:

  • Change the default to be 1.0.0 instead of the OS version
  • Allow the version to be set via a command-line tool

But what do people want to happen when there is a conflict? Should the box-creation fail? Should the number be incremented? Should a suffix be added, e.g. 10.15.6-2 (I'm not sure that's a valid Vagrant box version, though)?

bacongravy avatar Aug 24 '20 19:08 bacongravy

It definitely shouldn't overwrite anything and it can be pretty confusing if the version is automatically incremented. So I would say it should fail if the version already exists.

andreiborisov avatar Aug 24 '20 20:08 andreiborisov

options.rb:

DEFAULT_OPTION_VALUES = {
      :box_format      => "vmware_desktop",
      :box_version     => "1.0.0",
      :box_name        => "macinbox",

[...]

o.separator ''
        o.on(      '--box-format FORMAT',  'Format of the box (default: vmware_desktop)')  { |v| @options[:box_format] = v }
        o.on(      '--box-version xx.yy.zz',  'Version string for the box')               { |v| @options[:box_version] = v }

actions/install_box.rb:

def initialize(opts)
        @input_box   = opts[:box_path]   or raise ArgumentError.new(":box_path not specified")

        [...]

        @box_version = opts[:box_version].to_s rescue nil

ideologysec avatar Oct 14 '20 22:10 ideologysec