omnibus 2.0.2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +2 -0
  3. data/.travis.yml +0 -2
  4. data/CHANGELOG.md +26 -6
  5. data/Gemfile +7 -0
  6. data/Guardfile +10 -0
  7. data/README.md +103 -160
  8. data/Rakefile +6 -1
  9. data/docs/Building on OSX.md +66 -0
  10. data/docs/omnibus-build-cache.md +75 -0
  11. data/lib/omnibus.rb +9 -13
  12. data/lib/omnibus/artifact.rb +1 -13
  13. data/lib/omnibus/assets/README-logo.png +0 -0
  14. data/lib/omnibus/assets/logo.psd +0 -0
  15. data/lib/omnibus/builder.rb +1 -0
  16. data/lib/omnibus/cli/application.rb +17 -4
  17. data/lib/omnibus/cli/build.rb +6 -4
  18. data/lib/omnibus/config.rb +33 -0
  19. data/lib/omnibus/exceptions.rb +20 -14
  20. data/lib/omnibus/health_check.rb +2 -0
  21. data/lib/omnibus/install_path_cache.rb +106 -0
  22. data/lib/omnibus/library.rb +18 -1
  23. data/lib/omnibus/packagers/base.rb +228 -0
  24. data/lib/omnibus/packagers/mac_dmg.rb +215 -0
  25. data/lib/omnibus/packagers/mac_pkg.rb +129 -253
  26. data/lib/omnibus/project.rb +89 -95
  27. data/lib/omnibus/s3_cacher.rb +4 -7
  28. data/lib/omnibus/software.rb +47 -83
  29. data/lib/omnibus/sugar.rb +49 -0
  30. data/lib/omnibus/templates/.kitchen.yml.erb +3 -0
  31. data/lib/omnibus/templates/Berksfile.erb +4 -0
  32. data/lib/omnibus/templates/Gemfile.erb +1 -1
  33. data/lib/omnibus/templates/mac_dmg/background.png +0 -0
  34. data/lib/omnibus/templates/mac_dmg/icon.png +0 -0
  35. data/lib/omnibus/templates/mac_pkg/background.png +0 -0
  36. data/lib/omnibus/templates/mac_pkg/license.html.erb +1 -0
  37. data/lib/omnibus/templates/mac_pkg/welcome.html.erb +9 -0
  38. data/lib/omnibus/templates/omnibus.rb.example.erb +31 -4
  39. data/lib/omnibus/version.rb +1 -1
  40. data/omnibus.gemspec +5 -4
  41. data/spec/fixtures/sample/files/mac_dmg/Resources/background.png +0 -0
  42. data/spec/fixtures/sample/files/mac_dmg/Resources/icon.png +0 -0
  43. data/spec/fixtures/sample/files/mac_pkg/Resources/background.png +0 -0
  44. data/spec/fixtures/sample/files/mac_pkg/Resources/license.html +1 -0
  45. data/spec/fixtures/sample/files/mac_pkg/Resources/welcome.html +9 -0
  46. data/{functional/fixtures/mac_pkg/package-scripts/functional-test-project → spec/fixtures/sample/package-scripts/sample}/postinstall +0 -0
  47. data/spec/functional/packagers/mac_spec.rb +74 -0
  48. data/spec/spec_helper.rb +14 -3
  49. data/spec/sugar_spec.rb +20 -0
  50. data/spec/{artifact_spec.rb → unit/artifact_spec.rb} +2 -3
  51. data/spec/{build_version_spec.rb → unit/build_version_spec.rb} +0 -0
  52. data/spec/{config_spec.rb → unit/config_spec.rb} +4 -0
  53. data/spec/{fetchers → unit/fetchers}/git_fetcher_spec.rb +0 -0
  54. data/spec/{fetchers → unit/fetchers}/net_fetcher_spec.rb +0 -0
  55. data/spec/unit/install_path_cache_spec.rb +175 -0
  56. data/spec/unit/library_spec.rb +67 -0
  57. data/spec/{omnibus_spec.rb → unit/omnibus_spec.rb} +0 -0
  58. data/spec/{overrides_spec.rb → unit/overrides_spec.rb} +0 -0
  59. data/spec/{package_release_spec.rb → unit/package_release_spec.rb} +0 -0
  60. data/spec/unit/packagers/base_spec.rb +221 -0
  61. data/spec/unit/packagers/mac_pkg_spec.rb +163 -0
  62. data/spec/{project_spec.rb → unit/project_spec.rb} +0 -14
  63. data/spec/{s3_cacher_spec.rb → unit/s3_cacher_spec.rb} +0 -0
  64. data/spec/{software_spec.rb → unit/software_spec.rb} +0 -1
  65. metadata +122 -103
  66. data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/background.png +0 -0
  67. data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/license.html +0 -1
  68. data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/welcome.html +0 -1
  69. data/functional/packagers/mac_pkg_spec.rb +0 -72
  70. data/lib/omnibus/clean_tasks.rb +0 -28
  71. data/spec/packagers/mac_pkg_spec.rb +0 -262
