Skip to content

Commit

Permalink
Adjust installation for unknown default architecture
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
chrisroberts committed Sep 26, 2023
1 parent e719113 commit 74b4a2b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion lib/vagrant/action/builtin/box_add.rb
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,17 @@ def add_from_metadata(url, env, expanded)
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,
Expand All @@ -338,7 +349,7 @@ def add_from_metadata(url, env, expanded)
env,
checksum: metadata_provider.checksum,
checksum_type: metadata_provider.checksum_type,
architecture: metadata_provider.architecture,
architecture: arch_name,
)
end

Expand Down
4 changes: 2 additions & 2 deletions test/unit/vagrant/action/builtin/box_add_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ def with_web_server(path, **opts)
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(
Expand Down Expand Up @@ -1072,7 +1072,7 @@ def with_web_server(path, **opts)
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)

Expand Down

0 comments on commit 74b4a2b

Please sign in to comment.