omnibus 4.0.0.beta.1 → 4.0.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -0
  3. data/docs/Building on RHEL.md +1 -0
  4. data/lib/omnibus/builder.rb +48 -1
  5. data/lib/omnibus/config.rb +13 -0
  6. data/lib/omnibus/digestable.rb +2 -2
  7. data/lib/omnibus/exceptions.rb +21 -0
  8. data/lib/omnibus/fetchers/git_fetcher.rb +75 -9
  9. data/lib/omnibus/fetchers/net_fetcher.rb +5 -3
  10. data/lib/omnibus/generator.rb +0 -13
  11. data/{resources/bff/postinstall.sh → lib/omnibus/generator_files/package_scripts/makeselfinst.erb} +0 -0
  12. data/lib/omnibus/packagers/base.rb +25 -1
  13. data/lib/omnibus/packagers/bff.rb +99 -12
  14. data/lib/omnibus/packagers/deb.rb +10 -8
  15. data/lib/omnibus/packagers/makeself.rb +24 -16
  16. data/lib/omnibus/packagers/msi.rb +6 -5
  17. data/lib/omnibus/packagers/pkg.rb +59 -10
  18. data/lib/omnibus/packagers/rpm.rb +42 -25
  19. data/lib/omnibus/packagers/solaris.rb +5 -5
  20. data/lib/omnibus/project.rb +54 -5
  21. data/lib/omnibus/software.rb +37 -39
  22. data/lib/omnibus/version.rb +1 -1
  23. data/omnibus.gemspec +1 -0
  24. data/resources/bff/gen.template.erb +3 -2
  25. data/resources/rpm/signing.erb +1 -1
  26. data/spec/functional/builder_spec.rb +75 -3
  27. data/spec/functional/fetchers/git_fetcher_spec.rb +31 -2
  28. data/spec/support/examples.rb +8 -2
  29. data/spec/support/git_helpers.rb +8 -0
  30. data/spec/unit/builder_spec.rb +6 -0
  31. data/spec/unit/config_spec.rb +1 -0
  32. data/spec/unit/generator_spec.rb +0 -12
  33. data/spec/unit/packagers/base_spec.rb +16 -0
  34. data/spec/unit/packagers/bff_spec.rb +58 -5
  35. data/spec/unit/packagers/deb_spec.rb +15 -3
  36. data/spec/unit/packagers/makeself_spec.rb +56 -9
  37. data/spec/unit/packagers/pkg_spec.rb +57 -4
  38. data/spec/unit/packagers/rpm_spec.rb +38 -23
  39. data/spec/unit/project_spec.rb +16 -5
  40. data/spec/unit/software_spec.rb +0 -1
  41. metadata +18 -6
  42. data/resources/bff/unpostinstall.sh +0 -0
  43. data/resources/makeself/post_extract.sh.erb +0 -27
@@ -33,6 +33,14 @@ module Omnibus
33
33
  git %|remote add origin "#{remote_url}"|
34
34
  git %|push origin master|
35
35
 
36
+ options[:annotated_tags].each do |tag|
37
+ File.open('tag', 'w') { |f| f.write(tag) }
38
+ git %|add tag|
39
+ git %|commit -am "Create tag #{tag}"|
40
+ git %|tag "#{tag}" -m "#{tag}"|
41
+ git %|push origin "#{tag}"|
42
+ end if options[:annotated_tags]
43
+
36
44
  options[:tags].each do |tag|
37
45
  File.open('tag', 'w') { |f| f.write(tag) }
38
46
  git %|add tag|
@@ -48,6 +48,12 @@ module Omnibus
48
48
  end
49
49
  end
50
50
 
51
+ describe '#appbundle' do
52
+ it 'is a DSL method' do
53
+ expect(subject).to have_exposed_method(:appbundle)
54
+ end
55
+ end
56
+
51
57
  describe '#block' do
52
58
  it 'is a DSL method' do