@@ -15,275 +15,151 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require 'forwardable'
19
- require 'fileutils'
20
- require 'omnibus/util'
21
-
22
18
  module Omnibus
23
- module Packagers
24
- # Builds a Mac OS X "product" package (.pkg extension)
25
- #
26
- # Mac OS X packages are built in two stages. First, files are packaged up
27
- # into one or more "component" .pkg files (MacPkg only supports making a
28
- # single component). This is done with `pkgbuild`. Next the component(s)
29
- # are combined into a single "product" package, using `productbuild`. It is
30
- # this container package that can have custom branding (background image)
31
- # and a license. It can also allow for user customization of which
32
- # component packages to install, but MacPkg does not expose this feature.
33
- class MacPkg
34
- include Util
35
-
36
- extend Forwardable
37
-
38
- # The Omnibus::Project instance that we're packaging.
39
- attr_reader :project
40
-
41
- # !@method name
42
- # @return (see Project#name)
43
- def_delegator :@project, :name
44
-
45
- # !@method version
46
- # @return (see Project#build_version)
47
- def_delegator :@project, :build_version, :version
48
-
49
- # !@method iteration
50
- # @return (see Project#iteration)
51
- def_delegator :@project, :iteration, :iteration
52
-
53
- # !@method identifier
54
- # @return (see Project#mac_pkg_identifier)
55
- def_delegator :@project, :mac_pkg_identifier, :identifier
56
-
57
- # !@method pkg_root
58
- # @return (see Project#install_path)
59
- def_delegator :@project, :install_path, :pkg_root
60
-
61
- # !@method install_location
62
- # @return (see Project#install_path)
63
- def_delegator :@project, :install_path, :install_location
64
-
65
- # !@method scripts
66
- # @return (see Project#package_scripts_path)
67
- def_delegator :@project, :package_scripts_path, :scripts
68
-
69
- # !@method files_path
70
- # @return (see Project#files_path)
71
- def_delegator :@project, :files_path
72
-
73
- # !@method package_dir
74
- # @return (see Project#package_dir)
75
- def_delegator :@project, :package_dir
76
-
77
- # @param project [Project] the omnibus project to package.
78
- def initialize(project)
79
- @project = project
80
- end
81
-
82
- # Build the package.
83
- def build
84
- # Ensure the omnibus project repo contains the stuff we need.
85
- validate_omnibus_project!
86
-
87
- # create the staging dir for intermediate build products, if needed.
88
- setup_staging_dir!
89
-
90
- # build the component package
91
- build_component_pkg
92
-
93
- # build the product package
94
- build_product_pkg
95
- end
96
-
97
- # Verifies that the #required_files are present in the
98
- # omnibus project repo.
99
- # @return [true] if required files are present.
100
- # @raise [MissingMacPkgResource] if anything is missing.
101
- def validate_omnibus_project!
102
- missing_files = required_files.select { |f| !File.exist?(f) }
103
- if missing_files.empty?
104
- true # all good
105
- else
106
- fail MissingMacPkgResource.new(missing_files)
107
- end
108
- end
109
-
110
- # Nukes and re-creates the staging_dir
111
- # @return [void]
112
- def setup_staging_dir!
113
- FileUtils.rm_rf(staging_dir)
114
- FileUtils.mkdir_p(staging_dir)
115
- end
116
-
117
- def build_component_pkg
118
- shellout!(*pkgbuild_command, shellout_opts)
119
- end
120
-
121
- def build_product_pkg
122
- generate_distribution
123
- shellout!(*productbuild_command, shellout_opts)
124
- end
125
-
126
- # The argv for a pkgbuild command that will build the component package.
127
- # The resulting package is only an intermediate build product. It can be
128
- # installed with the mac installer, but doesn't contain the data needed
129
- # to customize the installer UI.
130
- # @return [Array<String>] argv for the pkgbuild command.
131
- def pkgbuild_command
132
- %W(
133
- pkgbuild
134
- --identifier #{identifier}
135
- --version #{version}
136
- --scripts #{scripts}
137
- --root #{pkg_root}
138
- --install-location #{install_location}
139
- #{component_pkg_name}
140
- )
141
- end
142
-
143
- # The argv for a productbuild command that will build the product package.
144
- # The generated package is the final build product that you ship to end
145
- # users.
146
- # @return [Array<String>] argv for the productbuild command
147
- def productbuild_command
148
- %W(
149
- productbuild
150
- --distribution #{distribution_staging_path}
151
- --resources #{mac_pkg_files_path}
152
- #{product_pkg_path}
153
- )
154
- end
155
-
156
- # Writes the Distribution file to the staging area.
157
- # @return [void]
158
- def generate_distribution
159
- File.open(distribution_staging_path, File::RDWR | File::CREAT | File::EXCL, 0600) do |file|
160
- file.print(distribution)
161
- end
162
- end
163
-
164
- # The name of the (only) component package.
165
- # @return [String] the filename of the component .pkg file to create.
166
- def component_pkg_name
167
- "#{name}-core.pkg"
168
- end
169
-
170
- # The basename of the end-result package (that will be distributed to
171
- # users).
172
- #
173
- # Project uses this to generate metadata about the package after its
174
- # built.
175
- #
176
- # @return [String] the basename of the package file
177
- def package_name
178
- "#{name}-#{version}-#{iteration}.pkg"
179
- end
180
-
181
- def identifier
182
- project.mac_pkg_identifier ||
183
- "test.#{sanitized_maintainer}.pkg.#{sanitized_name}"
184
- end
19
+ # Builds a Mac OS X "product" package (.pkg extension)
20
+ #
21
+ # Mac OS X packages are built in two stages. First, files are packaged up
22
+ # into one or more "component" .pkg files (MacPkg only supports making a
23
+ # single component). This is done with `pkgbuild`. Next the component(s)
24
+ # are combined into a single "product" package, using `productbuild`. It is
25
+ # this container package that can have custom branding (background image)
26
+ # and a license. It can also allow for user customization of which
27
+ # component packages to install, but MacPkg does not expose this feature.
28
+ class Packager::MacPkg < Packager::Base
29
+ validate do
30
+ assert_presence!(resource('background.png'))
31
+ assert_presence!(resource('license.html'))
32
+ assert_presence!(resource('welcome.html'))
33
+ end
185
34
 
