omnibus 4.1.0 → 5.0.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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/CHANGELOG.md +22 -0
  4. data/MAINTAINERS.md +2 -1
  5. data/README.md +1 -1
  6. data/lib/omnibus/builder.rb +2 -17
  7. data/lib/omnibus/cli/publish.rb +4 -0
  8. data/lib/omnibus/exceptions.rb +12 -0
  9. data/lib/omnibus/fetchers/net_fetcher.rb +4 -0
  10. data/lib/omnibus/manifest.rb +1 -1
  11. data/lib/omnibus/metadata.rb +13 -4
  12. data/lib/omnibus/packager.rb +1 -0
  13. data/lib/omnibus/packagers/base.rb +1 -0
  14. data/lib/omnibus/packagers/bff.rb +1 -1
  15. data/lib/omnibus/packagers/deb.rb +4 -0
  16. data/lib/omnibus/packagers/msi.rb +168 -55
  17. data/lib/omnibus/packagers/rpm.rb +41 -29
  18. data/lib/omnibus/packagers/solaris.rb +76 -25
  19. data/lib/omnibus/publisher.rb +4 -0
  20. data/lib/omnibus/publishers/artifactory_publisher.rb +19 -8
  21. data/lib/omnibus/sugarable.rb +5 -0
  22. data/lib/omnibus/version.rb +1 -1
  23. data/omnibus.gemspec +1 -1
  24. data/resources/msi/CustomActionFastMsi.CA.dll +0 -0
  25. data/resources/msi/localization-en-us.wxl.erb +4 -0
  26. data/resources/msi/source.wxs.erb +46 -9
  27. data/resources/rpm/spec.erb +0 -1
  28. data/spec/functional/builder_spec.rb +109 -113
  29. data/spec/functional/fetchers/net_fetcher_spec.rb +10 -0
  30. data/spec/unit/metadata_spec.rb +39 -4
  31. data/spec/unit/packagers/bff_spec.rb +9 -0
  32. data/spec/unit/packagers/deb_spec.rb +17 -5
  33. data/spec/unit/packagers/msi_spec.rb +175 -3
  34. data/spec/unit/packagers/rpm_spec.rb +50 -3
  35. data/spec/unit/packagers/solaris_spec.rb +234 -0
  36. data/spec/unit/publisher_spec.rb +14 -0
  37. data/spec/unit/publishers/artifactory_publisher_spec.rb +72 -3
  38. data/spec/unit/sugarable_spec.rb +16 -0
  39. metadata +7 -4
