omnibus 5.3.0 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ module Omnibus
4
+ describe Packager do
5
+ describe '.for_current_system' do
6
+ context 'on Mac OS X' do
7
+ before { stub_ohai(platform: 'mac_os_x', version: '10.9.2') }
8
+ it 'prefers PKG' do
9
+ expect(described_class.for_current_system).to eq(Packager::PKG)
10
+ end
11
+ end
12
+
13
+ context 'on Windows' do
14
+ before { stub_ohai(platform: 'windows', version: '2012') }
15
+ it 'prefers MSI' do
16
+ expect(described_class.for_current_system).to eq(Packager::MSI)
17
+ end
18
+ end
19
+
20
+ context 'on Solaris 11' do
21
+ before { stub_ohai(platform: 'solaris2', version: '5.11') }
22
+ it 'prefers IPS' do
23
+ expect(described_class.for_current_system).to eq(Packager::IPS)
24
+ end
25
+ end
26
+
27
+ context 'on Solaris 10' do
28
+ before { stub_ohai(platform: 'solaris2', version: '5.10') }
29
+ it 'prefers Solaris' do
30
+ expect(described_class.for_current_system).to eq(Packager::Solaris)
31
+ end
32
+ end
33
+
34
+
35
+ context 'on aix' do
36
+ before { stub_ohai(platform: 'aix', version: '7.1') }
37
+ it 'prefers BFF' do
38
+ expect(described_class.for_current_system).to eq(Packager::BFF)
39
+ end
40
+ end
41
+
42
+ context 'on fedora' do
43
+ before { stub_ohai(platform: 'fedora', version: '20') }
44
+ it 'prefers RPM' do
45
+ expect(described_class.for_current_system).to eq(Packager::RPM)
46
+ end
47
+ end
48
+
49
+ context 'on debian' do
50
+ before { stub_ohai(platform: 'debian', version: '7.2') }
51
+ it 'prefers RPM' do
52
+ expect(described_class.for_current_system).to eq(Packager::DEB)
53
+ end
54
+ end
55
+
56
+ context 'on suse' do
57
+ before { stub_ohai(platform: 'suse', version: '12.0') }
58
+ it 'prefers RPM' do
59
+ expect(described_class.for_current_system).to eq(Packager::RPM)
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,222 @@
1
+ require 'spec_helper'
2
+ require 'pry'
3
+
4
+ module Omnibus
5
+ describe Packager::IPS do
6
+ let(:project) do
7
+ Project.new.tap do |project|
8
+ project.name('project')
9
+ project.homepage('https://example.com')
10
+ project.install_dir('/opt/project')
11
+ project.build_version('1.2.3')
12
+ project.build_iteration('2')
13
+ project.maintainer('Chef Software')
14
+ end
15
+ end
16
+
17
+ subject { described_class.new(project) }
18
+
19
+ let(:project_root) { File.join(tmp_path, 'project/root') }
20
+ let(:package_dir) { File.join(tmp_path, 'package/dir') }
21
+ let(:staging_dir) { File.join(tmp_path, 'staging/dir') }
22
+ let(:source_dir) { File.join(staging_dir, 'proto_install')}
23
+ let(:repo_dir) { File.join(staging_dir, 'publish/repo')}
24
+ let(:architecture) { 'i86pc' }
25
+ let(:shellout) { double("Mixlib::ShellOut", :run_command => true, :error! => nil) }
26
+
27
+ before do
28
+ Config.project_root(project_root)
29
+ Config.package_dir(package_dir)
30
+
31
+ allow(Mixlib::ShellOut).to receive(:new).and_return(shellout)
32
+ allow(subject).to receive(:staging_dir).and_return(staging_dir)
33
+ create_directory(staging_dir)
34
+ create_directory(source_dir)
35
+ create_directory(repo_dir)
36
+
37
+ stub_ohai(platform: 'solaris2', version: '5.11') do |data|
38
+ data['kernel']['machine'] = architecture
39
+ end
40
+ end
41
+
42
+ describe '#publisher_prefix' do
43
+ it 'is a DSL method' do
44
+ expect(subject).to have_exposed_method(:publisher_prefix)
45
+ end
46
+
47
+ it 'has a default value' do
48
+ expect(subject.publisher_prefix).to eq('Omnibus')
49
+ end
50
+ end
51
+
52
+ it '#id is :IPS' do
53
+ expect(subject.id).to eq(:ips)
54
+ end
55
+
56
+ describe '#package_name' do
57
+ it 'should create correct package name' do
58
+ expect(subject.package_name).to eq('project.p5p')
59
+ end
60
+ end
61
+
62
+ describe '#fmri_package_name' do
63
+ it 'should create correct fmri package name' do
64
+ expect(subject.fmri_package_name).to eq ('project@1.2.3,5.11-2')
65
+ end
66
+ end
67
+
68
+ describe '#pkg_metadata_file' do
69
+ it 'is created inside the staging_dir' do
70
+ expect(subject.pkg_metadata_file).to eq("#{subject.staging_dir}/gen.manifestfile")
71
+ end
72
+ end
73
+
74
+ describe '#pkg_manifest_file' do
75
+ it 'is created inside the staging_dir' do
76
+ expect(subject.pkg_manifest_file).to eq("#{subject.staging_dir}/#{subject.safe_base_package_name}.p5m")
77
+ end
78
+ end
79
+
80
+ describe '#repo_dir' do
81
+ it 'is created inside the staging_dir' do
82
+ expect(subject.repo_dir).to eq("#{subject.staging_dir}/publish/repo")
83
+ end
84
+ end
85
+
86
+ describe '#source_dir' do
87
+ it 'is created inside the staging_dir' do
88
+ expect(subject.source_dir).to eq("#{subject.staging_dir}/proto_install")
89
+ end
90
+ end
91
+
92
+ describe '#safe_base_package_name' do
93
+ context 'when the project name is "safe"' do
94
+ it 'returns the value without logging a message' do
95
+ expect(subject.safe_base_package_name).to eq('project')
96
+ expect(subject).to_not receive(:log)
97
+ end
98
+ end
99
+
100
+ context 'when the project name has invalid characters' do
101
+ before { project.name("Pro$ject123.for-realz_2") }
102
+
103
+ it 'returns the value while logging a message' do
104
+ output = capture_logging do
105
+ expect(subject.safe_base_package_name).to eq('pro-ject123.for-realz-2')
106
+ end
107
+
108
+ expect(output).to include("The `name' component of IPS package names can only include")
109
+ end
110
+ end
111
+ end
112
+
113
+ describe '#safe_architecture' do
114
+ context 'the architecture is Intel-based' do
115
+ let(:architecture) { 'i86pc' }
116
+
117
+ it 'returns `i386`' do
118
+ expect(subject.safe_architecture).to eq('i386')
119
+ end
120
+ end
121
+
122
+ context 'the architecture is SPARC-based' do
123
+ let(:architecture) { 'sun4v' }
124
+
125
+ it 'returns `sparc`' do
126
+ expect(subject.safe_architecture).to eq('sparc')
127
+ end
128
+ end
129
+
130
+ context 'anything else' do
131
+ let(:architecture) { 'FOO' }
132
+
133
+ it 'returns the value from Ohai' do
134
+ expect(subject.safe_architecture).to eq('FOO')
135
+ end
136
+ end
137
+ end
138
+
139
+ describe "#write_transform_file" do
140
+ let(:transform_file) { File.join(staging_dir, "doc-transform") }
141
+
142
+ it "creates the transform file" do
143
+ subject.write_transform_file
144
+ transform_file_contents = File.read(transform_file)
145
+ expect(transform_file_contents).to include("<transform dir path=opt$ -> edit group bin sys>")
146
+ expect(transform_file_contents).to include("<transform file depend -> edit pkg.debug.depend.file ruby env>")
147
+ end
148
+ end
149
+
150
+ describe "#write_pkg_metadata" do
151
+ it "should create metadata correctly" do
152
+ subject.write_pkg_metadata
153
+ manifest_file = File.join(staging_dir, "gen.manifestfile")
154
+ manifest_file_contents = File.read(manifest_file)
155
+ expect(File.exist?(manifest_file)).to be(true)
156
+ expect(manifest_file_contents).to include("set name=pkg.fmri value=developer/versioning/project@1.2.3,5.11-2")
157
+ expect(manifest_file_contents).to include("set name=variant.arch value=i386")
158
+ end
159
+ end
160
+
161
+ describe "#generate_pkg_contents" do
162
+ it "uses the correct commands" do
163
+ expect(subject).to receive(:shellout!)
164
+ .with("pkgsend generate #{staging_dir}/proto_install | pkgfmt > #{staging_dir}/project.p5m.1")
165
+ expect(subject).to receive(:shellout!)
166
+ .with("pkgmogrify -DARCH=`uname -p` #{staging_dir}/project.p5m.1 #{staging_dir}/gen.manifestfile #{staging_dir}/doc-transform | pkgfmt > #{staging_dir}/project.p5m.2")
167
+ subject.generate_pkg_contents
168
+ end
169
+ end
170
+
171
+ describe "#generate_pkg_deps" do
172
+ it "uses the correct commands" do
173
+ expect(subject).to receive(:shellout!)
174
+ .with("pkgdepend generate -md #{staging_dir}/proto_install #{staging_dir}/project.p5m.2 | pkgfmt > #{staging_dir}/project.p5m.3")
175
+ expect(subject).to receive(:shellout!)
176
+ .with("pkgmogrify -DARCH=`uname -p` #{staging_dir}/project.p5m.3 #{staging_dir}/doc-transform | pkgfmt > #{staging_dir}/project.p5m.4")
177
+ expect(subject).to receive(:shellout!)
178
+ .with("pkgdepend resolve -m #{staging_dir}/project.p5m.4")
179
+ subject.generate_pkg_deps
180
+ end
181
+ end
182
+
183
+ describe "#validate_pkg_manifest" do
184
+ it "uses the correct commands" do
185
+ expect(subject).to receive(:shellout!)
186
+ .with("pkglint -c /tmp/lint-cache -r http://pkg.oracle.com/solaris/release #{staging_dir}/project.p5m.4.res")
187
+ subject.validate_pkg_manifest
188
+ end
189
+ end
190
+
191
+ describe "#create_ips_repo" do
192
+ it "uses the correct commands" do
193
+ expect(subject).to receive(:shellout!)
194
+ .with("pkgrepo create #{staging_dir}/publish/repo")
195
+ subject.create_ips_repo
196
+ end
197
+ end
198
+
199
+ describe "#publish_ips_pkg" do
200
+ it "uses the correct commands" do
201
+ expect(subject).to receive(:shellout!)
202
+ .with("pkgrepo -s #{staging_dir}/publish/repo set publisher/prefix=Omnibus")
203
+ expect(subject).to receive(:shellout!)
204
+ .with("pkgsend publish -s #{staging_dir}/publish/repo -d #{staging_dir}/proto_install #{staging_dir}/project.p5m.4.res")
205
+
206
+ expect(shellout).to receive(:stdout)
207
+ subject.publish_ips_pkg
208
+ end
209
+ end
210
+
211
+ describe "#export_pkg_archive_file" do
212
+ it "uses the correct commands" do
213
+ expect(subject).to receive(:shellout!)
214
+ .with("pkgrecv -s #{staging_dir}/publish/repo -a -d #{package_dir}/project.p5p project")
215
+
216
+ expect(shellout).to receive(:stdout)
217
+ subject.export_pkg_archive_file
218
+ end
219
+ end
220
+
221
+ end
222
+ end
@@ -67,11 +67,73 @@ module Omnibus
67
67
  version: '11.0.6',