186
- # Internally in this class we want to call this the "product package" so
187
- # we can be unambiguous and consistent.
188
- alias_method :product_pkg_name, :package_name
35
+ setup do
36
+ purge_directory(install_path)
37
+ purge_directory(staging_dir)
38
+ purge_directory(project.package_dir)
39
+ end
189
40
 
190
- # The full path where the product package was/will be written.
191
- #
192
- # @return [String] Path to the packge file.
193
- def product_pkg_path
194
- File.join(package_dir, product_pkg_name)
195
- end
41
+ build do
42
+ build_component_pkg
43
+ generate_distribution
44
+ build_product_pkg
196
45
 
197
- # @return [String] Filesystem path where the Distribution file is written.
198
- def distribution_staging_path
199
- File.join(staging_dir, 'Distribution')
46
+ if project.config[:build_dmg]
47
+ Packager::MacDmg.new(self).run!
200
48
  end
49
+ end
201
50
 
202
- # Generates the content of the Distribution file, which is used by
203
- # productbuild to select the component packages to include in the product
204
- # package. Also includes information used to customize the UI of the Mac
205
- # OS X installer.
206
- # @return [String] Distribution file content (XML)
207
- def distribution
208
- <<-END_DISTRIBTION
209
- <?xml version="1.0" standalone="no"?>
210
- <installer-gui-script minSpecVersion="1">
211
- <title>#{name.capitalize}</title>
212
- <background file="background.png" alignment="bottomleft" mime-type="image/png"/>
213
- <welcome file="welcome.html" mime-type="text/html"/>
214
- <license file="license.html" mime-type="text/html"/>
215
-
216
- <!-- Generated by productbuild - - synthesize -->
217
- <pkg-ref id="#{identifier}"/>
218
- <options customize="never" require-scripts="false"/>
219
- <choices-outline>
220
- <line choice="default">
221
- <line choice="#{identifier}"/>
222
- </line>
223
- </choices-outline>
224
- <choice id="default"/>
225
- <choice id="#{identifier}" visible="false">
226
- <pkg-ref id="#{identifier}"/>
227
- </choice>
228
- <pkg-ref id="#{identifier}" version="#{version}" onConclusion="none">#{component_pkg_name}</pkg-ref>
229
- </installer-gui-script>
230
- END_DISTRIBTION
231
- end
51
+ clean do
52
+ # There is nothing to cleanup
53
+ end
232
54
 