@@ -0,0 +1,234 @@
1
+ require 'spec_helper'
2
+
3
+ module Omnibus
4
+ describe Packager::Solaris do
5
+ let(:project) do
6
+ Project.new.tap do |project|
7
+ project.name('project')
8
+ project.homepage('https://example.com')
9
+ project.install_dir('/opt/project')
10
+ project.build_version('1.2.3')
11
+ project.build_iteration('1')
12
+ project.maintainer('Chef Software')
13
+ end
14
+ end
15
+
16
+ subject { described_class.new(project) }
17
+
18
+ let(:project_root) { File.join(tmp_path, 'project/root') }
19
+ let(:package_dir) { File.join(tmp_path, 'package/dir') }
20
+ let(:staging_dir) { File.join(tmp_path, 'staging/dir') }
21
+ let(:architecture) { 'i86pc' }
22
+
23
+ before do
24
+ # This is here to allow this unit test to run on windows.
25
+ allow(File).to receive(:expand_path).and_wrap_original do |m, *args|
26
+ m.call(*args).sub(/^[A-Za-z]:/, '')
27
+ end
28
+ Config.project_root(project_root)
29
+ Config.package_dir(package_dir)
30
+
31
+ allow(subject).to receive(:staging_dir).and_return(staging_dir)
32
+ create_directory(staging_dir)
33
+
34
+ stub_ohai(platform: 'solaris2', version: '5.11') do |data|
35
+ data['kernel']['machine'] = architecture
36
+ end
37
+ end
38
+
39
+ describe '#id' do
40
+ it 'is :solaris' do
41
+ expect(subject.id).to eq(:solaris)
42
+ end
43
+ end
44
+
45
+ describe '#package_name' do
46
+ it 'includes the name, version, iteration and architecture' do
47
+ expect(subject.package_name).to eq('project-1.2.3-1.i386.solaris')
48
+ end
49
+ end
50
+
51
+ describe '#pkgmk_version' do
52
+ it 'includes the version and iteration' do
53
+ expect(subject.pkgmk_version).to eq('1.2.3-1')
54
+ end
55
+ end
56
+
57
+ describe '#install_dirname' do
58
+ it 'returns the parent directory' do
59
+ expect(subject.install_dirname).to eq('/opt')
60
+ end
61
+ end
62
+
63
+ describe '#install_basename' do
64
+ it 'name of the install directory' do
65
+ expect(subject.install_basename).to eq('project')
66
+ end
67
+ end
68
+
69
+ describe '#write_scripts' do
70
+ context 'when scripts are given' do
71
+ let(:scripts) { %w( postinstall postremove ) }
72
+ before do
73
+ scripts.each do |script_name|
74
+ create_file("#{project_root}/package-scripts/project/#{script_name}") do
75
+ "Contents of #{script_name}"
76
+ end
77
+ end
78
+ end
79
+
80
+ it 'writes the scripts into scripts staging dir' do
81
+ subject.write_scripts
82
+
83
+ scripts.each do |script_name|
84
+ script_file = "#{staging_dir}/#{script_name}"
85
+ contents = File.read(script_file)
86
+ expect(contents).to include("Contents of #{script_name}")
87
+ end
88
+ end
89
+ end
90
+
91
+ context 'when scripts with default omnibus naming are given' do
92
+ let(:default_scripts) { %w( postinst postrm ) }
93
+ before do
94
+ default_scripts.each do |script_name|
95
+ create_file("#{project_root}/package-scripts/project/#{script_name}") do
96
+ "Contents of #{script_name}"
97
+ end
98
+ end
99
+ end
100
+
101
+ it 'writes the scripts into scripts staging dir' do
102
+ subject.write_scripts
103
+
104
+ default_scripts.each do |script_name|
105
+ mapped_name = Packager::Solaris::SCRIPT_MAP[script_name.to_sym]
106
+ script_file = "#{staging_dir}/#{mapped_name}"
107
+ contents = File.read(script_file)
108
+ expect(contents).to include("Contents of #{script_name}")
109
+ end
110
+ end
111
+ end
112
+ end
113
+
114
+ describe '#write_prototype_file' do
115
+ let(:prototype_file) { File.join(staging_dir, 'Prototype') }
116
+
117
+ before do
118
+ allow(subject).to receive(:shellout!)
119
+ end
120
+
121
+ it 'creates the prototype file' do
122
+ subject.write_prototype_file
123
+ contents = File.read(prototype_file)
124
+
125
+ expect(contents).to include(
126
+ <<-EOH.gsub(/^ {12}/, '')
127
+ i pkginfo
128
+ i postinstall
129
+ i postremove
130
+ EOH
131
+ )
132
+ end
133
+
134
+ it 'uses the correct commands' do
135
+ expect(subject).to receive(:shellout!)
136
+ .with("cd /opt && find project -print > #{File.join(staging_dir, 'files')}")
137
+ expect(subject).to receive(:shellout!)
138
+ .with("cd /opt && pkgproto < #{File.join(staging_dir, 'files')} > #{File.join(staging_dir, 'Prototype.files')}")
139
+ expect(subject).to receive(:shellout!)
140
+ .with("awk '{ $5 = \"root\"; $6 = \"root\"; print }' < #{File.join(staging_dir, 'Prototype.files')} >> #{File.join(staging_dir, 'Prototype')}")
141
+
142
+ subject.write_prototype_file
143
+ end
144
+ end
145
+
146
+ describe '#create_solaris_file' do
147
+ it 'uses the correct commands' do
148
+ expect(subject).to receive(:shellout!)
149
+ .with("pkgmk -o -r /opt -d #{staging_dir} -f #{File.join(staging_dir, 'Prototype')}")
150
+ expect(subject).to receive(:shellout!)
151
+ .with("pkgchk -vd #{staging_dir} project")
152
+ expect(subject).to receive(:shellout!)
153
+ .with("pkgtrans #{staging_dir} #{File.join(package_dir, 'project-1.2.3-1.i386.solaris')} project")
154
+
155
+ subject.create_solaris_file
156
+ end
157
+ end
158
+
159
+ describe '#write_pkginfo_file' do
160
+ let(:pkginfo_file) { File.join(staging_dir, 'pkginfo') }
161
+ let(:hostname) { Socket.gethostname }
162
+ let(:now) { Time.now }
163
+
164
+ it 'generates the file' do
165
+ subject.write_pkginfo_file
166
+ expect(pkginfo_file).to be_a_file
167
+ end
168
+
169
+ it 'has the correct content' do
170
+ allow(Time).to receive(:now).and_return(now)
171
+ subject.write_pkginfo_file
172
+ contents = File.read(pkginfo_file)
173
+
174
+ expect(contents).to include("CLASSES=none")
175
+ expect(contents).to include("TZ=PST")
176
+ expect(contents).to include("PATH=/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin")
177
+ expect(contents).to include("BASEDIR=/opt")
178
+ expect(contents).to include("PKG=project")
179
+ expect(contents).to include("NAME=project")
180
+ expect(contents).to include("ARCH=i386")
181
+ expect(contents).to include("VERSION=1.2.3-1")
182
+ expect(contents).to include("CATEGORY=application")
183
+ expect(contents).to include("DESC=")
184
+ expect(contents).to include("VENDOR=Chef Software")
185
+ expect(contents).to include("EMAIL=Chef Software")
186
+ expect(contents).to include("PSTAMP=#{hostname}#{now.utc.iso8601}")
187
+ end
188
+ end
189
+
190
+ describe '#create_solaris_file' do
191
+ before do
192
+ allow(subject).to receive(:shellout!)
193
+ allow(Dir).to receive(:chdir) { |_, &b| b.call }
194
+ end
195
+
196
+ it 'uses the correct commands' do
197
+ expect(subject).to receive(:shellout!)
198
+ .with("pkgmk -o -r /opt -d #{staging_dir} -f #{File.join(staging_dir, 'Prototype')}")
199
+ expect(subject).to receive(:shellout!)
200
+ .with("pkgchk -vd #{staging_dir} project")
201
+ expect(subject).to receive(:shellout!)
202
+ .with("pkgtrans #{staging_dir} #{File.join(package_dir, 'project-1.2.3-1.i386.solaris')} project")
203
+
204
+ subject.create_solaris_file
205
+ end
206
+ end
207
+
208
+ describe '#safe_architecture' do
209
+ context 'the architecture is Intel-based' do
210
+ let(:architecture) { 'i86pc' }
211
+
212
+ it 'returns `i386`' do
213
+ expect(subject.safe_architecture).to eq('i386')
214
+ end
215
+ end
216
+
217
+ context 'the architecture is SPARC-based' do
218
+ let(:architecture) { 'sun4v' }
219
+
220
+ it 'returns `sparc`' do
221
+ expect(subject.safe_architecture).to eq('sparc')
222
+ end
223
+ end
224
+
225
+ context 'anything else' do
226
+ let(:architecture) { 'FOO' }
227
+
228
+ it 'returns the value from Ohai' do
229
+ expect(subject.safe_architecture).to eq('FOO')
230
+ end
231
+ end
232
+ end
233
+ end
234
+ end
@@ -107,6 +107,20 @@ module Omnibus
107
107
  end