68
68
  iteration: 1,
69
69
  basename: 'chef.deb',
70
+ license: 'Apache-2.0',
70
71
  platform: 'ubuntu',
71
72
  platform_version: '12.04',
72
73
  arch: 'x86_64',
73
74
  sha1: 'SHA1',
74
75
  md5: 'ABCDEF123456',
76
+ version_manifest: {
77
+ manifest_format: 1,
78
+ build_version: '11.0.6',
79
+ build_git_revision: '2e763ac957b308ba95cef256c2491a5a55a163cc',
80
+ software: {
81
+ zlib: {
82
+ locked_source: {
83
+ md5: '44d667c142d7cda120332623eab69f40',
84
+ url: 'http://iweb.dl.sourceforge.net/project/libpng/zlib/1.2.8/zlib-1.2.8.tar.gz',
85
+ },
86
+ locked_version: '1.2.8',
87
+ source_type: 'url',
88
+ described_version: '1.2.8',
89
+ license: 'Zlib',
90
+ },
91
+ openssl: {
92
+ locked_source: {
93
+ md5: '562986f6937aabc7c11a6d376d8a0d26',
94
+ extract: 'lax_tar',
95
+ url: 'http://iweb.dl.sourceforge.net/project/libpng/zlib/1.2.8/zlib-1.2.8.tar.gz',
96
+ },
97
+ locked_version: '1.0.1s',
98
+ source_type: 'url',
99
+ described_version: '1.0.1s',
100
+ license: 'OpenSSL',
101
+ },
102
+ ruby: {
103
+ locked_source: {
104
+ md5: '091b62f0a9796a3c55de2a228a0e6ef3',
105
+ url: 'https://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.8.tar.gz',
106
+ },
107
+ locked_version: '2.1.8',
108
+ source_type: 'url',
109
+ described_version: '2.1.8',
110
+ license: 'BSD-2-Clause',
111
+ },
112
+ ohai: {
113
+ locked_source: {
114
+ git: 'https://github.com/opscode/ohai.git'
115
+ },
116
+ locked_version: 'fec0959aa5da5ce7ba0e07740dbc08546a8f53f0',
117
+ source_type: 'git',
118
+ described_version: 'master',
119
+ license: 'Apache-2.0',
120
+ },
121
+ chef: {
122
+ locked_source: {
123
+ path: '/home/jenkins/workspace/chef-build/architecture/x86_64/platform/ubuntu-10.04/project/chef/role/builder/omnibus/files/../..',
124
+ options: {
125
+ exclude: [
126
+ 'omnibus/vendor',
127
+ ],
128
+ },
129
+ },
130
+ locked_version: 'local_source',
131
+ source_type: 'path',
132
+ described_version: 'local_source',
133
+ license: 'Apache-2.0',
134
+ },
135
+ }
136
+ }
75
137
  )