53
59
  expect(subject).to have_exposed_method(:block)
@@ -41,6 +41,7 @@ module Omnibus
41
41
  include_examples 'a configurable', :append_timestamp, true
42
42
  include_examples 'a configurable', :build_retries, 0
43
43
  include_examples 'a configurable', :use_git_caching, true
44
+ include_examples 'a configurable', :fetcher_read_timeout, 60
44
45
 
45
46
  describe '#workers' do
46
47
  context 'when the Ohai data is not present' do
@@ -53,8 +53,6 @@ module Omnibus
53
53
 
54
54
  expect(structure).to include(*%w(
55
55
  omnibus-name/resources/bff/gen.template.erb
56
- omnibus-name/resources/bff/postinstall.sh
57
- omnibus-name/resources/bff/unpostinstall.sh
58
56
  ))
59
57
  end
60
58
  end
@@ -82,16 +80,6 @@ module Omnibus
82
80
  end
83
81
  end
84
82
 
85
- context 'with the --makeself-assets flag' do
86
- it 'generates the proper file structure' do
87
- Generator.new(['name'], path: tmp_path, makeself_assets: true).invoke_all
88
-
89
- expect(structure).to include(*%w(
90
- omnibus-name/resources/makeself/post_extract.sh.erb
91
- ))
92
- end
93
- end
94
-
95
83
  context 'with the --msi-assets flag' do
96
84
  it 'generates the proper file structure' do
97
85
  Generator.new(['name'], path: tmp_path, msi_assets: true).invoke_all
@@ -71,6 +71,22 @@ module Omnibus
71
71
  end
72
72
  end
73
73
 
74
+ describe '#install_dir' do
75
+ it 'is a DSL method' do
76
+ expect(subject).to have_exposed_method(:install_dir)
77
+ end
78
+
79
+ it 'returns the project instances install_dir' do
80
+ expect(subject.install_dir).to eq('/opt/project')
81
+ end
82
+ end
83
+
84
+ describe '#windows_safe_path' do
85
+ it 'is a DSL method' do
86
+ expect(subject).to have_exposed_method(:windows_safe_path)
87
+ end
88
+ end
89
+
74
90
  describe '#run!' do
75
91
  before do
76
92
  allow(subject).to receive(:remove_directory)
@@ -25,6 +25,7 @@ module Omnibus
25
25
 
26
26
  allow(subject).to receive(:staging_dir).and_return(staging_dir)
27
27
  create_directory(staging_dir)
28
+ create_directory(subject.scripts_staging_dir)
28
29
  end
29
30
 
30
31
  describe '#id' do
@@ -43,6 +44,41 @@ module Omnibus
43
44
  end
44
45
  end
45
46
 
47
+ describe '#scripts_install_dir' do
48
+ it 'is nested inside the project install_dir' do
49
+ expect(subject.scripts_install_dir).to eq("#{project.install_dir}/embedded/share/installp")
50
+ end
51
+ end
52
+
53
+ describe '#scripts_staging_dir' do
54
+ it 'is nested inside the staging_dir' do
55
+ expect(subject.scripts_staging_dir).to eq("#{staging_dir}#{subject.scripts_install_dir}")
56
+ end
57
+ end
58
+
59
+ describe '#write_scripts' do
60
+ context 'when scripts are given' do
61
+ let(:scripts) { %w( preinst postinst prerm postrm ) }
62
+ before do
63
+ scripts.each do |script_name|
64
+ create_file("#{project_root}/package-scripts/project/#{script_name}") do
65
+ "Contents of #{script_name}"
66
+ end
67
+ end
68
+ end
69
+
70
+ it 'writes the scripts into scripts staging dir' do
71
+ subject.write_scripts
72
+
73
+ scripts.each do |script_name|
74
+ script_file = "#{subject.scripts_staging_dir}/#{script_name}"
75
+ contents = File.read(script_file)
76
+ expect(contents).to include("Contents of #{script_name}")
77
+ end
78
+ end
79
+ end
80
+ end
81
+
46
82
  describe '#write_gen_template' do