233
- # A directory where intermediate build products are stored.
234
- # @return [String] Path to the directory
235
- def staging_dir
236
- File.join(project.package_tmp, 'mac-pkg')
237
- end
55
+ # @see Base#package_name
56
+ def package_name
57
+ "#{name}-#{version}-#{iteration}.pkg"
58
+ end
238
59
 
239
- # A list of the files that will be used to customize the "product" package.P
240
- # @return [Array<String>] paths to the required files.
241
- def required_files
242
- [
243
- background_png_path,
244
- license_file_path,
245
- welcome_file_path,
246
- ]
247
- end
60
+ # The full path where the product package was/will be written.
61
+ #
62
+ # @return [String] Path to the packge file.
63
+ def final_pkg
64
+ File.expand_path("#{project.package_dir}/#{package_name}")
65
+ end
248
66
 
249
- def sanitized_name
250
- name.gsub(/[^[:alnum:]]/, '').downcase
251
- end
67
+ #
68
+ # Construct the intermediate build product. It can be installed with the
69
+ # Installer.app, but doesn't contain the data needed to customize the
70
+ # installer UI.
71
+ #
72
+ def build_component_pkg
73
+ execute <<-EOH.gsub(/^ {8}/, '')
74
+ pkgbuild \\
75
+ --identifier "#{identifier}" \\
76
+ --version "#{version}" \\
77
+ --scripts "#{scripts}" \\
78
+ --root "#{install_path}" \\
79
+ --install-location "#{install_path}" \\
80
+ "#{component_pkg}"
81
+ EOH
82
+ end
252
83
 