76
138
  end
77
139
 
@@ -21,6 +21,7 @@ module Omnibus
21
21
  homepage: 'https://www.getchef.com',
22
22
  version: '11.0.6',
23
23
  iteration: 1,
24
+ license: 'Apache-2.0',
24
25
  basename: 'chef.deb',
25
26
  platform: 'ubuntu',
26
27
  platform_version: '14.04',
@@ -29,6 +30,67 @@ module Omnibus
29
30
  sha256: 'SHA256',
30
31
  sha512: 'SHA512',
31
32
  md5: 'ABCDEF123456',
33
+ version_manifest: {
34
+ manifest_format: 1,
35
+ build_version: '11.0.6',
36
+ build_git_revision: '2e763ac957b308ba95cef256c2491a5a55a163cc',
37
+ software: {
38
+ zlib: {
39
+ locked_source: {
40
+ md5: '44d667c142d7cda120332623eab69f40',
41
+ url: 'http://iweb.dl.sourceforge.net/project/libpng/zlib/1.2.8/zlib-1.2.8.tar.gz',
42
+ },
43
+ locked_version: '1.2.8',
44
+ source_type: 'url',
45
+ described_version: '1.2.8',
46
+ license: 'Zlib',
47
+ },
48
+ openssl: {
49
+ locked_source: {
50
+ md5: '562986f6937aabc7c11a6d376d8a0d26',
51
+ extract: 'lax_tar',
52
+ url: 'http://iweb.dl.sourceforge.net/project/libpng/zlib/1.2.8/zlib-1.2.8.tar.gz',
53
+ },
54
+ locked_version: '1.0.1s',
55
+ source_type: 'url',
56
+ described_version: '1.0.1s',
57
+ license: 'OpenSSL',
58
+ },
59
+ ruby: {
60
+ locked_source: {
61
+ md5: '091b62f0a9796a3c55de2a228a0e6ef3',
62
+ url: 'https://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.8.tar.gz',
63
+ },
64
+ locked_version: '2.1.8',
65
+ source_type: 'url',
66
+ described_version: '2.1.8',
67
+ license: 'BSD-2-Clause',
68
+ },
69
+ ohai: {
70
+ locked_source: {
71
+ git: 'https://github.com/opscode/ohai.git'
72
+ },
73
+ locked_version: 'fec0959aa5da5ce7ba0e07740dbc08546a8f53f0',
74
+ source_type: 'git',
75
+ described_version: 'master',
76
+ license: 'Apache-2.0',
77
+ },
78
+ chef: {
79
+ locked_source: {
80
+ path: '/home/jenkins/workspace/chef-build/architecture/x86_64/platform/ubuntu-10.04/project/chef/role/builder/omnibus/files/../..',
81
+ options: {
82
+ exclude: [
83
+ 'omnibus/vendor',
84
+ ],
85
+ },
86
+ },
87
+ locked_version: 'local_source',
88
+ source_type: 'path',
89
+ described_version: 'local_source',
90
+ license: 'Apache-2.0',
91
+ },
92
+ }
93
+ }
32
94
  )