47
83
  before do
48
84
  allow(subject).to receive(:safe_architecture).and_return('x86_64')
@@ -67,8 +103,6 @@ module Omnibus
67
103
  expect(contents).to include(" Fileset VRMF: 1.2.3.2")
68
104
  expect(contents).to include(" Fileset Description: The full stack of project")
69
105
  expect(contents).to include(" USRLIBLPPFiles")
70
- expect(contents).to include(" Configuration Script:")
71
- expect(contents).to include(" Unconfiguration Script:")
72
106
  expect(contents).to include(" EOUSRLIBLPPFiles")
73
107
  expect(contents).to include(" Bosboot required: N")
74
108
  expect(contents).to include(" License agreement acceptance required: N")
@@ -98,6 +132,25 @@ module Omnibus
98
132
  expect(contents).to include("/file2")
99
133
  end
100
134
  end
135
+
136
+ context 'when script files are present' do
137
+ before do
138
+ create_file("#{subject.scripts_staging_dir}/preinst")
139
+ create_file("#{subject.scripts_staging_dir}/postinst")
140
+ create_file("#{subject.scripts_staging_dir}/prerm")
141
+ create_file("#{subject.scripts_staging_dir}/postrm")
142
+ end
143
+
144
+ it 'writes them into the template' do
145
+ subject.write_gen_template
146
+ contents = File.read(gen_file)
147
+
148
+ expect(contents).to include(" Pre-installation Script: #{subject.scripts_install_dir}/preinst")
149
+ expect(contents).to include(" Post-installation Script: #{subject.scripts_install_dir}/postinst")
150
+ expect(contents).to include(" Pre_rm Script: #{subject.scripts_install_dir}/prerm")
151
+ expect(contents).to include(" Unconfiguration Script: #{subject.scripts_install_dir}/postrm")
152
+ end
153
+ end
101
154
  end
102
155
 
103
156
  describe '#create_bff_file' do
@@ -118,10 +171,10 @@ module Omnibus
118
171
  end
119
172
  end
120
173
 
121
- describe '#safe_project_name' do
174
+ describe '#safe_base_package_name' do
122
175
  context 'when the project name is "safe"' do
123
176
  it 'returns the value without logging a message' do
124
- expect(subject.safe_project_name).to eq('project')
177
+ expect(subject.safe_base_package_name).to eq('project')
125
178
  expect(subject).to_not receive(:log)
126
179
  end
127
180
  end
@@ -131,7 +184,7 @@ module Omnibus
131
184
 
132
185
  it 'returns the value while logging a message' do
133
186
  output = capture_logging do
134
- expect(subject.safe_project_name).to eq('pro-ject123.for-realz-2')
187
+ expect(subject.safe_base_package_name).to eq('pro-ject123.for-realz-2')
135
188
  end
136
189
 
137
190
  expect(output).to include("The `name' compontent of BFF package names can only include")
@@ -247,10 +247,10 @@ module Omnibus
247
247
  end
248
248
  end
249
249
 
250
- describe '#safe_project_name' do
250
+ describe '#safe_base_package_name' do
251
251
  context 'when the project name is "safe"' do
252
252
  it 'returns the value without logging a message' do
253
- expect(subject.safe_project_name).to eq('project')
253
+ expect(subject.safe_base_package_name).to eq('project')
254
254
  expect(subject).to_not receive(:log)
255
255
  end
256
256
  end
@@ -260,7 +260,7 @@ module Omnibus
260
260
 
261
261
  it 'returns the value while logging a message' do
262
262
  output = capture_logging do
263
- expect(subject.safe_project_name).to eq('Pro-ject123.for-realz-2')
263
+ expect(subject.safe_base_package_name).to eq('Pro-ject123.for-realz-2')
264
264
  end
265
265
 
