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

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 (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
@@ -175,7 +175,7 @@ module Omnibus
175
175
  # extension.
176
176
  #
177
177
  def package_name
178
- "#{safe_project_name}_#{safe_version}-#{safe_build_iteration}_#{safe_architecture}.deb"
178
+ "#{safe_base_package_name}_#{safe_version}-#{safe_build_iteration}_#{safe_architecture}.deb"
179
179
  end
180
180
 
181
181
  #
@@ -200,7 +200,7 @@ module Omnibus
200
200
  render_template(resource_path('control.erb'),
201
201
  destination: File.join(debian_dir, 'control'),
202
202
  variables: {
203
- name: safe_project_name,
203
+ name: safe_base_package_name,
204
204
  version: safe_version,
205
205
  iteration: safe_build_iteration,
206
206
  vendor: vendor,
@@ -317,21 +317,21 @@ module Omnibus
317
317
  end
318
318
 
319
319
  #
320
- # Return the Debian-ready project name, converting any invalid characters to
320
+ # Return the Debian-ready base package name, converting any invalid characters to
321
321
  # dashes (+-+).
322
322
  #
323
323
  # @return [String]
324
324
  #
325
- def safe_project_name
326
- if project.name =~ /\A[a-zA-Z0-9\.\+\-]+\z/
327
- project.name.dup
325
+ def safe_base_package_name
326
+ if project.package_name =~ /\A[a-zA-Z0-9\.\+\-]+\z/
327
+ project.package_name.dup
328
328
  else
329
- converted = project.name.gsub(/[^a-zA-Z0-9\.\+\-]+/, '-')
329
+ converted = project.package_name.gsub(/[^a-zA-Z0-9\.\+\-]+/, '-')
330
330
 
331
331
  log.warn(log_key) do
332
332
  "The `name' compontent of Debian package names can only include " \
333
333
  "alphabetical characters (a-z, A-Z), numbers (0-9), dots (.), " \
334
- "plus signs (+), and dashes (-). Converting `#{project.name}' to " \
334
+ "plus signs (+), and dashes (-). Converting `#{project.package_name}' to " \
335
335
  "`#{converted}'."
336
336
  end
337
337
 
@@ -381,6 +381,8 @@ module Omnibus
381
381
  case Ohai['kernel']['machine']
382
382
  when 'x86_64'
383
383
  'amd64'
384
+ when 'i686'
385
+ 'i386'
384
386
  else
385
387
  Ohai['kernel']['machine']
386
388
  end
@@ -16,6 +16,14 @@
16
16
 
17
17
  module Omnibus
18
18
  class Packager::Makeself < Packager::Base
19
+ # @return [Hash]
20
+ SCRIPT_MAP = {
21
+ # Default Omnibus naming
22
+ postinst: 'makeselfinst',
23
+ # Default Makeself naming
24
+ makeselfinst: 'makeselfinst',
25
+ }.freeze
26
+
19
27
  id :makeself
20
28
 
21
29
  setup do
@@ -27,8 +35,8 @@ module Omnibus
27
35
  end
28
36
 
29
37
  build do
30
- # Render the post_extract file
31
- write_post_extract_file
38
+ # Write the scripts
39
+ write_scripts
32
40
 
33
41
  # Create the makeself archive
34
42
  create_makeself_package
@@ -36,7 +44,7 @@ module Omnibus
36
44
 
37
45
  # @see Base#package_name
38
46
  def package_name
39
- "#{project.name}-#{project.build_version}_#{project.build_iteration}.#{safe_architecture}.run"
47
+ "#{project.package_name}-#{project.build_version}_#{project.build_iteration}.#{safe_architecture}.run"
40
48
  end
41
49
 
42
50
  #
@@ -60,21 +68,21 @@ module Omnibus
60
68
  end
61
69
 
62
70
  #
63
- # Write the post-extraction file that will be executed upon extraction of
64
- # the makeself file.
71
+ # Copy all scripts in {Project#package_scripts_path} to the staging
72
+ # directory.
65
73
  #
66
74
  # @return [void]
67
75
  #
68
- def write_post_extract_file
69
- render_template(resource_path('post_extract.sh.erb'),
70
- destination: File.join(staging_dir, 'post_extract.sh'),
71
- mode: 0755,
72
- variables: {
73
- name: project.name,
74
- friendly_name: project.friendly_name,
75
- install_dir: project.install_dir,
76
- }
77
- )
76
+ def write_scripts
77
+ SCRIPT_MAP.each do |source, destination|
78
+ source_path = File.join(project.package_scripts_path, source.to_s)
79
+
80
+ if File.file?(source_path)
81
+ destination_path = File.join(staging_dir, destination)
82
+ log.debug(log_key) { "Adding script `#{source}' to `#{destination_path}'" }
83
+ copy_file(source_path, destination_path)
84
+ end
85
+ end
78
86
  end
79
87
 
80
88
  #
@@ -93,7 +101,7 @@ module Omnibus
93
101
  "#{staging_dir}" \\
94
102
  "#{package_name}" \\
95
103
  "#{project.description}" \\
96
- "./post_extract.sh"
104
+ "./makeselfinst"
97
105
  EOH
98
106
  end
99
107
 
@@ -65,7 +65,7 @@ module Omnibus
65
65
 
66
66
  # Create the msi, ignoring the 204 return code from light.exe since it is
67
67
  # about some expected warnings
68
- shellout! <<-EOH.split.join(' ').squeeze(' ').strip
68
+ light_command = <<-EOH.split.join(' ').squeeze(' ').strip
69
69
  light.exe
70
70
  -nologo
71
71
  -ext WixUIExtension
@@ -75,6 +75,7 @@ module Omnibus
75
75
  project-files.wixobj source.wixobj
76
76
  -out "#{windows_safe_path(Config.package_dir, package_name)}"
77
77
  EOH
78
+ shellout!(light_command, returns: [0, 204])
78
79
  end
79
80
  end
80
81
 
@@ -182,7 +183,7 @@ module Omnibus
182
183
 
183
184
  # @see Base#package_name
184
185
  def package_name
185
- "#{project.name}-#{project.build_version}-#{project.build_iteration}.msi"
186
+ "#{project.package_name}-#{project.build_version}-#{project.build_iteration}.msi"
186
187
  end
187
188
 
188
189
  #
@@ -203,7 +204,7 @@ module Omnibus
203
204
  render_template(resource_path('localization-en-us.wxl.erb'),
204
205
  destination: "#{staging_dir}/localization-en-us.wxl",
205
206
  variables: {
206
- name: project.name,
207
+ name: project.package_name,
207
208
  friendly_name: project.friendly_name,
208
209
  maintainer: project.maintainer,
209
210
  }
@@ -219,7 +220,7 @@ module Omnibus
219
220
  render_template(resource_path('parameters.wxi.erb'),
220
221
  destination: "#{staging_dir}/parameters.wxi",
221
222
  variables: {
222
- name: project.name,
223
+ name: project.package_name,
223
224
  friendly_name: project.friendly_name,
224
225
  maintainer: project.maintainer,
225
226
  upgrade_code: upgrade_code,
@@ -268,7 +269,7 @@ module Omnibus
268
269
  render_template(resource_path('source.wxs.erb'),
269
270
  destination: "#{staging_dir}/source.wxs",
270
271
  variables: {
271
- name: project.name,
272
+ name: project.package_name,
272
273
  friendly_name: project.friendly_name,
273
274
  maintainer: project.maintainer,
274
275
  hierarchy: hierarchy,
@@ -16,12 +16,25 @@
16
16
 
17
17
  module Omnibus
18
18
  class Packager::PKG < Packager::Base
19
+ # @return [Hash]
20
+ SCRIPT_MAP = {
21
+ # Default Omnibus naming
22
+ preinst: 'preinstall',
23
+ postinst: 'postinstall',
24
+ # Default PKG naming
25
+ preinstall: 'preinstall',
26
+ postinstall: 'postinstall',
27
+ }.freeze
28
+
19
29
  id :pkg
20
30
 
21
31
  setup do
22
32
  # Create the resources directory
23
33
  create_directory(resources_dir)
24
34
 
35
+ # Create the scripts directory
36
+ create_directory(scripts_dir)
37
+
25
38
  # Render the license
26
39
  render_template(resource_path('license.html.erb'),
27
40
  destination: "#{resources_dir}/license.html",
@@ -29,6 +42,8 @@ module Omnibus
29
42
  name: project.name,
30
43
  friendly_name: project.friendly_name,
31
44
  maintainer: project.maintainer,
45
+ build_version: project.build_version,
46
+ package_name: project.package_name,
32
47
  }
33
48
  )
34
49
 
@@ -39,6 +54,8 @@ module Omnibus
39
54
  name: project.name,
40
55
  friendly_name: project.friendly_name,
41
56
  maintainer: project.maintainer,
57
+ build_version: project.build_version,
58
+ package_name: project.package_name,
42
59
  }
43
60
  )
44
61
 
@@ -47,6 +64,8 @@ module Omnibus
47
64
  end
48
65
 
49
66
  build do
67
+ write_scripts
68
+
50
69
  build_component_pkg
51
70
 
52
71
  write_distribution_file
@@ -106,7 +125,7 @@ module Omnibus
106
125
 
107
126
  # @see Base#package_name
108
127
  def package_name
109
- "#{safe_project_name}-#{safe_version}-#{safe_build_iteration}.pkg"
128
+ "#{safe_base_package_name}-#{safe_version}-#{safe_build_iteration}.pkg"
110
129
  end
111
130
 
112
131
  #
@@ -130,6 +149,36 @@ module Omnibus
130
149
  File.expand_path("#{staging_dir}/Resources")
131
150
  end
132
151
 
152
+ #
153
+ # The path where the package scripts will live. We cannot store
154
+ # scripts in the top-level staging dir, because +pkgbuild+'s
155
+ # +--scripts+ flag expects a directory that does not contain the parent
156
+ # package.
157
+ #
158
+ # @return [String]
159
+ #
160
+ def scripts_dir
161
+ File.expand_path("#{staging_dir}/Scripts")
162
+ end
163
+
164
+ #
165
+ # Copy all scripts in {Project#package_scripts_path} to the package
166
+ # directory.
167
+ #
168
+ # @return [void]
169
+ #
170
+ def write_scripts
171
+ SCRIPT_MAP.each do |source, destination|
172
+ source_path = File.join(project.package_scripts_path, source.to_s)
173
+
174
+ if File.file?(source_path)
175
+ destination_path = File.join(scripts_dir, destination)
176
+ log.debug(log_key) { "Adding script `#{source}' to `#{destination_path}'" }
177
+ copy_file(source_path, destination_path)
178
+ end
179
+ end
180
+ end
181
+
133
182
  #
134
183
  # Construct the intermediate build product. It can be installed with the
135
184
  # Installer.app, but doesn't contain the data needed to customize the
@@ -142,7 +191,7 @@ module Omnibus
142
191
  pkgbuild \\
143
192
  --identifier "#{safe_identifier}" \\
144
193
  --version "#{safe_version}" \\
145
- --scripts "#{project.package_scripts_path}" \\
194
+ --scripts "#{scripts_dir}" \\
146
195
  --root "#{project.install_dir}" \\
147
196
  --install-location "#{project.install_dir}" \\
148
197
  "#{component_pkg}"
@@ -204,24 +253,24 @@ module Omnibus
204
253
  # @return [String] the filename of the component .pkg file to create.
205
254
  #
206
255
  def component_pkg
207
- "#{safe_project_name}-core.pkg"
256
+ "#{safe_base_package_name}-core.pkg"
208
257
  end
209
258
 
210
259
  #
211
- # Return the PKG-ready project name, removing any invalid characters.
260
+ # Return the PKG-ready base package name, removing any invalid characters.
212
261
  #
213
262
  # @return [String]
214
263
  #
215
- def safe_project_name
216
- if project.name =~ /\A[[:alnum:]]+\z/
217
- project.name.dup
264
+ def safe_base_package_name
265
+ if project.package_name =~ /\A[[:alnum:]]+\z/
266
+ project.package_name.dup
218
267
  else
219
- converted = project.name.downcase.gsub(/[^[:alnum:]+]/, '')
268
+ converted = project.package_name.downcase.gsub(/[^[:alnum:]+]/, '')
220
269
 
221
270
  log.warn(log_key) do
222
271
  "The `name' compontent of Mac package names can only include " \
223
272
  "alphabetical characters (a-z, A-Z), and numbers (0-9). Converting " \
224
- "`#{project.name}' to `#{converted}'."
273
+ "`#{project.package_name}' to `#{converted}'."
225
274
  end
226
275
 
227
276
  converted
@@ -239,7 +288,7 @@ module Omnibus
239
288
  return identifier if identifier
240
289
 
241
290
  maintainer = project.maintainer.gsub(/[^[:alnum:]+]/, '').downcase
242
- "test.#{maintainer}.pkg.#{safe_project_name}"
291
+ "test.#{maintainer}.pkg.#{safe_base_package_name}"
243
292
  end
244
293
 
245
294
  #
@@ -18,8 +18,22 @@
18
18
 
19
19
  module Omnibus
20
20
  class Packager::RPM < Packager::Base
21
- # @return [Array]
22
- SCRIPTS = %w(pre post preun postun verifyscript pretans posttrans).freeze
21
+ # @return [Hash]
22
+ SCRIPT_MAP = {
23
+ # Default Omnibus naming
24
+ preinst: 'pre',
25
+ postinst: 'post',
26
+ prerm: 'preun',
27
+ postrm: 'postun',
28
+ # Default RPM naming
29
+ pre: 'pre',
30
+ post: 'post',
31
+ preun: 'preun',
32
+ postun: 'postun',
33
+ verifyscript: 'verifyscript',
34
+ pretans: 'pretans',
35
+ posttrans: 'posttrans',
36
+ }.freeze
23
37
 
24
38
  id :rpm
25
39
 
@@ -196,7 +210,7 @@ module Omnibus
196
210
  # @return [String]
197
211
  #
198
212
  def package_name
199
- "#{safe_project_name}-#{safe_version}-#{safe_build_iteration}.#{safe_architecture}.rpm"
213
+ "#{safe_base_package_name}-#{safe_version}-#{safe_build_iteration}.#{safe_architecture}.rpm"
200
214
  end
201
215
 
202
216
  #
@@ -216,11 +230,11 @@ module Omnibus
216
230
  #
217
231
  def write_rpm_spec
218
232
  # Create a map of scripts that exist and their contents
219
- scripts = SCRIPTS.inject({}) do |hash, name|
220
- path = File.join(project.package_scripts_path, name)
233
+ scripts = SCRIPT_MAP.inject({}) do |hash, (source, destination)|
234
+ path = File.join(project.package_scripts_path, source.to_s)
221
235
 
222
236
  if File.file?(path)
223
- hash[name] = File.read(path)
237
+ hash[destination] = File.read(path)
224
238
  end
225
239
 
226
240
  hash
@@ -239,7 +253,7 @@ module Omnibus
239
253
  render_template(resource_path('spec.erb'),
240
254
  destination: spec_file,
241
255
  variables: {
242
- name: safe_project_name,
256
+ name: safe_base_package_name,
243
257
  version: safe_version,
244
258
  iteration: safe_build_iteration,
245
259
  vendor: vendor,
@@ -270,16 +284,17 @@ module Omnibus
270
284
  # @return [void]
271
285
  #
272
286
  def create_rpm_file
273
- log.info(log_key) { "Creating .rpm file" }
274
-
275
287
  command = %|fakeroot rpmbuild|
276
288
  command << %| -bb|
277
289
  command << %| --buildroot #{staging_dir}/BUILD|
278
- command << %| --define "_topdir #{staging_dir}"|
290
+ command << %| --define '_topdir #{staging_dir}'|
279
291
 
280
292
  if signing_passphrase
293
+ log.info(log_key) { "Signing enabled for .rpm file" }
294
+
281
295
  if File.exist?("#{ENV['HOME']}/.rpmmacros")
282
296
  log.info(log_key) { "Detected .rpmmacros file at `#{ENV['HOME']}'" }
297
+ home = ENV['HOME']
283
298
  else
284
299
  log.info(log_key) { "Using default .rpmmacros file from Omnibus" }
285
300
 
@@ -293,15 +308,17 @@ module Omnibus
293
308
  gpg_path: "#{ENV['HOME']}/.gnupg", # TODO: Make this configurable
294
309
  }
295
310
  )
311
+ end
296
312
 
297
- command << " --sign"
298
- command << " #{spec_file}"
313
+ command << " --sign"
314
+ command << " #{spec_file}"
299
315
 
300
- with_rpm_signing do |signing_script|
301
- shellout!("#{signing_script} \"#{command}\"", environment: { 'HOME' => home })
302
- end
316
+ with_rpm_signing do |signing_script|
317
+ log.info(log_key) { "Creating .rpm file" }
318
+ shellout!("#{signing_script} \"#{command}\"", environment: { 'HOME' => home })
303
319
  end
304
320
  else
321
+ log.info(log_key) { "Creating .rpm file" }
305
322
  command << " #{spec_file}"
306
323
  shellout!("#{command}")
307
324
  end
@@ -371,21 +388,21 @@ module Omnibus
371
388
  end
372
389
 
373
390
  #
374
- # Return the RPM-ready project name, converting any invalid characters to
391
+ # Return the RPM-ready base package name, converting any invalid characters to
375
392
  # dashes (+-+).
376
393
  #
377
394
  # @return [String]
378
395
  #
379
- def safe_project_name
380
- if project.name =~ /\A[a-z0-9\.\+\-]+\z/
381
- project.name.dup
396
+ def safe_base_package_name
397
+ if project.package_name =~ /\A[a-z0-9\.\+\-]+\z/
398
+ project.package_name.dup
382
399
  else
383
- converted = project.name.downcase.gsub(/[^a-z0-9\.\+\-]+/, '-')
400
+ converted = project.package_name.downcase.gsub(/[^a-z0-9\.\+\-]+/, '-')
384
401
 
385
402
  log.warn(log_key) do
386
403
  "The `name' compontent of RPM package names can only include " \
387
404
  "lowercase alphabetical characters (a-z), numbers (0-9), dots (.), " \
388
- "plus signs (+), and dashes (-). Converting `#{project.name}' to " \
405
+ "plus signs (+), and dashes (-). Converting `#{project.package_name}' to " \
389
406
  "`#{converted}'."
390
407
  end
391
408
 
@@ -410,15 +427,15 @@ module Omnibus
410
427
  # @return [String]
411
428
  #
412
429
  def safe_version
413
- if project.build_version =~ /\A[a-zA-Z0-9\.\+\-]+\z/
430
+ if project.build_version =~ /\A[a-zA-Z0-9\.\+\_]+\z/
414
431
  project.build_version.dup
415
432
  else
416
- converted = project.build_version.gsub(/[^a-zA-Z0-9\.\+\-]+/, '-')
433
+ converted = project.build_version.gsub('-', '_')
417
434
 
418
435
  log.warn(log_key) do
419
- "The `version' compontent of RPM package names can only include " \
436
+ "The `version' component of RPM package names can only include " \
420
437
  "alphabetical characters (a-z, A-Z), numbers (0-9), dots (.), " \
421
- "plus signs (+), and dashes (-). Converting " \
438
+ "plus signs (+), and underscores (_). Converting " \
422
439
  "`#{project.build_version}' to `#{converted}'."
423
440
  end
424
441