108
108
  end
109
109
  end
110
+
111
+ context 'there are no packages to publish' do
112
+ before do
113
+ allow(FileSyncer).to receive(:glob)
114
+ .with(pattern)
115
+ .and_return([])
116
+ end
117
+
118
+ it 'prints a warning' do
119
+ output = capture_logging { subject.packages }
120
+ expect(output).to include('No packages found, skipping publish')
121
+ end
122
+ end
123
+
110
124
  end
111
125
 
112
126
  describe '#publish' do
@@ -3,7 +3,6 @@ require 'spec_helper'
3
3
  module Omnibus
4
4
  describe ArtifactoryPublisher do
5
5
  let(:path) { '/path/to/files/*.deb' }
6
-
7
6
  let(:repository) { 'REPO' }
8
7
 
9
8
  let(:package) do
@@ -27,6 +26,8 @@ module Omnibus
27
26
  platform_version: '14.04',
28
27
  arch: 'x86_64',
29
28
  sha1: 'SHA1',
29
+ sha256: 'SHA256',
30
+ sha512: 'SHA512',
30
31
  md5: 'ABCDEF123456',
31
32
  )
32
33
  end
@@ -36,6 +37,29 @@ module Omnibus
36
37
  let(:artifact) { double('Artifactory::Resource::Artifact', upload: nil) }
