diff --git a/lib/omnibus/packagers/pkg.rb b/lib/omnibus/packagers/pkg.rb
index 0f2d28a1d..7c80bd8de 100644
--- a/lib/omnibus/packagers/pkg.rb
+++ b/lib/omnibus/packagers/pkg.rb
@@ -219,6 +219,7 @@ def write_distribution_file
identifier: safe_identifier,
version: safe_version,
component_pkg: component_pkg,
+ host_architecture: safe_architecture,
})
end
@@ -253,6 +254,15 @@ def component_pkg
"#{safe_base_package_name}-core.pkg"
end
+ #
+ # Return the architecture
+ #
+ # @return [String]
+ #
+ def safe_architecture
+ @safe_architecture ||= Ohai["kernel"]["machine"]
+ end
+
#
# Return the PKG-ready base package name, removing any invalid characters.
#
diff --git a/resources/pkg/distribution.xml.erb b/resources/pkg/distribution.xml.erb
index d56d81783..bef76cb07 100644
--- a/resources/pkg/distribution.xml.erb
+++ b/resources/pkg/distribution.xml.erb
@@ -7,7 +7,7 @@
-
+
diff --git a/spec/unit/packagers/pkg_spec.rb b/spec/unit/packagers/pkg_spec.rb
index 32e493342..99fb6cc3f 100644
--- a/spec/unit/packagers/pkg_spec.rb
+++ b/spec/unit/packagers/pkg_spec.rb
@@ -137,8 +137,24 @@ module Omnibus
expect(contents).to include('')
expect(contents).to include('')
+ expect(contents).to include('hostArchitectures="x86_64"')
expect(contents).to include("project-full-name-core.pkg")
end
+
+ context "for arm64 builds" do
+ before do
+ stub_ohai(platform: "mac_os_x", version: "11.0") do |data|
+ data["kernel"]["machine"] = "arm64"
+ end
+ end
+
+ it "sets the hostArchitectures to include arm64" do
+ subject.write_distribution_file
+ contents = File.read("#{staging_dir}/Distribution")
+
+ expect(contents).to include('hostArchitectures="arm64"')
+ end
+ end
end
describe '#build_product_pkg' do