Skip to content
Merged
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
8 changes: 6 additions & 2 deletions lib/omnibus/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,13 @@ def truncate_platform_version(platform_version, platform)
when "centos", "debian", "el", "fedora", "freebsd", "omnios", "pidora", "raspbian", "rhel", "sles", "suse", "smartos", "nexus", "ios_xr"
# Only want MAJOR (e.g. Debian 7, OmniOS r151006, SmartOS 20120809T221258Z)
platform_version.split(".").first
when "aix", "gentoo", "mac_os_x", "openbsd", "slackware", "solaris2", "opensuse", "ubuntu", "macos"
# Only want MAJOR.MINOR (e.g. Mac OS X 10.9, Ubuntu 12.04)
when "aix", "gentoo", "openbsd", "slackware", "solaris2", "opensuse", "ubuntu"
# Only want MAJOR.MINOR (e.g. Ubuntu 12.04)
platform_version.split(".")[0..1].join(".")
when "mac_os_x", "darwin", "macos"
# If running macOS >= 11, use only MAJOR version. Otherwise, use MAJOR.MINOR
pv_bits = platform_version.split(".")
pv_bits[0].to_i >= 11 ? pv_bits[0] : pv_bits[0..1].join(".")
when "arch"
# Arch Linux does not have a platform_version ohai attribute, it is rolling release (lsb_release -r)
"rolling"
Expand Down
12 changes: 11 additions & 1 deletion lib/omnibus/packagers/pkg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def install_location(val = NULL)

# @see Base#package_name
def package_name
"#{safe_base_package_name}-#{safe_version}-#{safe_build_iteration}.pkg"
"#{safe_base_package_name}-#{safe_version}-#{safe_build_iteration}.#{safe_architecture}.pkg"
end

#
Expand Down Expand Up @@ -242,6 +242,7 @@ def write_distribution_file
identifier: safe_identifier,
version: safe_version,
component_pkg: component_pkg,
host_architecture: safe_architecture,
})
end

Expand Down Expand Up @@ -276,6 +277,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
12 changes: 6 additions & 6 deletions spec/unit/compressors/dmg_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ module Omnibus
--detach-retries=5 \\
--settings="#{subject.resource_path('settings.py')}" \\
-Dbackground="#{subject.resource_path('background.png')}" \\
-Dpkg="#{package_dir}/project-1.2.3-2.pkg" \\
-Dpkg="#{package_dir}/project-1.2.3-2.x86_64.pkg" \\
-Dpkg_position="535, 50" \\
-Dvolume_icon="#{staging_dir}/tmp.icns" \\
-Dwindow_bounds="100, 100, 750, 600" \\
Expand All @@ -136,7 +136,7 @@ module Omnibus
expect(subject).to receive(:shellout!)
.with <<-EOH.gsub(/^ {12}/, "")
hdiutil verify \\
"#{package_dir}/project-1.2.3-2.dmg" \\
"#{package_dir}/project-1.2.3-2.x86_64.dmg" \\
-puppetstrings
EOH

Expand All @@ -162,10 +162,10 @@ module Omnibus
DeRez -only icns "#{icon}" > tmp.rsrc

# Append the icon reosurce to the DMG
Rez -append tmp.rsrc -o "#{package_dir}/project-1.2.3-2.dmg"
Rez -append tmp.rsrc -o "#{package_dir}/project-1.2.3-2.x86_64.dmg"

# Source the icon
SetFile -a C "#{package_dir}/project-1.2.3-2.dmg"
SetFile -a C "#{package_dir}/project-1.2.3-2.x86_64.dmg"
EOH

subject.set_dmg_icon
Expand All @@ -174,11 +174,11 @@ module Omnibus

describe '#package_name' do
it 'reflects the packager\'s unmodified package_name' do
expect(subject.package_name).to eq("project-1.2.3-2.dmg")
expect(subject.package_name).to eq("project-1.2.3-2.x86_64.dmg")
end

it 'reflects the packager\'s modified package_name' do
package_basename = "projectsub-1.2.3-3"
package_basename = "projectsub-1.2.3-3.x86_64"
allow(project.packagers_for_system[0]).to receive(:package_name)
.and_return("#{package_basename}.pkg")

Expand Down
8 changes: 4 additions & 4 deletions spec/unit/compressors/tgz_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,25 @@ module Omnibus

describe '#package_name' do
it "returns the name of the packager" do
expect(subject.package_name).to eq("project-1.2.3-2.pkg.tar.gz")
expect(subject.package_name).to eq("project-1.2.3-2.x86_64.pkg.tar.gz")
end
end

describe '#write_tgz' do
before do
File.open("#{staging_dir}/project-1.2.3-2.pkg", "wb") do |f|
File.open("#{staging_dir}/project-1.2.3-2.x86_64.pkg", "wb") do |f|
f.write " " * 1_000_000
end
end

it "generates the file" do
subject.write_tgz
expect("#{staging_dir}/project-1.2.3-2.pkg.tar.gz").to be_a_file
expect("#{staging_dir}/project-1.2.3-2.x86_64.pkg.tar.gz").to be_a_file
end

it "has the correct content" do
subject.write_tgz
file = File.open("#{staging_dir}/project-1.2.3-2.pkg.tar.gz", "rb")
file = File.open("#{staging_dir}/project-1.2.3-2.x86_64.pkg.tar.gz", "rb")
contents = file.read
file.close

Expand Down
2 changes: 2 additions & 0 deletions spec/unit/metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ module Omnibus
it_behaves_like "a version manipulator", "gentoo", "2004.3", "2004.3"
it_behaves_like "a version manipulator", "ios_xr", "6.0.0.14I", "6"
it_behaves_like "a version manipulator", "mac_os_x", "10.9.1", "10.9"
it_behaves_like "a version manipulator", "mac_os_x", "10.15.7", "10.15"
it_behaves_like "a version manipulator", "mac_os_x", "11.2.1", "11"
it_behaves_like "a version manipulator", "nexus", "5.0", "5"
it_behaves_like "a version manipulator", "omnios", "r151010", "r151010"
it_behaves_like "a version manipulator", "openbsd", "5.4.4", "5.4"
Expand Down
24 changes: 20 additions & 4 deletions spec/unit/packagers/pkg_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ module Omnibus
end

describe '#package_name' do
it "includes the name, version, and build iteration" do
expect(subject.package_name).to eq("project-full-name-1.2.3-2.pkg")
it "includes the name, version, build iteration, and architecture" do
expect(subject.package_name).to eq("project-full-name-1.2.3-2.x86_64.pkg")
end
end

Expand Down 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 All @@ -148,7 +164,7 @@ module Omnibus
productbuild \\
--distribution "#{staging_dir}/Distribution" \\
--resources "#{staging_dir}/Resources" \\
"#{package_dir}/project-full-name-1.2.3-2.pkg"
"#{package_dir}/project-full-name-1.2.3-2.x86_64.pkg"
EOH

subject.build_product_pkg
Expand All @@ -166,7 +182,7 @@ module Omnibus
--distribution "#{staging_dir}/Distribution" \\
--resources "#{staging_dir}/Resources" \\
--sign "My Special Identity" \\
"#{package_dir}/project-full-name-1.2.3-2.pkg"
"#{package_dir}/project-full-name-1.2.3-2.x86_64.pkg"
EOH
subject.build_product_pkg
end
Expand Down