37
38
  let(:build) { double('Artifactory::Resource::Build') }
38
39
 
40
+ let(:transformed_metadata_values) do
41
+ {
42
+ "omnibus.architecture" => "x86_64",
43
+ "omnibus.iteration" => 1,
44
+ "omnibus.md5" => "ABCDEF123456",
45
+ "omnibus.platform" => "ubuntu",
46
+ "omnibus.platform_version" => "14.04",
47
+ "omnibus.project" => "chef",
48
+ "omnibus.sha1" => "SHA1",
49
+ "omnibus.sha256" => "SHA256",
50
+ "omnibus.sha512" => "SHA512",
51
+ "omnibus.version" => "11.0.6",
52
+ }
53
+ end
54
+ let(:build_values) do
55
+ {
56
+ "build.name" => "chef",
57
+ "build.number" => "11.0.6",
58
+ }
59
+ end
60
+
61
+ let(:options) { {repository: repository} }
62
+
39
63
  before do
40
64
  allow(subject).to receive(:client).and_return(client)
41
65
  allow(subject).to receive(:artifact_for).and_return(artifact)
@@ -44,7 +68,7 @@ module Omnibus
44
68
  allow(build).to receive(:save)
45
69
  end
46
70
 
47
- subject { described_class.new(path, repository: repository) }
71
+ subject { described_class.new(path, options) }
48
72
 
49
73
  describe '#publish' do
50
74
  before do
@@ -62,7 +86,7 @@ module Omnibus
62
86
  expect(artifact).to receive(:upload).with(
63
87
  repository,
64
88
  'com/getchef/chef/11.0.6/ubuntu/14.04/chef.deb',
65
- an_instance_of(Hash),
89
+ hash_including(transformed_metadata_values),
66
90
  ).once
67
91
 
68
92
  subject.publish
@@ -118,6 +142,51 @@ module Omnibus
118
142
  subject.publish
119
143
  end
120
144
  end