253
- def sanitized_maintainer
254
- project.maintainer.gsub(/[^[:alnum:]]/, '').downcase
84
+ #
85
+ # Write the Distribution file to the staging area. This method generates the
86
+ # content of the Distribution file, which is used by +productbuild+ to
87
+ # select the component packages to include in the product package.
88
+ #
89
+ # It also includes information used to customize the UI of the Mac OS X
90
+ # installer.
91
+ #
92
+ def generate_distribution
93
+ File.open(distribution_file, 'w', 0600) do |file|
94
+ file.puts <<-EOH.gsub(/^ {10}/, '')
95
+ <?xml version="1.0" standalone="no"?>
96
+ <installer-gui-script minSpecVersion="1">
97
+ <title>#{name.capitalize}</title>
98
+ <background file="background.png" alignment="bottomleft" mime-type="image/png"/>
99
+ <welcome file="welcome.html" mime-type="text/html"/>
100
+ <license file="license.html" mime-type="text/html"/>
101
+
102
+ <!-- Generated by productbuild - - synthesize -->
103
+ <pkg-ref id="#{identifier}"/>
104
+ <options customize="never" require-scripts="false"/>
105
+ <choices-outline>
106
+ <line choice="default">
107
+ <line choice="#{identifier}"/>
108
+ </line>
109
+ </choices-outline>
110
+ <choice id="default"/>
111
+ <choice id="#{identifier}" visible="false">
112
+ <pkg-ref id="#{identifier}"/>
113
+ </choice>
114
+ <pkg-ref id="#{identifier}" version="#{version}" onConclusion="none">#{component_pkg}</pkg-ref>
115
+ </installer-gui-script>
116
+ EOH
255
117
  end
118
+ end
256
119
 
257
- # The path to the directory inside the omnibus project's repo where the
258
- # pkg resource files are.
259
- # @return [String] path to the Resources directory
260
- def mac_pkg_files_path
261
- File.join(files_path, 'mac_pkg', 'Resources')
262
- end
120
+ #
121
+ # Construct the product package. The generated package is the final build
122
+ # product that is shipped to end users.
123
+ #
124
+ def build_product_pkg
125
+ execute <<-EOH.gsub(/^ {8}/, '')
126
+ productbuild \\
127
+ --distribution "#{distribution_file}" \\
128
+ --resources "#{resources_path}" \\
129
+ "#{final_pkg}"
130
+ EOH
131
+ end
263
132
 
264
- # @return [String] path to the license file
265
- def license_file_path
266
- File.join(mac_pkg_files_path, 'license.html')
267
- end
133
+ # The identifier for this mac package (the com.whatever.thing.whatever).
134
+ # This is a configurable project value, but a default value is calculated if
135
+ # one is not given.
136
+ #
137
+ # @return [String]
138
+ def identifier
139
+ @identifier ||= project.mac_pkg_identifier ||
140
+ "test.#{sanitize(project.maintainer)}.pkg.#{sanitize(project.name)}"
141
+ end
268
142
 
269
- # @return [String] path to the background image for the product package.
270
- def background_png_path
271
- File.join(mac_pkg_files_path, 'background.png')
272
- end
143
+ # Filesystem path where the Distribution XML file is written.
144
+ #
145
+ # @return [String]
146
+ def distribution_file
147
+ File.expand_path("#{staging_dir}/Distribution")
148
+ end
273
149
 
274
- # Path to the welcome file. This is the content that's displayed on the
275
- # first screen of the installer.
276
- # @return [String] path to the welcome file
277
- def welcome_file_path
278
- File.join(mac_pkg_files_path, 'welcome.html')
279
- end
150
+ # The name of the (only) component package.
151
+ #
152
+ # @return [String] the filename of the component .pkg file to create.
153
+ def component_pkg
154
+ "#{name}-core.pkg"
155
+ end
280
156
 
281
- def shellout_opts
282
- {
283
- timeout: 3600,
284
- cwd: staging_dir,
285
- }
286
- end
157
+ # Sanitize the given string for the package identifier.
158
+ #
159
+ # @param [String]
160
+ # @return [String]
161
+ def sanitize(string)
162
+ string.gsub(/[^[:alnum:]]/, '').downcase
287
163
  end
288
164
  end
289
165
  end
@@ -19,7 +19,6 @@ require 'omnibus/artifact'
19
19
  require 'omnibus/exceptions'
20
20
  require 'omnibus/library'
