omnibus 1.3.0 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -1
- data/.rubocop.yml +30 -0
- data/.travis.yml +14 -3
- data/CHANGELOG.md +72 -49
- data/Gemfile +8 -5
- data/NOTICE +2 -2
- data/README.md +65 -7
- data/Rakefile +12 -3
- data/bin/makeself-header.sh +1 -1
- data/bin/makeself.sh +2 -2
- data/bin/omnibus +2 -2
- data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/background.png +0 -0
- data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/license.html +1 -0
- data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/welcome.html +1 -0
- data/functional/fixtures/mac_pkg/package-scripts/functional-test-project/postinstall +4 -0
- data/functional/packagers/mac_pkg_spec.rb +72 -0
- data/lib/omnibus/artifact.rb +11 -13
- data/lib/omnibus/build_version.rb +18 -21
- data/lib/omnibus/builder.rb +37 -48
- data/lib/omnibus/clean_tasks.rb +3 -5
- data/lib/omnibus/cli/application.rb +46 -53
- data/lib/omnibus/cli/base.rb +16 -19
- data/lib/omnibus/cli/build.rb +13 -13
- data/lib/omnibus/cli/cache.rb +13 -15
- data/lib/omnibus/cli/release.rb +4 -9
- data/lib/omnibus/cli.rb +2 -4
- data/lib/omnibus/config.rb +43 -23
- data/lib/omnibus/exceptions.rb +35 -1
- data/lib/omnibus/fetcher.rb +9 -13
- data/lib/omnibus/fetchers/git_fetcher.rb +15 -19
- data/lib/omnibus/fetchers/net_fetcher.rb +34 -38
- data/lib/omnibus/fetchers/path_fetcher.rb +7 -9
- data/lib/omnibus/fetchers/s3_cache_fetcher.rb +3 -4
- data/lib/omnibus/fetchers.rb +3 -3
- data/lib/omnibus/health_check.rb +126 -127
- data/lib/omnibus/library.rb +11 -12
- data/lib/omnibus/overrides.rb +6 -8
- data/lib/omnibus/package_release.rb +20 -22
- data/lib/omnibus/packagers/mac_pkg.rb +285 -0
- data/lib/omnibus/project.rb +215 -110
- data/lib/omnibus/reports.rb +16 -24
- data/lib/omnibus/s3_cacher.rb +15 -21
- data/lib/omnibus/software.rb +178 -88
- data/lib/omnibus/util.rb +25 -13
- data/lib/omnibus/version.rb +2 -2
- data/lib/omnibus.rb +11 -13
- data/omnibus.gemspec +20 -18
- data/spec/artifact_spec.rb +55 -52
- data/spec/build_version_spec.rb +121 -129
- data/spec/config_spec.rb +40 -0
- data/spec/data/projects/chefdk.rb +41 -0
- data/spec/data/projects/sample.rb +10 -0
- data/spec/data/software/erchef.rb +12 -12
- data/spec/data/software/zlib.rb +67 -0
- data/spec/fetchers/git_fetcher_spec.rb +55 -48
- data/spec/fetchers/net_fetcher_spec.rb +72 -78
- data/spec/omnibus_spec.rb +59 -0
- data/spec/overrides_spec.rb +64 -64
- data/spec/package_release_spec.rb +65 -64
- data/spec/packagers/mac_pkg_spec.rb +261 -0
- data/spec/project_spec.rb +138 -0
- data/spec/s3_cacher_spec.rb +9 -10
- data/spec/software_spec.rb +71 -50
- data/spec/spec_helper.rb +14 -7
- metadata +68 -60
- data/.rspec +0 -1
- data/.yardopts +0 -6
- data/spec/software_dirs_spec.rb +0 -34
data/lib/omnibus/project.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright (c) 2012
|
2
|
+
# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
|
3
|
+
# Copyright:: Copyright (c) 2014 Noah Kantrowitz
|
3
4
|
# License:: Apache License, Version 2.0
|
4
5
|
#
|
5
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -18,10 +19,10 @@ require 'omnibus/artifact'
|
|
18
19
|
require 'omnibus/exceptions'
|
19
20
|
require 'omnibus/library'
|
20
21
|
require 'omnibus/util'
|
22
|
+
require 'omnibus/packagers/mac_pkg'
|
21
23
|
require 'time'
|
22
24
|
|
23
25
|
module Omnibus
|
24
|
-
|
25
26
|
# Omnibus project DSL reader
|
26
27
|
#
|
27
28
|
# @todo It seems like there's a bit of a conflation between a
|
@@ -53,8 +54,6 @@ module Omnibus
|
|
53
54
|
# @param filename [String] unused!
|
54
55
|
#
|
55
56
|
# @see Omnibus::Project#load
|
56
|
-
#
|
57
|
-
# @todo Remove filename parameter, as it is unused.
|
58
57
|
def initialize(io, filename)
|
59
58
|
@output_package = nil
|
60
59
|
@name = nil
|
@@ -63,13 +62,16 @@ module Omnibus
|
|
63
62
|
@homepage = nil
|
64
63
|
@description = nil
|
65
64
|
@replaces = nil
|
66
|
-
|
67
|
-
@
|
68
|
-
|
69
|
-
@
|
70
|
-
@
|
71
|
-
@
|
72
|
-
|
65
|
+
@mac_pkg_identifier = nil
|
66
|
+
@overrides = {}
|
67
|
+
|
68
|
+
@exclusions = []
|
69
|
+
@conflicts = []
|
70
|
+
@config_files = []
|
71
|
+
@extra_package_files = []
|
72
|
+
@dependencies = []
|
73
|
+
@runtime_dependencies = []
|
74
|
+
instance_eval(io, filename)
|
73
75
|
validate
|
74
76
|
|
75
77
|
@library = Omnibus::Library.new(self)
|
@@ -96,9 +98,9 @@ module Omnibus
|
|
96
98
|
# @raise [MissingProjectConfiguration] if a value was not set
|
97
99
|
# before being subsequently retrieved (i.e., a name
|
98
100
|
# must be set in order to build a project)
|
99
|
-
def name(val=NULL_ARG)
|
101
|
+
def name(val = NULL_ARG)
|
100
102
|
@name = val unless val.equal?(NULL_ARG)
|
101
|
-
@name ||
|
103
|
+
@name || fail(MissingProjectConfiguration.new('name', 'my_project'))
|
102
104
|
end
|
103
105
|
|
104
106
|
# Set or retrieve the package name of the project. Unless
|
@@ -106,7 +108,7 @@ module Omnibus
|
|
106
108
|
#
|
107
109
|
# @param val [String] the package name to set
|
108
110
|
# @return [String]
|
109
|
-
def package_name(val=NULL_ARG)
|
111
|
+
def package_name(val = NULL_ARG)
|
110
112
|
@package_name = val unless val.equal?(NULL_ARG)
|
111
113
|
@package_name.nil? ? @name : @package_name
|
112
114
|
end
|
@@ -120,9 +122,9 @@ module Omnibus
|
|
120
122
|
# @raise [MissingProjectConfiguration] if a value was not set
|
121
123
|
# before being subsequently retrieved (i.e., an install_path
|
122
124
|
# must be set in order to build a project)
|
123
|
-
def install_path(val=NULL_ARG)
|
125
|
+
def install_path(val = NULL_ARG)
|
124
126
|
@install_path = val unless val.equal?(NULL_ARG)
|
125
|
-
@install_path ||
|
127
|
+
@install_path || fail(MissingProjectConfiguration.new('install_path', '/opt/chef'))
|
126
128
|
end
|
127
129
|
|
128
130
|
# Set or retrieve the the package maintainer.
|
@@ -133,9 +135,9 @@ module Omnibus
|
|
133
135
|
# @raise [MissingProjectConfiguration] if a value was not set
|
134
136
|
# before being subsequently retrieved (i.e., a maintainer must
|
135
137
|
# be set in order to build a project)
|
136
|
-
def maintainer(val=NULL_ARG)
|
138
|
+
def maintainer(val = NULL_ARG)
|
137
139
|
@maintainer = val unless val.equal?(NULL_ARG)
|
138
|
-
@maintainer ||
|
140
|
+
@maintainer || fail(MissingProjectConfiguration.new('maintainer', 'Chef Software, Inc.'))
|
139
141
|
end
|
140
142
|
|
141
143
|
# Set or retrive the package homepage.
|
@@ -146,9 +148,9 @@ module Omnibus
|
|
146
148
|
# @raise [MissingProjectConfiguration] if a value was not set
|
147
149
|
# before being subsequently retrieved (i.e., a homepage must be
|
148
150
|
# set in order to build a project)
|
149
|
-
def homepage(val=NULL_ARG)
|
151
|
+
def homepage(val = NULL_ARG)
|
150
152
|
@homepage = val unless val.equal?(NULL_ARG)
|
151
|
-
@homepage ||
|
153
|
+
@homepage || fail(MissingProjectConfiguration.new('homepage', 'http://www.getchef.com'))
|
152
154
|
end
|
153
155
|
|
154
156
|
# Defines the iteration for the package to be generated. Adheres
|
@@ -162,15 +164,15 @@ module Omnibus
|
|
162
164
|
case platform_family
|
163
165
|
when 'rhel'
|
164
166
|
platform_version =~ /^(\d+)/
|
165
|
-
maj =
|
167
|
+
maj = Regexp.last_match[1]
|
166
168
|
"#{build_iteration}.el#{maj}"
|
167
169
|
when 'freebsd'
|
168
170
|
platform_version =~ /^(\d+)/
|
169
|
-
maj =
|
171
|
+
maj = Regexp.last_match[1]
|
170
172
|
"#{build_iteration}.#{platform}.#{maj}.#{machine}"
|
171
173
|
when 'windows'
|
172
174
|
"#{build_iteration}.windows"
|
173
|
-
when 'aix'
|
175
|
+
when 'aix', 'debian'
|
174
176
|
"#{build_iteration}"
|
175
177
|
else
|
176
178
|
"#{build_iteration}.#{platform}.#{platform_version}"
|
@@ -187,7 +189,7 @@ module Omnibus
|
|
187
189
|
# @return [String]
|
188
190
|
#
|
189
191
|
# @see #name
|
190
|
-
def description(val=NULL_ARG)
|
192
|
+
def description(val = NULL_ARG)
|
191
193
|
@description = val unless val.equal?(NULL_ARG)
|
192
194
|
@description || "The full stack of #{name}"
|
193
195
|
end
|
@@ -202,7 +204,7 @@ module Omnibus
|
|
202
204
|
#
|
203
205
|
# @todo Consider having this default to {#package_name}; many uses of this
|
204
206
|
# method effectively do this already.
|
205
|
-
def replaces(val=NULL_ARG)
|
207
|
+
def replaces(val = NULL_ARG)
|
206
208
|
@replaces = val unless val.equal?(NULL_ARG)
|
207
209
|
@replaces
|
208
210
|
end
|
@@ -224,7 +226,7 @@ module Omnibus
|
|
224
226
|
# @return [String]
|
225
227
|
#
|
226
228
|
# @see Omnibus::BuildVersion
|
227
|
-
def build_version(val=NULL_ARG)
|
229
|
+
def build_version(val = NULL_ARG)
|
228
230
|
@build_version = val unless val.equal?(NULL_ARG)
|
229
231
|
@build_version
|
230
232
|
end
|
@@ -237,25 +239,50 @@ module Omnibus
|
|
237
239
|
#
|
238
240
|
# @todo Is there a better name for this than "build_iteration"?
|
239
241
|
# Would be nice to cut down confusiton with {#iteration}.
|
240
|
-
def build_iteration(val=NULL_ARG)
|
242
|
+
def build_iteration(val = NULL_ARG)
|
241
243
|
@build_iteration = val unless val.equal?(NULL_ARG)
|
242
244
|
@build_iteration || 1
|
243
245
|
end
|
244
246
|
|
247
|
+
def mac_pkg_identifier(val = NULL_ARG)
|
248
|
+
@mac_pkg_identifier = val unless val.equal?(NULL_ARG)
|
249
|
+
@mac_pkg_identifier
|
250
|
+
end
|
251
|
+
|
245
252
|
# Set or retrieve the {deb/rpm/solaris}-user fpm argument.
|
246
253
|
#
|
247
254
|
# @param val [String]
|
248
255
|
# @return [String]
|
249
|
-
def package_user(val=NULL_ARG)
|
256
|
+
def package_user(val = NULL_ARG)
|
250
257
|
@pkg_user = val unless val.equal?(NULL_ARG)
|
251
258
|
@pkg_user
|
252
259
|
end
|
253
260
|
|
261
|
+
# Set or retrieve the full overrides hash for all software being overridden. Calling it as
|
262
|
+
# a setter does not merge hash entries and will obliterate any previous overrides that have been setup.
|
263
|
+
#
|
264
|
+
# @param val [Hash]
|
265
|
+
# @return [Hash]
|
266
|
+
def overrides(val = NULL_ARG)
|
267
|
+
@overrides = val unless val.equal?(NULL_ARG)
|
268
|
+
@overrides
|
269
|
+
end
|
270
|
+
|
271
|
+
# Set or retrieve the overrides hash for one piece of software being overridden. Calling it as a
|
272
|
+
# setter does not merge hash entries and it will set all the overrides for a given software definition.
|
273
|
+
#
|
274
|
+
# @param val [Hash]
|
275
|
+
# @return [Hash]
|
276
|
+
def override(name, val = NULL_ARG)
|
277
|
+
@overrides[name] = val unless val.equal?(NULL_ARG)
|
278
|
+
@overrides[name]
|
279
|
+
end
|
280
|
+
|
254
281
|
# Set or retrieve the {deb/rpm/solaris}-group fpm argument.
|
255
282
|
#
|
256
283
|
# @param val [String]
|
257
284
|
# @return [String]
|
258
|
-
def package_group(val=NULL_ARG)
|
285
|
+
def package_group(val = NULL_ARG)
|
259
286
|
@pkg_group = val unless val.equal?(NULL_ARG)
|
260
287
|
@pkg_group
|
261
288
|
end
|
@@ -300,7 +327,7 @@ module Omnibus
|
|
300
327
|
#
|
301
328
|
# @param val [Array<String>] a list of names of Software components
|
302
329
|
# @return [Array<String>]
|
303
|
-
def dependencies(val=NULL_ARG)
|
330
|
+
def dependencies(val = NULL_ARG)
|
304
331
|
@dependencies = val unless val.equal?(NULL_ARG)
|
305
332
|
@dependencies
|
306
333
|
end
|
@@ -323,6 +350,33 @@ module Omnibus
|
|
323
350
|
@config_files << val
|
324
351
|
end
|
325
352
|
|
353
|
+
# Add other files or dirs outside of install_path
|
354
|
+
#
|
355
|
+
# @param val [String] the name of a dir or file to include in build
|
356
|
+
# @return [void]
|
357
|
+
# NOTE: This option is currently only supported with FPM based package
|
358
|
+
# builds such as RPM, DEB and .sh (makeselfinst). This isn't supported
|
359
|
+
# on Mac OSX packages, Windows MSI, AIX and Solaris
|
360
|
+
def extra_package_file(val)
|
361
|
+
@extra_package_files << val
|
362
|
+
end
|
363
|
+
|
364
|
+
# Set or retrieve the array of files and directories used to
|
365
|
+
# build this project. If you use this to write, only pass the
|
366
|
+
# full path to the dir or file you want included in the omnibus
|
367
|
+
# package build.
|
368
|
+
#
|
369
|
+
# @note - similar to the depdencies array - this will reinitialize
|
370
|
+
# the files array and overwrite and dependencies that were set using
|
371
|
+
# {#file}.
|
372
|
+
#
|
373
|
+
# @param val [Array<String>] a list of names of Software components
|
374
|
+
# @return [Array<String>]
|
375
|
+
def extra_package_files(val = NULL_ARG)
|
376
|
+
@extra_package_files = val unless val.equal?(NULL_ARG)
|
377
|
+
@extra_package_files
|
378
|
+
end
|
379
|
+
|
326
380
|
# Returns the platform version of the machine on which Omnibus is
|
327
381
|
# running, as determined by Ohai.
|
328
382
|
#
|
@@ -391,6 +445,37 @@ module Omnibus
|
|
391
445
|
"#{Omnibus.project_root}/package-scripts/#{name}"
|
392
446
|
end
|
393
447
|
|
448
|
+
# Path to the /files directory in the omnibus project. This directory can
|
449
|
+
# contain assets used for creating packages (e.g., Mac .pkg files and
|
450
|
+
# Windows MSIs can be installed by GUI which can optionally be customized
|
451
|
+
# with background images, license agreements, etc.)
|
452
|
+
#
|
453
|
+
# This method delegates to the Omnibus.project_root module function so that
|
454
|
+
# Packagers classes rely only on the Project object for their inputs.
|
455
|
+
#
|
456
|
+
# @return [String] path to the files directory.
|
457
|
+
def files_path
|
458
|
+
"#{Omnibus.project_root}/files"
|
459
|
+
end
|
460
|
+
|
461
|
+
# The directory where packages are written when created. Delegates to
|
462
|
+
# #config. The delegation allows Packagers (like Packagers::MacPkg) to
|
463
|
+
# define the implementation rather than using the global config everywhere.
|
464
|
+
#
|
465
|
+
# @return [String] path to the package directory.
|
466
|
+
def package_dir
|
467
|
+
config.package_dir
|
468
|
+
end
|
469
|
+
|
470
|
+
# The directory where intermediate packaging products may be stored.
|
471
|
+
# Delegates to Config so that Packagers have a consistent API.
|
472
|
+
#
|
473
|
+
# @see Config.package_tmp some caveats.
|
474
|
+
# @return [String] path to the package temp directory.
|
475
|
+
def package_tmp
|
476
|
+
config.package_tmp
|
477
|
+
end
|
478
|
+
|
394
479
|
# Determine the package type(s) to be built, based on the platform
|
395
480
|
# family for which the package is being built.
|
396
481
|
#
|
@@ -403,17 +488,19 @@ module Omnibus
|
|
403
488
|
def package_types
|
404
489
|
case platform_family
|
405
490
|
when 'debian'
|
406
|
-
[
|
491
|
+
['deb']
|
407
492
|
when 'fedora', 'rhel'
|
408
|
-
[
|
493
|
+
['rpm']
|
409
494
|
when 'aix'
|
410
|
-
[
|
495
|
+
['bff']
|
411
496
|
when 'solaris2'
|
412
|
-
[
|
497
|
+
['pkgmk']
|
413
498
|
when 'windows'
|
414
|
-
[
|
499
|
+
['msi']
|
500
|
+
when 'mac_os_x'
|
501
|
+
['mac_pkg']
|
415
502
|
else
|
416
|
-
[
|
503
|
+
['makeself']
|
417
504
|
end
|
418
505
|
end
|
419
506
|
|
@@ -451,7 +538,7 @@ module Omnibus
|
|
451
538
|
# this is just the platform_version.
|
452
539
|
# @return [String] the platform version
|
453
540
|
def platform_version_for_package
|
454
|
-
if platform ==
|
541
|
+
if platform == 'rhel'
|
455
542
|
platform_version[/([\d]+)\..+/, 1]
|
456
543
|
else
|
457
544
|
platform_version
|
@@ -462,8 +549,8 @@ module Omnibus
|
|
462
549
|
# rhel/centos become "el", all others are just platform
|
463
550
|
# @return [String] the platform family short name
|
464
551
|
def platform_shortname
|
465
|
-
if platform_family ==
|
466
|
-
|
552
|
+
if platform_family == 'rhel'
|
553
|
+
'el'
|
467
554
|
else
|
468
555
|
platform
|
469
556
|
end
|
@@ -472,9 +559,9 @@ module Omnibus
|
|
472
559
|
def render_metadata(pkg_type)
|
473
560
|
basename = output_package(pkg_type)
|
474
561
|
pkg_path = "#{config.package_dir}/#{basename}"
|
475
|
-
artifact = Artifact.new(pkg_path, [
|
562
|
+
artifact = Artifact.new(pkg_path, [platform_tuple], version: build_version)
|
476
563
|
metadata = artifact.flat_metadata
|
477
|
-
File.open("#{pkg_path}.metadata.json",
|
564
|
+
File.open("#{pkg_path}.metadata.json", 'w+') do |f|
|
478
565
|
f.print(JSON.pretty_generate(metadata))
|
479
566
|
end
|
480
567
|
end
|
@@ -483,22 +570,24 @@ module Omnibus
|
|
483
570
|
# @return [String] the basename of the package file
|
484
571
|
def output_package(pkg_type)
|
485
572
|
case pkg_type
|
486
|
-
when
|
573
|
+
when 'makeself'
|
487
574
|
"#{package_name}-#{build_version}_#{iteration}.sh"
|
488
|
-
when
|
575
|
+
when 'msi'
|
489
576
|
"#{package_name}-#{build_version}-#{iteration}.msi"
|
490
|
-
when
|
577
|
+
when 'bff'
|
491
578
|
"#{package_name}.#{bff_version}.bff"
|
492
|
-
when
|
579
|
+
when 'pkgmk'
|
493
580
|
"#{package_name}-#{build_version}-#{iteration}.solaris"
|
581
|
+
when 'mac_pkg'
|
582
|
+
Packagers::MacPkg.new(self).package_name
|
494
583
|
else # fpm
|
495
584
|
require "fpm/package/#{pkg_type}"
|
496
585
|
pkg = FPM::Package.types[pkg_type].new
|
497
586
|
pkg.version = build_version
|
498
587
|
pkg.name = package_name
|
499
588
|
pkg.iteration = iteration
|
500
|
-
if pkg_type ==
|
501
|
-
pkg.to_s(
|
589
|
+
if pkg_type == 'solaris'
|
590
|
+
pkg.to_s('NAME.FULLVERSION.ARCH.TYPE')
|
502
591
|
else
|
503
592
|
pkg.to_s
|
504
593
|
end
|
@@ -518,26 +607,27 @@ module Omnibus
|
|
518
607
|
# Mixlib::ShellOut object ready for execution. Using Arrays
|
519
608
|
# makes downstream processing needlessly complicated.
|
520
609
|
def msi_command
|
521
|
-
msi_command = [
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
610
|
+
msi_command = [
|
611
|
+
'light.exe',
|
612
|
+
'-nologo',
|
613
|
+
'-ext WixUIExtension',
|
614
|
+
'-cultures:en-us',
|
615
|
+
"-loc #{install_path}\\msi-tmp\\#{package_name}-en-us.wxl",
|
616
|
+
"#{install_path}\\msi-tmp\\#{package_name}-Files.wixobj",
|
617
|
+
"#{install_path}\\msi-tmp\\#{package_name}.wixobj",
|
618
|
+
"-out #{config.package_dir}\\#{output_package("msi")}",
|
619
|
+
]
|
529
620
|
|
530
621
|
# Don't care about the 204 return code from light.exe since it's
|
531
622
|
# about some expected warnings...
|
532
|
-
[msi_command.join(
|
623
|
+
[msi_command.join(' '), { returns: [0, 204] }]
|
533
624
|
end
|
534
625
|
|
535
626
|
def bff_command
|
536
|
-
bff_command = [
|
537
|
-
[bff_command.join(
|
627
|
+
bff_command = ['sudo /usr/sbin/mkinstallp -d / -T /tmp/bff/gen.template']
|
628
|
+
[bff_command.join(' '), { returns: [0] }]
|
538
629
|
end
|
539
630
|
|
540
|
-
|
541
631
|
# The {https://github.com/jordansissel/fpm fpm} command to
|
542
632
|
# generate a package for RedHat, Ubuntu, Solaris, etc. platforms.
|
543
633
|
#
|
@@ -553,17 +643,20 @@ module Omnibus
|
|
553
643
|
# @todo Use the long option names (i.e., the double-dash ones) in
|
554
644
|
# the fpm command for maximum clarity.
|
555
645
|
def fpm_command(pkg_type)
|
556
|
-
command_and_opts = [
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
646
|
+
command_and_opts = [
|
647
|
+
'fpm',
|
648
|
+
'-s dir',
|
649
|
+
"-t #{pkg_type}",
|
650
|
+
"-v #{build_version}",
|
651
|
+
"-n #{package_name}",
|
652
|
+
"-p #{output_package(pkg_type)}",
|
653
|
+
"--iteration #{iteration}",
|
654
|
+
"-m '#{maintainer}'",
|
655
|
+
"--description '#{description}'",
|
656
|
+
"--url #{homepage}",
|
657
|
+
]
|
658
|
+
|
659
|
+
if File.exist?(File.join(package_scripts_path, 'preinst'))
|
567
660
|
command_and_opts << "--before-install '#{File.join(package_scripts_path, "preinst")}'"
|
568
661
|
end
|
569
662
|
|
@@ -582,7 +675,7 @@ module Omnibus
|
|
582
675
|
@exclusions.each do |pattern|
|
583
676
|
command_and_opts << "--exclude '#{pattern}'"
|
584
677
|
end
|
585
|
-
|
678
|
+
|
586
679
|
@config_files.each do |config_file|
|
587
680
|
command_and_opts << "--config-files '#{config_file}'"
|
588
681
|
end
|
@@ -609,18 +702,24 @@ module Omnibus
|
|
609
702
|
|
610
703
|
command_and_opts << " --replaces #{@replaces}" if @replaces
|
611
704
|
command_and_opts << install_path
|
705
|
+
|
706
|
+
@extra_package_files.each do |files|
|
707
|
+
command_and_opts << files
|
708
|
+
end
|
709
|
+
|
612
710
|
command_and_opts
|
613
711
|
end
|
614
712
|
|
615
713
|
# TODO: what's this do?
|
616
714
|
def makeself_command
|
617
|
-
command_and_opts = [
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
715
|
+
command_and_opts = [
|
716
|
+
File.expand_path(File.join(Omnibus.source_root, 'bin', 'makeself.sh')),
|
717
|
+
'--gzip',
|
718
|
+
install_path,
|
719
|
+
output_package('makeself'),
|
720
|
+
"'The full stack of #{@name}'",
|
721
|
+
]
|
722
|
+
command_and_opts << './makeselfinst' if File.exists?("#{package_scripts_path}/makeselfinst")
|
624
723
|
command_and_opts
|
625
724
|
end
|
626
725
|
|
@@ -635,11 +734,11 @@ module Omnibus
|
|
635
734
|
end
|
636
735
|
|
637
736
|
# run the makeself program
|
638
|
-
package_commands << makeself_command.join(
|
737
|
+
package_commands << makeself_command.join(' ')
|
639
738
|
|
640
739
|
# rm the makeself installer (for incremental builds)
|
641
740
|
package_commands << "rm -f #{install_path}/makeselfinst"
|
642
|
-
package_commands.each {|cmd| run_package_command(cmd) }
|
741
|
+
package_commands.each { |cmd| run_package_command(cmd) }
|
643
742
|
end
|
644
743
|
|
645
744
|
# Runs the necessary command to make an MSI. As a side-effect, sets `output_package`
|
@@ -649,13 +748,13 @@ module Omnibus
|
|
649
748
|
end
|
650
749
|
|
651
750
|
def bff_version
|
652
|
-
build_version.split(/[^\d]/)[0..2].join(
|
751
|
+
build_version.split(/[^\d]/)[0..2].join('.') + ".#{iteration}"
|
653
752
|
end
|
654
753
|
|
655
754
|
def run_bff
|
656
|
-
FileUtils.rm_rf
|
657
|
-
FileUtils.rm_rf
|
658
|
-
FileUtils.mkdir
|
755
|
+
FileUtils.rm_rf '/.info/*'
|
756
|
+
FileUtils.rm_rf '/tmp/bff'
|
757
|
+
FileUtils.mkdir '/tmp/bff'
|
659
758
|
|
660
759
|
system "find #{install_path} -print > /tmp/bff/file.list"
|
661
760
|
|
@@ -680,8 +779,8 @@ module Omnibus
|
|
680
779
|
install_dirname = File.dirname(install_path)
|
681
780
|
install_basename = File.basename(install_path)
|
682
781
|
|
683
|
-
system
|
684
|
-
FileUtils.mkdir
|
782
|
+
system 'sudo rm -rf /tmp/pkgmk'
|
783
|
+
FileUtils.mkdir '/tmp/pkgmk'
|
685
784
|
|
686
785
|
system "cd #{install_dirname} && find #{install_basename} -print > /tmp/pkgmk/files"
|
687
786
|
|
@@ -691,7 +790,7 @@ i postinstall
|
|
691
790
|
i postremove
|
692
791
|
EOF
|
693
792
|
|
694
|
-
File.open
|
793
|
+
File.open '/tmp/pkgmk/Prototype', 'w+' do |f|
|
695
794
|
f.write prototype_content
|
696
795
|
end
|
697
796
|
|
@@ -717,25 +816,29 @@ EMAIL=#{maintainer}
|
|
717
816
|
PSTAMP=#{`hostname`.chomp + Time.now.utc.iso8601}
|
718
817
|
EOF
|
719
818
|
|
720
|
-
File.open
|
819
|
+
File.open '/tmp/pkgmk/pkginfo', 'w+' do |f|
|
721
820
|
f.write pkginfo_content
|
722
821
|
end
|
723
822
|
|
724
|
-
FileUtils.cp "#{package_scripts_path}/postinst",
|
725
|
-
FileUtils.cp "#{package_scripts_path}/postrm",
|
823
|
+
FileUtils.cp "#{package_scripts_path}/postinst", '/tmp/pkgmk/postinstall'
|
824
|
+
FileUtils.cp "#{package_scripts_path}/postrm", '/tmp/pkgmk/postremove'
|
726
825
|
|
727
|
-
shellout!("pkgmk -o -r #{install_dirname} -d /tmp/pkgmk -f /tmp/pkgmk/Prototype", :
|
826
|
+
shellout!("pkgmk -o -r #{install_dirname} -d /tmp/pkgmk -f /tmp/pkgmk/Prototype", timeout: 3600)
|
728
827
|
|
729
|
-
system
|
828
|
+
system 'pkgchk -vd /tmp/pkgmk chef'
|
730
829
|
|
731
830
|
system "pkgtrans /tmp/pkgmk /var/cache/omnibus/pkg/#{output_package("pkgmk")} chef"
|
732
831
|
end
|
733
832
|
|
833
|
+
def run_mac_package_build
|
834
|
+
Packagers::MacPkg.new(self).build
|
835
|
+
end
|
836
|
+
|
734
837
|
# Runs the necessary command to make a package with fpm. As a side-effect,
|
735
838
|
# sets `output_package`
|
736
839
|
# @return void
|
737
840
|
def run_fpm(pkg_type)
|
738
|
-
run_package_command(fpm_command(pkg_type).join(
|
841
|
+
run_package_command(fpm_command(pkg_type).join(' '))
|
739
842
|
end
|
740
843
|
|
741
844
|
# Executes the given command via mixlib-shellout.
|
@@ -743,8 +846,8 @@ PSTAMP=#{`hostname`.chomp + Time.now.utc.iso8601}
|
|
743
846
|
# object, so the caller can inspect the stdout and stderr.
|
744
847
|
def run_package_command(cmd)
|
745
848
|
cmd_options = {
|
746
|
-
:
|
747
|
-
:
|
849
|
+
timeout: 3600,
|
850
|
+
cwd: config.package_dir,
|
748
851
|
}
|
749
852
|
|
750
853
|
if cmd.is_a?(Array)
|
@@ -764,26 +867,28 @@ PSTAMP=#{`hostname`.chomp + Time.now.utc.iso8601}
|
|
764
867
|
# @return void
|
765
868
|
def render_tasks
|
766
869
|
directory config.package_dir
|
767
|
-
directory
|
870
|
+
directory 'pkg'
|
768
871
|
|
769
872
|
namespace :projects do
|
770
873
|
namespace @name do
|
771
874
|
|
772
875
|
package_types.each do |pkg_type|
|
773
|
-
dep_tasks = @dependencies.map {|dep| "software:#{dep}"}
|
876
|
+
dep_tasks = @dependencies.map { |dep| "software:#{dep}" }
|
774
877
|
dep_tasks << config.package_dir
|
775
|
-
dep_tasks <<
|
878
|
+
dep_tasks << 'health_check'
|
776
879
|
|
777
880
|
desc "package #{@name} into a #{pkg_type}"
|
778
881
|
task pkg_type => dep_tasks do
|
779
|
-
if pkg_type ==
|
882
|
+
if pkg_type == 'makeself'
|
780
883
|
run_makeself
|
781
|
-
elsif pkg_type ==
|
884
|
+
elsif pkg_type == 'msi'
|
782
885
|
run_msi
|
783
|
-
elsif pkg_type ==
|
886
|
+
elsif pkg_type == 'bff'
|
784
887
|
run_bff
|
785
|
-
elsif pkg_type ==
|
888
|
+
elsif pkg_type == 'pkgmk'
|
786
889
|
run_pkgmk
|
890
|
+
elsif pkg_type == 'mac_pkg'
|
891
|
+
run_mac_package_build
|
787
892
|
else # pkg_type == "fpm"
|
788
893
|
run_fpm(pkg_type)
|
789
894
|
end
|
@@ -793,10 +898,10 @@ PSTAMP=#{`hostname`.chomp + Time.now.utc.iso8601}
|
|
793
898
|
end
|
794
899
|
end
|
795
900
|
|
796
|
-
task
|
797
|
-
if OHAI.platform ==
|
901
|
+
task 'copy' => package_types do
|
902
|
+
if OHAI.platform == 'windows'
|
798
903
|
cp_cmd = "xcopy #{config.package_dir}\\*.msi pkg\\ /Y"
|
799
|
-
elsif OHAI.platform ==
|
904
|
+
elsif OHAI.platform == 'aix'
|
800
905
|
cp_cmd = "cp #{config.package_dir}/*.bff pkg/"
|
801
906
|
else
|
802
907
|
cp_cmd = "cp #{config.package_dir}/* pkg/"
|
@@ -805,15 +910,15 @@ PSTAMP=#{`hostname`.chomp + Time.now.utc.iso8601}
|
|
805
910
|
shell.run_command
|
806
911
|
shell.error!
|
807
912
|
end
|
808
|
-
task
|
913
|
+
task 'copy' => 'pkg'
|
809
914
|
|
810
915
|
desc "run the health check on the #{@name} install path"
|
811
|
-
task
|
812
|
-
if OHAI.platform ==
|
813
|
-
puts
|
916
|
+
task 'health_check' do
|
917
|
+
if OHAI.platform == 'windows'
|
918
|
+
puts 'Skipping health check on windows...'
|
814
919
|
else
|
815
920
|
# build a list of all whitelist files from all project dependencies
|
816
|
-
whitelist_files = library.components.map{|component| component.whitelist_files }.flatten
|
921
|
+
whitelist_files = library.components.map { |component| component.whitelist_files }.flatten
|
817
922
|
Omnibus::HealthCheck.run(install_path, whitelist_files)
|
818
923
|
end
|
819
924
|
end
|