145
+
146
+ context 'additional properties are provided' do
147
+ let(:delivery_props) do
148
+ {
149
+ 'delivery.change' => '4dbf38de-3e82-439f-8090-c5f3e11aeba6',
150
+ 'delivery.sha' => 'ec1cb62616350176fc6fd9b1dc4ad3153caa0791',
151
+ }
152
+ end
153
+ let(:options) do
154
+ {
155
+ properties: delivery_props,
156
+ repository: repository,
157
+ }
158
+ end
159
+
160
+ it 'uploads the package with the provided properties' do
161
+ expect(artifact).to receive(:upload).with(
162
+ repository,
163
+ 'com/getchef/chef/11.0.6/ubuntu/14.04/chef.deb',
164
+ hash_including(transformed_metadata_values.merge(delivery_props)),
165
+ ).once
166
+
167
+ subject.publish
168
+ end
169
+ end
170
+ end
171
+
172
+ describe '#metadata_properties_for' do
173
+ it 'returns the transformed package metadata values' do
174
+ expect(subject.send(:metadata_properties_for, package)).to include(transformed_metadata_values.merge(build_values))
175
+ end
176
+
177
+ context ':build_record is false' do
178
+ let(:options) do
179
+ {
180
+ build_record: false,
181
+ repository: repository,
182
+ }
183
+ end
184
+
185
+ it 'does not include `build.*` values' do
186
+ expect(subject.send(:metadata_properties_for, package)).to include(transformed_metadata_values)
187
+ expect(subject.send(:metadata_properties_for, package)).to_not include(build_values)
188
+ end
189
+ end
121
190
  end
122
191
  end
123
192
  end
@@ -7,6 +7,22 @@ module Omnibus
7
7
  end
8
8
  end
9
9
 
10
+ describe Metadata do
11
+ it 'extends Sugarable' do
12
+ expect(described_class.singleton_class.included_modules).to include(Sugarable)
13
+ end
14
+
15
+ it 'includes Sugarable' do
16
+ expect(described_class.ancestors).to include(Sugarable)
17
+ end
18
+ end
19
+
20
+ describe Packager::Base do
21
+ it 'is a sugarable' do
22
+ expect(described_class.ancestors).to include(Sugarable)
23
+ end
24
+ end
25
+
10
26
  describe Project do
11
27
  it 'is a sugarable' do
12
28
  expect(described_class.ancestors).to include(Sugarable)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omnibus
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef Software, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-01 00:00:00.000000000 Z
11
+ date: 2015-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-sugar
@@ -374,6 +374,7 @@ files:
374
374
  - resources/makeself/makeself-header.sh
375
375
  - resources/makeself/makeself.sh
376
376
  - resources/makeself/makeselfinst.erb
377
+ - resources/msi/CustomActionFastMsi.CA.dll
377
378
  - resources/msi/assets/LICENSE.rtf
378
379
  - resources/msi/assets/banner_background.bmp
379
380
  - resources/msi/assets/dialog_background.bmp
@@ -444,6 +445,7 @@ files:
444
445
  - spec/unit/packagers/msi_spec.rb
445
446
  - spec/unit/packagers/pkg_spec.rb
446
447
  - spec/unit/packagers/rpm_spec.rb
448
+ - spec/unit/packagers/solaris_spec.rb
447
449
  - spec/unit/project_spec.rb
448
450
  - spec/unit/publisher_spec.rb
449
451
  - spec/unit/publishers/artifactory_publisher_spec.rb
@@ -466,7 +468,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
466
468
  requirements:
467
469
  - - ">="
468
470
  - !ruby/object:Gem::Version
469
- version: 1.9.1
471
+ version: '2'
470
472
  required_rubygems_version: !ruby/object:Gem::Requirement
471
473
  requirements:
472
474
  - - ">="
@@ -474,7 +476,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
474
476
  version: '0'
475
477
  requirements: []
476
478
  rubyforge_project:
477
- rubygems_version: 2.4.4
479
+ rubygems_version: 2.2.2
478
480
  signing_key:
479
481
  specification_version: 4
480
482
  summary: Omnibus is a framework for building self-installing, full-stack software
@@ -540,6 +542,7 @@ test_files:
540
542
  - spec/unit/packagers/msi_spec.rb
541
543
  - spec/unit/packagers/pkg_spec.rb
542
544
  - spec/unit/packagers/rpm_spec.rb
545
+ - spec/unit/packagers/solaris_spec.rb
543
546
  - spec/unit/project_spec.rb
544
547
  - spec/unit/publisher_spec.rb
545
548
  - spec/unit/publishers/artifactory_publisher_spec.rb