266
266
  expect(output).to include("The `name' compontent of Debian package names can only include")
@@ -319,6 +319,18 @@ module Omnibus
319
319
  expect(subject.safe_architecture).to eq('i386')
320
320
  end
321
321
  end
322
+
323
+ context 'when i686' do
324
+ before do
325
+ stub_ohai(platform: 'ubuntu', version: '12.04') do |data|
326
+ data['kernel']['machine'] = 'i686'
327
+ end
328
+ end
329
+
330
+ it 'returns i386' do
331
+ expect(subject.safe_architecture).to eq('i386')
332
+ end
333
+ end
322
334
  end
323
335
  end
324
336
  end
@@ -43,19 +43,66 @@ module Omnibus
43
43
  end
44
44
  end
45
45
 
46
- describe '#write_post_extract_file' do
47
- it 'generates the file' do
48
- subject.write_post_extract_file
49
- expect("#{staging_dir}/post_extract.sh").to be_a_file
50
- expect("#{staging_dir}/post_extract.sh").to be_an_executable
46
+ describe '#write_scripts' do
47
+ before do
48
+ create_file("#{project_root}/package-scripts/project/makeselfinst") { 'Contents of makeselfinst' }
49
+ end
50
+
51
+ it 'copies the scripts into the STAGING dir' do
52
+ subject.write_scripts
53
+ expect("#{staging_dir}/makeselfinst").to be_a_file
51
54
  end
52
55
 
53
56
  it 'has the correct content' do
54
- subject.write_post_extract_file
55
- contents = File.read("#{staging_dir}/post_extract.sh")
57
+ subject.write_scripts
58
+ contents = File.read("#{staging_dir}/makeselfinst")
59
+
60
+ expect(contents).to include('Contents of makeselfinst')
61
+ end
62
+ end
63
+
64
+ describe '#write_scripts' do
65
+ context 'when scripts are given' do
66
+ let(:scripts) { %w( makeselfinst ) }
67
+ before do
68
+ scripts.each do |script_name|
69
+ create_file("#{project_root}/package-scripts/project/#{script_name}") do
70
+ "Contents of #{script_name}"
71
+ end
72
+ end
73
+ end
74
+
75
+ it 'writes the scripts into the staging dir' do
76
+ subject.write_scripts
77
+
78
+ scripts.each do |script_name|
79
+ script_file = "#{staging_dir}/#{script_name}"
80
+ contents = File.read(script_file)
81
+ expect(contents).to include("Contents of #{script_name}")
82
+ end
83
+ end
84
+ end
85
+
86
+ context 'when scripts with default omnibus naming are given' do
87
+ let(:default_scripts) { %w( postinst ) }
88
+ before do
89
+ default_scripts.each do |script_name|
90
+ create_file("#{project_root}/package-scripts/project/#{script_name}") do
91
+ "Contents of #{script_name}"
92
+ end
93
+ end
94
+ end
95
+
96
+ it 'writes the scripts into the staging dir' do
97
+ subject.write_scripts
56
98
 
57
- expect(contents).to include("DEST_DIR=/opt/project")
58
- expect(contents).to include("CONFIG_DIR=/etc/project")
99
+ default_scripts.each do |script_name|
100
+ mapped_name = Packager::Makeself::SCRIPT_MAP[script_name.to_sym]
101
+ script_file = "#{staging_dir}/#{mapped_name}"
102
+ contents = File.read(script_file)
103
+ expect(contents).to include("Contents of #{script_name}")
104
+ end
105
+ end
59
106
  end
60
107
  end
61
108
 
@@ -27,6 +27,7 @@ module Omnibus
27
27
 
28
28
  allow(subject).to receive(:staging_dir).and_return(staging_dir)
29
29
  create_directory(staging_dir)
30
+ create_directory("#{staging_dir}/Scripts")
30
31
  end
31
32
 
32
33
  describe 'DSL' do