21
21
  require 'omnibus/util'
22
- require 'omnibus/packagers/mac_pkg'
23
22
  require 'time'
24
23
 
25
24
  module Omnibus
@@ -32,12 +31,12 @@ module Omnibus
32
31
  # @todo: Reorder DSL methods to fit in the same YARD group
33
32
  # @todo: Generate the DSL methods via metaprogramming... they're all so similar
34
33
  class Project
35
- include Rake::DSL
36
34
  include Util
37
35
 
38
36
  NULL_ARG = Object.new
39
37
 
40
38
  attr_reader :library
39
+ attr_accessor :dirty_cache
41
40
 
42
41
  # Convenience method to initialize a Project from a DSL file.
43
42
  #
@@ -71,11 +70,71 @@ module Omnibus
71
70
  @extra_package_files = []
72
71
  @dependencies = []
73
72
  @runtime_dependencies = []
73
+ @dirty_cache = false
74
74
  instance_eval(io, filename)
75
75
  validate
76
76
 
77
77
  @library = Omnibus::Library.new(self)
78
- render_tasks
78
+ end
79
+
80
+ def build_me
81
+ FileUtils.mkdir_p(config.package_dir)
82
+ FileUtils.mkdir_p('pkg')
83
+
84
+ if OHAI.platform == 'windows'
85
+ shellout!("rmdir #{install_path} /s /q")
86
+ else
87
+ shellout!("rm -rf #{install_path}/*")
88
+ end
89
+
90
+ library.build_order.each do |software|
91
+ software.build_me
92
+ end
93
+ health_check_me
94
+ package_me
95
+ end
96
+
97
+ def health_check_me
98
+ if OHAI.platform == 'windows'
99
+ puts 'Skipping health check on windows...'
100
+ else
101
+ # build a list of all whitelist files from all project dependencies
102
+ whitelist_files = library.components.map { |component| component.whitelist_files }.flatten
103
+ Omnibus::HealthCheck.run(install_path, whitelist_files)
104
+ end
105
+ end
106
+
107
+ def package_me
108
+ package_types.each do |pkg_type|
109
+ if pkg_type == 'makeself'
110
+ run_makeself
111
+ elsif pkg_type == 'msi'
112
+ run_msi
113
+ elsif pkg_type == 'bff'
114
+ run_bff
115
+ elsif pkg_type == 'pkgmk'
116
+ run_pkgmk
117
+ elsif pkg_type == 'mac_pkg'
118
+ run_mac_package_build
119
+ elsif pkg_type == 'mac_dmg'
120
+ # noop, since the dmg creation is handled by the packager
121
+ else # pkg_type == "fpm"
122
+ run_fpm(pkg_type)
123
+ end
124
+
125
+ render_metadata(pkg_type)
126
+
127
+ if OHAI.platform == 'windows'
128
+ cp_cmd = "xcopy #{config.package_dir}\\*.msi pkg\\ /Y"
129
+ elsif OHAI.platform == 'aix'
130
+ cp_cmd = "cp #{config.package_dir}/*.bff pkg/"
131
+ else
132
+ cp_cmd = "cp #{config.package_dir}/* pkg/"
133
+ end
134
+ shell = Mixlib::ShellOut.new(cp_cmd)
135
+ shell.run_command
136
+ shell.error!
137
+ end
79
138
  end
80
139
 
81
140
  # Ensures that certain project information has been set
@@ -123,7 +182,7 @@ module Omnibus
123
182
  # before being subsequently retrieved (i.e., an install_path
124
183
  # must be set in order to build a project)
125
184
  def install_path(val = NULL_ARG)
126
- @install_path = val unless val.equal?(NULL_ARG)
185
+ @install_path = File.expand_path(val) unless val.equal?(NULL_ARG)
127
186
  @install_path || fail(MissingProjectConfiguration.new('install_path', '/opt/chef'))
128
187
  end
129
188
 
@@ -249,14 +308,13 @@ module Omnibus
249
308
  @mac_pkg_identifier