33
95
  end
34
96
 
@@ -37,7 +99,7 @@ module Omnibus
37
99
  let(:artifact) { double('Artifactory::Resource::Artifact', upload: nil) }
38
100
  let(:build) { double('Artifactory::Resource::Build') }
39
101
 
40
- let(:transformed_metadata_values) do
102
+ let(:package_properties) do
41
103
  {
42
104
  "omnibus.architecture" => "x86_64",
43
105
  "omnibus.iteration" => 1,
@@ -49,8 +111,13 @@ module Omnibus
49
111
  "omnibus.sha256" => "SHA256",
50
112
  "omnibus.sha512" => "SHA512",
51
113
  "omnibus.version" => "11.0.6",
114
+ "omnibus.license" => "Apache-2.0",
52
115
  }
53
116
  end
117
+ let(:metadata_json_properites) do
118
+ # we don't attache checksum properties to the *.metadata.json
119
+ package_properties.delete_if { |k,v| k =~ /md5|sha/ }
120
+ end
54
121
  let(:build_values) do
55
122
  {
56
123
  "build.name" => "chef",
@@ -86,7 +153,17 @@ module Omnibus
86
153
  expect(artifact).to receive(:upload).with(
87
154
  repository,
88
155
  'com/getchef/chef/11.0.6/ubuntu/14.04/chef.deb',
89
- hash_including(transformed_metadata_values),
156
+ hash_including(package_properties),
157
+ ).once
158
+
159
+ subject.publish
160
+ end
161
+
162
+ it "uploads the package's associated *.metadata.json" do
163
+ expect(artifact).to receive(:upload).with(
164
+ repository,
165
+ 'com/getchef/chef/11.0.6/ubuntu/14.04/chef.deb.metadata.json',
166
+ hash_including(metadata_json_properites),
90
167
  ).once
91
168
 
92
169
  subject.publish
@@ -161,7 +238,7 @@ module Omnibus
161
238
  expect(artifact).to receive(:upload).with(
162
239
  repository,
163
240
  'com/getchef/chef/11.0.6/ubuntu/14.04/chef.deb',
164
- hash_including(transformed_metadata_values.merge(delivery_props)),
241
+ hash_including(package_properties.merge(delivery_props)),
165
242
  ).once
166
243
 
167
244
  subject.publish
@@ -171,7 +248,7 @@ module Omnibus
171
248
 
172
249
  describe '#metadata_properties_for' do
173
250
  it 'returns the transformed package metadata values' do
174
- expect(subject.send(:metadata_properties_for, package)).to include(transformed_metadata_values.merge(build_values))
251
+ expect(subject.send(:metadata_properties_for, package)).to include(package_properties.merge(build_values))
175
252
  end
176
253
 
177
254
  context ':build_record is false' do
@@ -183,7 +260,7 @@ module Omnibus
183
260
  end
184
261
 
185
262
  it 'does not include `build.*` values' do
186
- expect(subject.send(:metadata_properties_for, package)).to include(transformed_metadata_values)
263
+ expect(subject.send(:metadata_properties_for, package)).to include(package_properties)
187
264
  expect(subject.send(:metadata_properties_for, package)).to_not include(build_values)
188
265
  end
189
266
  end