From cf9d13315d9030732ebe4affb6da7ac5cd7de62b Mon Sep 17 00:00:00 2001 From: Tom Duffield Date: Fri, 12 Mar 2021 10:31:05 -0600 Subject: [PATCH 1/2] Add hostArchitectures to macOS Distribution file Unless hostArchitectures is set, macOS 11 will assume that the package is x86_64 and require Rosetta 2. * https://scriptingosx.com/2020/12/platform-support-in-macos-installer-packages-pkg/ * https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html#//apple_ref/doc/uid/TP40005370-CH100-SW7 Signed-off-by: Tom Duffield --- lib/omnibus/packagers/pkg.rb | 1 + resources/pkg/distribution.xml.erb | 2 +- spec/unit/packagers/pkg_spec.rb | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/omnibus/packagers/pkg.rb b/lib/omnibus/packagers/pkg.rb index 0f2d28a1d..8c8c28cdb 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 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 From e8f6cd501d2c051ff9fa663c24e6e0f060587e9e Mon Sep 17 00:00:00 2001 From: Timothy Sutton Date: Fri, 14 Jul 2023 21:32:01 -0400 Subject: [PATCH 2/2] Add safe_architecture method to support cherry-picked 6173b5f --- lib/omnibus/packagers/pkg.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/omnibus/packagers/pkg.rb b/lib/omnibus/packagers/pkg.rb index 8c8c28cdb..7c80bd8de 100644 --- a/lib/omnibus/packagers/pkg.rb +++ b/lib/omnibus/packagers/pkg.rb @@ -254,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. #