@@ -57,13 +58,65 @@ module Omnibus
57
58
  end
58
59
  end
59
60
 
61
+ describe '#scripts_dir' do
62
+ it 'is nested inside the staging_dir' do
63
+ expect(subject.scripts_dir).to eq("#{staging_dir}/Scripts")
64
+ end
65
+ end
66
+
67
+ describe '#write_scripts' do
68
+ context 'when scripts are given' do
69
+ let(:scripts) { %w( preinstall postinstall ) }
70
+ before do
71
+ scripts.each do |script_name|
72
+ create_file("#{project_root}/package-scripts/project/#{script_name}") do
73
+ "Contents of #{script_name}"
74
+ end
75
+ end
76
+ end
77
+
78
+ it 'writes the scripts into scripts staging dir' do
79
+ subject.write_scripts
80
+
81
+ scripts.each do |script_name|
82
+ script_file = "#{staging_dir}/Scripts/#{script_name}"
83
+ contents = File.read(script_file)
84
+ expect(contents).to include("Contents of #{script_name}")
85
+ end
86
+ end
87
+ end
88
+
89
+ context 'when scripts with default omnibus naming are given' do
90
+ let(:default_scripts) { %w( preinst postinst ) }
91
+ before do
92
+ default_scripts.each do |script_name|
93
+ create_file("#{project_root}/package-scripts/project/#{script_name}") do
94
+ "Contents of #{script_name}"
95
+ end
96
+ end
97
+ end
98
+
99
+ it 'writes the scripts into scripts staging dir' do
100
+ subject.write_scripts
101
+
102
+ default_scripts.each do |script_name|
103
+ mapped_name = Packager::PKG::SCRIPT_MAP[script_name.to_sym]
104
+ script_file = "#{staging_dir}/Scripts/#{mapped_name}"
105
+ contents = File.read(script_file)
106
+ expect(contents).to include("Contents of #{script_name}")
107
+ end
108
+ end
109
+ end
110
+ end
111
+
112
+
60
113
  describe '#build_component_pkg' do
61
114
  it 'executes the pkgbuild command' do
62
115
  expect(subject).to receive(:shellout!).with <<-EOH.gsub(/^ {10}/, '')
63
116
  pkgbuild \\
64
117
  --identifier "com.getchef.project" \\
65
118
  --version "1.2.3" \\
66
- --scripts "#{project_root}/package-scripts/project" \\
119
+ --scripts "#{staging_dir}/Scripts" \\
67
120
  --root "/opt/project" \\
68
121
  --install-location "/opt/project" \\
69
122
  "project-core.pkg"
@@ -138,10 +191,10 @@ module Omnibus
138
191
  end
139
192
  end
140
193
 
141
- describe '#safe_project_name' do
194
+ describe '#safe_base_package_name' do
142
195
  context 'when the project name is "safe"' do
143
196
  it 'returns the value without logging a message' do
144
- expect(subject.safe_project_name).to eq('project')
197
+ expect(subject.safe_base_package_name).to eq('project')
145
198
  expect(subject).to_not receive(:log)
146
199
  end
147
200
  end
@@ -151,7 +204,7 @@ module Omnibus
151
204
 
152
205
  it 'returns the value while logging a message' do
153
206
  output = capture_logging do
154
- expect(subject.safe_project_name).to eq('project123forrealz2')
207
+ expect(subject.safe_base_package_name).to eq('project123forrealz2')
155
208
  end
156
209
 
157
210
  expect(output).to include("The `name' compontent of Mac package names can only include")
@@ -153,10 +153,34 @@ module Omnibus
153
153
  end
154
154
 
155
155
  context 'when scripts are given' do
