Skip to content

Commit 74b4a2b

Browse files
committed
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.
1 parent e719113 commit 74b4a2b

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/vagrant/action/builtin/box_add.rb

+12-1
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,17 @@ def add_from_metadata(url, env, expanded)
329329
provider_url = authed_urls[0]
330330
end
331331

332+
# The architecture name used when adding the box should be
333+
# the value extracted from the metadata provider
334+
arch_name = metadata_provider.architecture
335+
336+
# In the special case where the architecture name is "unknown" and
337+
# it is listed as the default architecture, unset the architecture
338+
# name so it is installed without architecture information
339+
if arch_name == "unknown" && metadata_provider.default_architecture
340+
arch_name = nil
341+
end
342+
332343
box_add(
333344
[[provider_url, metadata_provider.url]],
334345
metadata.name,
@@ -338,7 +349,7 @@ def add_from_metadata(url, env, expanded)
338349
env,
339350
checksum: metadata_provider.checksum,
340351
checksum_type: metadata_provider.checksum_type,
341-
architecture: metadata_provider.architecture,
352+
architecture: arch_name,
342353
)
343354
end
344355

test/unit/vagrant/action/builtin/box_add_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ def with_web_server(path, **opts)
10331033
subject.call(env)
10341034
end
10351035

1036-
it "adds the latest version of a box with only one provider and no unknown architecture set as default" do
1036+
it "adds the latest version of a box with only one provider and unknown architecture set as default" do
10371037
box_path = iso_env.box2_file(:virtualbox)
10381038
tf = Tempfile.new(["vagrant-box-latest-version", ".json"]).tap do |f|
10391039
f.write(
@@ -1072,7 +1072,7 @@ def with_web_server(path, **opts)
10721072
expect(name).to eq("foo/bar")
10731073
expect(version).to eq("0.7")
10741074
expect(opts[:metadata_url]).to eq("file://#{tf.path}")
1075-
expect(opts[:architecture]).to eq("unknown")
1075+
expect(opts[:architecture]).to be_nil
10761076
true
10771077
}.and_return(box)
10781078

0 commit comments

Comments
 (0)