Commit 3fed9317 authored by Seth Chisamore's avatar Seth Chisamore

Merge pull request #555 from chef/schisamo/solaris-arch-metadata-fix

Ensure metadata.json returns the correct Solaris arch value
parents dbdf0551 67fe6ed7
......@@ -18,6 +18,9 @@ require 'json'
module Omnibus
class Metadata
extend Sugarable
include Sugarable
class << self
#
# Render the metadata for the package at the given path, generated by the
......@@ -108,8 +111,14 @@ module Omnibus
# @return [String]
#
def arch
if (Ohai['platform'] == 'windows') && (Config.windows_arch.to_sym == :x86)
if windows? && windows_arch_i386?
'i386'
elsif solaris?
if intel?
'i386'
elsif sparc?
'sparc'
end
else
Ohai['kernel']['machine']
end
......@@ -132,9 +141,9 @@ module Omnibus
# the platform family short name
#
def platform_shortname
if Ohai['platform_family'] == 'rhel'
if rhel?
'el'
elsif Ohai['platform'] == 'suse'
elsif suse?
'sles'
else
Ohai['platform']
......
......@@ -30,6 +30,11 @@ require 'chef/sugar/vagrant'
module Omnibus
module Sugarable
def self.extended(base)
base.send(:extend, Chef::Sugar::DSL)
base.send(:extend, Omnibus::Sugar)
end
def self.included(base)
base.send(:include, Chef::Sugar::DSL)
base.send(:include, Omnibus::Sugar)
......
......@@ -22,18 +22,51 @@ module Omnibus
subject { described_class.new(package, data) }
describe '.arch' do
it 'returns the architecture' do
let(:architecture) { 'x86_64' }
before do
stub_ohai(platform: 'ubuntu', version: '12.04') do |data|
data['kernel']['machine'] = 'x86_64'
data['kernel']['machine'] = architecture
end
end
it 'returns the architecture' do
expect(described_class.arch).to eq('x86_64')
end
context 'on solaris' do
before do
stub_ohai(platform: 'solaris2', version: '5.11') do |data|
data['platform'] = 'solaris2'
data['kernel']['machine'] = architecture
end
end
context 'architecture is Intel-based' do
let(:architecture) { 'i86pc' }
it 'returns i386' do
expect(described_class.arch).to eq('i386')
end
end
context 'architecture is SPARC-based' do
let(:architecture) { 'sun4v' }
it 'returns sparc' do
expect(described_class.arch).to eq('sparc')
end
end
end
context 'on windows' do
it 'returns a 32-bit value based on Config.windows_arch being set to x86' do
before do
stub_ohai(platform: 'windows', version: '2012R2') do |data|
data['kernel']['machine'] = 'x86_64'
data['kernel']['machine'] = architecture
end
end
it 'returns a 32-bit value based on Config.windows_arch being set to x86' do
expect(Config).to receive(:windows_arch).and_return(:x86)
expect(described_class.arch).to eq('i386')
end
......
......@@ -7,6 +7,22 @@ module Omnibus
end
end
describe Metadata do
it 'extends Sugarable' do
expect(described_class.singleton_class.included_modules).to include(Sugarable)
end
it 'includes Sugarable' do
expect(described_class.ancestors).to include(Sugarable)
end
end
describe Packager::Base do
it 'is a sugarable' do
expect(described_class.ancestors).to include(Sugarable)
end
end
describe Project do
it 'is a sugarable' do
expect(described_class.ancestors).to include(Sugarable)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment