Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/omnibus/packagers/pkg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ def write_distribution_file
identifier: safe_identifier,
version: safe_version,
component_pkg: component_pkg,
host_architecture: safe_architecture,
})
end

Expand Down Expand Up @@ -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.
#
Expand Down
2 changes: 1 addition & 1 deletion resources/pkg/distribution.xml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<!-- Generated by productbuild - - synthesize -->
<pkg-ref id="<%= identifier %>"/>
<options customize="never" require-scripts="false"/>
<options customize="never" require-scripts="false" hostArchitectures="<%= host_architecture %>" />
<choices-outline>
<line choice="default">
<line choice="<%= identifier %>"/>
Expand Down
16 changes: 16 additions & 0 deletions spec/unit/packagers/pkg_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,24 @@ module Omnibus

expect(contents).to include('<pkg-ref id="com.getchef.project-full-name"/>')
expect(contents).to include('<line choice="com.getchef.project-full-name"/>')
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
Expand Down