156
+ let(:scripts) { %w( pre post preun postun verifyscript pretans posttrans ) }
157
+
158
+ before do
159
+ scripts.each do |script_name|
160
+ create_file("#{project_root}/package-scripts/project/#{script_name}") do
161
+ "Contents of #{script_name}"
162
+ end
163
+ end
164
+ end
165
+
166
+ it 'writes the scripts into the spec' do
167
+ subject.write_rpm_spec
168
+ contents = File.read(spec_file)
169
+
170
+ scripts.each do |script_name|
171
+ expect(contents).to include("%#{script_name}")
172
+ expect(contents).to include("Contents of #{script_name}")
173
+ end
174
+ end
175
+ end
176
+
177
+ context 'when scripts with default omnibus naming are given' do
178
+ let(:default_scripts) { %w( preinst postinst prerm postrm ) }
179
+
156
180
  before do
157
- Packager::RPM::SCRIPTS.each do |name|
158
- create_file("#{project_root}/package-scripts/project/#{name}") do
159
- "Contents of #{name}"
181
+ default_scripts.each do |default_name|
182
+ create_file("#{project_root}/package-scripts/project/#{default_name}") do
183
+ "Contents of #{default_name}"
160
184
  end
161
185
  end
162
186
  end
@@ -165,20 +189,11 @@ module Omnibus
165
189
  subject.write_rpm_spec
166
190
  contents = File.read(spec_file)
167
191
 
168
- expect(contents).to include("%pre")
169
- expect(contents).to include("Contents of pre")
170
- expect(contents).to include("%post")
171
- expect(contents).to include("Contents of post")
172
- expect(contents).to include("%preun")
173
- expect(contents).to include("Contents of preun")
174
- expect(contents).to include("%postun")
175
- expect(contents).to include("Contents of postun")
176
- expect(contents).to include("%verifyscript")
177
- expect(contents).to include("Contents of verifyscript")
178
- expect(contents).to include("%pretans")
179
- expect(contents).to include("Contents of pretans")
180
- expect(contents).to include("%posttrans")
181
- expect(contents).to include("Contents of posttrans")
192
+ default_scripts.each do |script_name|
193
+ mapped_name = Packager::RPM::SCRIPT_MAP[script_name.to_sym]
194
+ expect(contents).to include("%#{mapped_name}")
195
+ expect(contents).to include("Contents of #{script_name}")
196
+ end
182
197
  end
183
198
  end
184
199
 
@@ -265,10 +280,10 @@ module Omnibus
265
280
  end
266
281
  end
267
282
 
268
- describe '#safe_project_name' do
283
+ describe '#safe_base_package_name' do
269
284
  context 'when the project name is "safe"' do
270
285
  it 'returns the value without logging a message' do
271
- expect(subject.safe_project_name).to eq('project')
286
+ expect(subject.safe_base_package_name).to eq('project')
272
287
  expect(subject).to_not receive(:log)
273
288
  end
274
289
  end
@@ -278,7 +293,7 @@ module Omnibus
278
293
 
279
294
  it 'returns the value while logging a message' do
280
295
  output = capture_logging do
281
- expect(subject.safe_project_name).to eq('pro-ject123.for-realz-2')
296
+ expect(subject.safe_base_package_name).to eq('pro-ject123.for-realz-2')
282
297
  end
283
298
 
284
299
  expect(output).to include("The `name' compontent of RPM package names can only include")
@@ -301,14 +316,14 @@ module Omnibus
301
316
  end
302
317
 
303
318
  context 'when the project build_version has invalid characters' do
304
- before { project.build_version("1.2$alpha.##__2") }
319
+ before { project.build_version("1.2-pre$alpha.##__2") }
305
320
 
306
321
  it 'returns the value while logging a message' do
307
322
  output = capture_logging do
308
- expect(subject.safe_version).to eq('1.2-alpha.-2')
323
+ expect(subject.safe_version).to eq('1.2_pre$alpha.##__2')
309
324
  end
310
325
 
311
- expect(output).to include("The `version' compontent of RPM package names can only include")
326
+ expect(output).to include("The `version' component of RPM package names can only include")
312
327
  end
313
328
  end
314
329
  end