250
309
  end
251
310
 
252
- # Set or retrieve the +{deb/rpm/solaris}-user+ fpm argument. Defaults
253
- # to +root+ if not otherwise set.
311
+ # Set or retrieve the {deb/rpm/solaris}-user fpm argument.
254
312
  #
255
313
  # @param val [String]
256
314
  # @return [String]
257
315
  def package_user(val = NULL_ARG)
258
316
  @pkg_user = val unless val.equal?(NULL_ARG)
259
- @pkg_user ||= 'root'
317
+ @pkg_user
260
318
  end
261
319
 
262
320
  # Set or retrieve the full overrides hash for all software being overridden. Calling it as
@@ -279,14 +337,13 @@ module Omnibus
279
337
  @overrides[name]
280
338
  end
281
339
 
282
- # Set or retrieve the +{deb/rpm/solaris}-group+ fpm argument. Defaults
283
- # to +root+ if not otherwise set.
340
+ # Set or retrieve the {deb/rpm/solaris}-group fpm argument.
284
341
  #
285
342
  # @param val [String]
286
343
  # @return [String]
287
344
  def package_group(val = NULL_ARG)
288
345
  @pkg_group = val unless val.equal?(NULL_ARG)
289
- @pkg_group ||= 'root'
346
+ @pkg_group
290
347
  end
291
348
 
292
349
  # Add an Omnibus software dependency.
@@ -461,7 +518,7 @@ module Omnibus
461
518
  end
462
519
 
463
520
  # The directory where packages are written when created. Delegates to
464
- # #config. The delegation allows Packagers (like Packagers::MacPkg) to
521
+ # #config. The delegation allows Packagers (like Packager::MacPkg) to
465
522
  # define the implementation rather than using the global config everywhere.
466
523
  #
467
524
  # @return [String] path to the package directory.
@@ -484,25 +541,22 @@ module Omnibus
484
541
  # If specific types cannot be determined, default to `["makeself"]`.
485
542
  #
486
543
  # @return [Array<(String)>]
487
- #
488
- # @todo Why does this only ever return a single-element array,
489
- # instead of just a string, or symbol?
490
544
  def package_types
491
545
  case platform_family
492
546
  when 'debian'
493
- ['deb']
547
+ %w(deb)
494
548
  when 'fedora', 'rhel'
495
- ['rpm']
549
+ %w(rpm)
496
550
  when 'aix'
497
- ['bff']
551
+ %w(bff)
498
552
  when 'solaris2'
499
- ['pkgmk']
553
+ %w(pkgmk)
500
554
  when 'windows'
501
- ['msi']
555
+ %w(msi)
502
556
  when 'mac_os_x'
503
- ['mac_pkg']
557
+ %w(mac_pkg mac_dmg)
504
558
  else
505
- ['makeself']
559
+ %w(makeself)
506
560
  end
507
561
  end
508
562
 
@@ -561,10 +615,13 @@ module Omnibus
561
615
  def render_metadata(pkg_type)
562
616
  basename = output_package(pkg_type)
563
617
  pkg_path = "#{config.package_dir}/#{basename}"
618
+
619
+ # Don't generate metadata for packages that haven't been created.
620
+ # TODO: Fix this and make it betterer
621
+ return unless File.exist?(pkg_path)
622
+
564
623
  artifact = Artifact.new(pkg_path, [platform_tuple], version: build_version)
565
624
  metadata = artifact.flat_metadata
566
- metadata['name'] = name
567
- metadata['homepage'] = homepage
568
625
  File.open("#{pkg_path}.metadata.json", 'w+') do |f|
569
626
  f.print(JSON.pretty_generate(metadata))
570
627
  end
@@ -583,7 +640,10 @@ module Omnibus
583
640
  when 'pkgmk'
584
641
  "#{package_name}-#{build_version}-#{iteration}.solaris"
585
642
  when 'mac_pkg'
