From 74b4a2b1f58177d79f608c34a3decb3388d045b6 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Tue, 26 Sep 2023 16:20:37 -0700 Subject: [PATCH] Adjust installation for unknown default architecture When the reported architecture is unknown and the provider is listed as the default architecture, add the box without architecture information so it is installed without architecture information on the path within the collection. --- lib/vagrant/action/builtin/box_add.rb | 13 ++++++++++++- test/unit/vagrant/action/builtin/box_add_test.rb | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/vagrant/action/builtin/box_add.rb b/lib/vagrant/action/builtin/box_add.rb index 9e8374920..f04b8b861 100644 --- a/lib/vagrant/action/builtin/box_add.rb +++ b/lib/vagrant/action/builtin/box_add.rb @@ -329,6 +329,17 @@ module Vagrant provider_url = authed_urls[0] end + # The architecture name used when adding the box should be + # the value extracted from the metadata provider + arch_name = metadata_provider.architecture + + # In the special case where the architecture name is "unknown" and + # it is listed as the default architecture, unset the architecture + # name so it is installed without architecture information + if arch_name == "unknown" && metadata_provider.default_architecture + arch_name = nil + end + box_add( [[provider_url, metadata_provider.url]], metadata.name, @@ -338,7 +349,7 @@ module Vagrant env, checksum: metadata_provider.checksum, checksum_type: metadata_provider.checksum_type, - architecture: metadata_provider.architecture, + architecture: arch_name, ) end diff --git a/test/unit/vagrant/action/builtin/box_add_test.rb b/test/unit/vagrant/action/builtin/box_add_test.rb index c3366d504..704e7626e 100644 --- a/test/unit/vagrant/action/builtin/box_add_test.rb +++ b/test/unit/vagrant/action/builtin/box_add_test.rb @@ -1033,7 +1033,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows, :bsdtar do subject.call(env) end - it "adds the latest version of a box with only one provider and no unknown architecture set as default" do + it "adds the latest version of a box with only one provider and unknown architecture set as default" do box_path = iso_env.box2_file(:virtualbox) tf = Tempfile.new(["vagrant-box-latest-version", ".json"]).tap do |f| f.write( @@ -1072,7 +1072,7 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows, :bsdtar do expect(name).to eq("foo/bar") expect(version).to eq("0.7") expect(opts[:metadata_url]).to eq("file://#{tf.path}") - expect(opts[:architecture]).to eq("unknown") + expect(opts[:architecture]).to be_nil true }.and_return(box)