586
- Packagers::MacPkg.new(self).package_name
643
+ Packager::MacPkg.new(self).package_name
644
+ when 'mac_dmg'
645
+ pkg = Packager::MacPkg.new(self)
646
+ Packager::MacDmg.new(pkg).package_name
587
647
  else # fpm
588
648
  require "fpm/package/#{pkg_type}"
589
649
  pkg = FPM::Package.types[pkg_type].new
@@ -705,12 +765,15 @@ module Omnibus
705
765
  end
706
766
 
707
767
  command_and_opts << " --replaces #{@replaces}" if @replaces
708
- command_and_opts << install_path
709
768
 
769
+ # All project files must be appended to the command "last", but before
770
+ # the final install path
710
771
  @extra_package_files.each do |files|
711
772
  command_and_opts << files
712
773
  end
713
774
 
775
+ # Install path must be the final entry in the command
776
+ command_and_opts << install_path
714
777
  command_and_opts
715
778
  end
716
779
 
@@ -835,7 +898,7 @@ PSTAMP=#{`hostname`.chomp + Time.now.utc.iso8601}
835
898
  end
836
899
 
837
900
  def run_mac_package_build
838
- Packagers::MacPkg.new(self).build
901
+ Packager::MacPkg.new(self).run!
839
902
  end
840
903
 
841
904
  # Runs the necessary command to make a package with fpm. As a side-effect,
@@ -863,74 +926,5 @@ PSTAMP=#{`hostname`.chomp + Time.now.utc.iso8601}
863
926
 
864
927
  shellout!(command, cmd_options)
865
928
  end
866
-
867
- # Dynamically generate Rake tasks to build projects and all the software they depend on.
868
- #
869
- # @note Much Rake magic ahead!
870
- #
871
- # @return void
872
- def render_tasks
873
- directory config.package_dir
874
- directory 'pkg'
875
-
876
- namespace :projects do
877
- namespace @name do
878
-
879
- package_types.each do |pkg_type|
880
- dep_tasks = @dependencies.map { |dep| "software:#{dep}" }
881
- dep_tasks << config.package_dir
882
- dep_tasks << 'health_check'
883
-
884
- desc "package #{@name} into a #{pkg_type}"
885
- task pkg_type => dep_tasks do
886
- if pkg_type == 'makeself'
887
- run_makeself
888
- elsif pkg_type == 'msi'
889
- run_msi
890
- elsif pkg_type == 'bff'
891
- run_bff
892
- elsif pkg_type == 'pkgmk'
893
- run_pkgmk
894
- elsif pkg_type == 'mac_pkg'
895
- run_mac_package_build
896
- else # pkg_type == "fpm"
897
- run_fpm(pkg_type)
898
- end
899
-
900
- render_metadata(pkg_type)
901
-
902
- end
903
- end
904
-
905
- task 'copy' => package_types do
906
- if OHAI.platform == 'windows'
907
- cp_cmd = "xcopy #{config.package_dir}\\*.msi pkg\\ /Y"
908
- elsif OHAI.platform == 'aix'
909
- cp_cmd = "cp #{config.package_dir}/*.bff pkg/"
910
- else
911
- cp_cmd = "cp #{config.package_dir}/* pkg/"
912
- end
913
- shell = Mixlib::ShellOut.new(cp_cmd)
914
- shell.run_command
915
- shell.error!
916
- end
917
- task 'copy' => 'pkg'
918
-
919
- desc "run the health check on the #{@name} install path"
920
- task 'health_check' do
921
- if OHAI.platform == 'windows'
922
- puts 'Skipping health check on windows...'
923
- else
924
- # build a list of all whitelist files from all project dependencies
925
- whitelist_files = library.components.map { |component| component.whitelist_files }.flatten
926
- Omnibus::HealthCheck.run(install_path, whitelist_files)
927
- end
928
- end
929
- end
930
-
931
- desc "package #{@name}"
932
- task @name => "#{@name}:copy"
933
- end
934
- end
935
929
  end
936
930
  end