omnibus 3.1.1 → 3.2.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +71 -0
- data/Gemfile +0 -7
- data/README.md +108 -36
- data/Rakefile +1 -5
- data/docs/omnibus-build-cache.md +5 -5
- data/features/commands/_deprecated.feature +21 -3
- data/features/step_definitions/generator_steps.rb +7 -7
- data/lib/omnibus.rb +232 -171
- data/lib/omnibus/build_version.rb +2 -2
- data/lib/omnibus/builder.rb +38 -19
- data/lib/omnibus/cleaner.rb +5 -5
- data/lib/omnibus/cleanroom.rb +141 -0
- data/lib/omnibus/cli.rb +6 -9
- data/lib/omnibus/cli/base.rb +2 -1
- data/lib/omnibus/cli/cache.rb +15 -21
- data/lib/omnibus/cli/deprecated.rb +40 -4
- data/lib/omnibus/cli/publish.rb +61 -0
- data/lib/omnibus/config.rb +350 -189
- data/lib/omnibus/digestable.rb +131 -0
- data/lib/omnibus/exceptions.rb +163 -83
- data/lib/omnibus/fetcher.rb +1 -1
- data/lib/omnibus/fetchers/net_fetcher.rb +19 -13
- data/lib/omnibus/fetchers/path_fetcher.rb +8 -1
- data/lib/omnibus/fetchers/s3_cache_fetcher.rb +16 -7
- data/lib/omnibus/generator.rb +2 -2
- data/lib/omnibus/generator_files/Gemfile.erb +4 -1
- data/lib/omnibus/generator_files/README.md.erb +10 -0
- data/lib/omnibus/generator_files/{omnibus.rb.example.erb → omnibus.rb.erb} +20 -11
- data/lib/omnibus/generator_files/package_scripts/makeselfinst.erb +1 -1
- data/lib/omnibus/generator_files/project.rb.erb +2 -2
- data/lib/omnibus/generator_files/windows_msi/localization-en-us.wxl.erb +3 -3
- data/lib/omnibus/git_cache.rb +192 -0
- data/lib/omnibus/health_check.rb +171 -116
- data/lib/omnibus/library.rb +4 -2
- data/lib/omnibus/logger.rb +60 -1
- data/lib/omnibus/null_argumentable.rb +51 -0
- data/lib/omnibus/ohai.rb +29 -8
- data/lib/omnibus/package.rb +240 -0
- data/lib/omnibus/packagers/base.rb +21 -42
- data/lib/omnibus/packagers/mac_dmg.rb +5 -5
- data/lib/omnibus/packagers/mac_pkg.rb +20 -19
- data/lib/omnibus/packagers/windows_msi.rb +7 -7
- data/lib/omnibus/project.rb +969 -486
- data/lib/omnibus/publisher.rb +76 -0
- data/lib/omnibus/publishers/artifactory_publisher.rb +168 -0
- data/lib/omnibus/publishers/null_publisher.rb +23 -0
- data/lib/omnibus/publishers/s3_publisher.rb +99 -0
- data/lib/omnibus/s3_cache.rb +150 -63
- data/lib/omnibus/software.rb +749 -321
- data/lib/omnibus/{sugar.rb → sugarable.rb} +11 -6
- data/lib/omnibus/version.rb +1 -1
- data/omnibus.gemspec +8 -8
- data/spec/data/complicated/config/projects/angrychef.rb +1 -1
- data/spec/data/complicated/config/projects/chef-windows.rb +1 -1
- data/spec/data/complicated/config/projects/chef.rb +1 -1
- data/spec/data/complicated/config/projects/chefdk-windows.rb +1 -1
- data/spec/data/complicated/config/projects/chefdk.rb +1 -1
- data/spec/data/complicated/config/software/cacerts.rb +1 -1
- data/spec/data/complicated/config/software/chef-client-msi.rb +1 -1
- data/spec/data/complicated/config/software/libgcc.rb +1 -1
- data/spec/data/complicated/config/software/libiconv.rb +0 -11
- data/spec/data/complicated/config/software/libpng.rb +2 -2
- data/spec/data/complicated/config/software/openssl.rb +1 -1
- data/spec/data/complicated/config/software/ruby.rb +1 -1
- data/spec/data/complicated/config/software/runit.rb +4 -4
- data/spec/data/projects/chefdk.rb +1 -1
- data/spec/data/projects/sample.rb +1 -1
- data/spec/data/software/erchef.rb +3 -1
- data/spec/functional/packagers/mac_spec.rb +25 -24
- data/spec/functional/packagers/windows_spec.rb +21 -20
- data/spec/spec_helper.rb +43 -4
- data/spec/unit/build_version_spec.rb +14 -16
- data/spec/unit/cleanroom_spec.rb +63 -0
- data/spec/unit/config_spec.rb +36 -30
- data/spec/unit/digestable_spec.rb +38 -0
- data/spec/unit/fetchers/net_fetcher_spec.rb +98 -87
- data/spec/unit/{install_path_cache_spec.rb → git_cache_spec.rb} +67 -56
- data/spec/unit/health_check_spec.rb +73 -0
- data/spec/unit/library_spec.rb +166 -159
- data/spec/unit/ohai_spec.rb +19 -0
- data/spec/unit/omnibus_spec.rb +43 -41
- data/spec/unit/package_spec.rb +178 -0
- data/spec/unit/packagers/base_spec.rb +17 -47
- data/spec/unit/packagers/mac_pkg_spec.rb +104 -126
- data/spec/unit/project_spec.rb +176 -25
- data/spec/unit/publisher_spec.rb +49 -0
- data/spec/unit/publishers/artifactory_publisher_spec.rb +80 -0
- data/spec/unit/publishers/s3_publisher_spec.rb +120 -0
- data/spec/unit/s3_cacher_spec.rb +84 -19
- data/spec/unit/software_spec.rb +397 -170
- data/spec/unit/sugarable_spec.rb +43 -0
- metadata +62 -50
- data/Guardfile +0 -10
- data/lib/omnibus/artifact.rb +0 -165
- data/lib/omnibus/cli/release.rb +0 -40
- data/lib/omnibus/generator_files/Vagrantfile.erb +0 -75
- data/lib/omnibus/install_path_cache.rb +0 -105
- data/lib/omnibus/overrides.rb +0 -88
- data/lib/omnibus/package_release.rb +0 -154
- data/lib/omnibus/software_s3_urls.rb +0 -50
- data/spec/unit/artifact_spec.rb +0 -91
- data/spec/unit/overrides_spec.rb +0 -102
- data/spec/unit/package_release_spec.rb +0 -180
- data/spec/unit/sugar_spec.rb +0 -17
@@ -155,13 +155,13 @@ module Omnibus
|
|
155
155
|
set current view of container window to icon view
|
156
156
|
set toolbar visible of container window to false
|
157
157
|
set statusbar visible of container window to false
|
158
|
-
set the bounds of container window to {#{
|
158
|
+
set the bounds of container window to {#{Config[:dmg_window_bounds]}}
|
159
159
|
set theViewOptions to the icon view options of container window
|
160
160
|
set arrangement of theViewOptions to not arranged
|
161
161
|
set icon size of theViewOptions to 72
|
162
162
|
set background picture of theViewOptions to file ".support:'background.png'"
|
163
163
|
delay 5
|
164
|
-
set position of item "'#{project.name}.pkg'" of container window to {#{
|
164
|
+
set position of item "'#{project.name}.pkg'" of container window to {#{Config[:dmg_pkg_position]}}
|
165
165
|
update without registering applications
|
166
166
|
delay 5
|
167
167
|
end tell
|
@@ -208,7 +208,7 @@ module Omnibus
|
|
208
208
|
|
209
209
|
# @see Base#package_name
|
210
210
|
def package_name
|
211
|
-
"#{name}-#{
|
211
|
+
"#{project.name}-#{project.build_version}-#{project.iteration}.dmg"
|
212
212
|
end
|
213
213
|
|
214
214
|
# The path to the folder that we should stage.
|
@@ -222,14 +222,14 @@ module Omnibus
|
|
222
222
|
#
|
223
223
|
# @return [String]
|
224
224
|
def writable_dmg
|
225
|
-
File.expand_path("#{staging_dir}/#{name}-writable.dmg")
|
225
|
+
File.expand_path("#{staging_dir}/#{project.name}-writable.dmg")
|
226
226
|
end
|
227
227
|
|
228
228
|
# The path where the final dmg will be produced.
|
229
229
|
#
|
230
230
|
# @return [String]
|
231
231
|
def final_dmg
|
232
|
-
File.expand_path("#{
|
232
|
+
File.expand_path("#{Config.package_dir}/#{project.name}-#{project.build_version}-#{project.iteration}.dmg")
|
233
233
|
end
|
234
234
|
end
|
235
235
|
end
|
@@ -33,7 +33,7 @@ module Omnibus
|
|
33
33
|
|
34
34
|
setup do
|
35
35
|
purge_directory(staging_dir)
|
36
|
-
purge_directory(
|
36
|
+
purge_directory(Config.package_dir)
|
37
37
|
purge_directory(staging_resources_path)
|
38
38
|
copy_directory(resources_path, staging_resources_path)
|
39
39
|
|
@@ -49,7 +49,7 @@ module Omnibus
|
|
49
49
|
generate_distribution
|
50
50
|
build_product_pkg
|
51
51
|
|
52
|
-
if
|
52
|
+
if Config.build_dmg
|
53
53
|
Packager::MacDmg.new(self).run!
|
54
54
|
end
|
55
55
|
end
|
@@ -60,14 +60,14 @@ module Omnibus
|
|
60
60
|
|
61
61
|
# @see Base#package_name
|
62
62
|
def package_name
|
63
|
-
"#{name}-#{
|
63
|
+
"#{project.name}-#{project.build_version}-#{project.iteration}.pkg"
|
64
64
|
end
|
65
65
|
|
66
66
|
# The full path where the product package was/will be written.
|
67
67
|
#
|
68
68
|
# @return [String] Path to the packge file.
|
69
69
|
def final_pkg
|
70
|
-
File.expand_path("#{
|
70
|
+
File.expand_path("#{Config.package_dir}/#{package_name}")
|
71
71
|
end
|
72
72
|
|
73
73
|
#
|
@@ -79,10 +79,10 @@ module Omnibus
|
|
79
79
|
execute <<-EOH.gsub(/^ {8}/, '')
|
80
80
|
pkgbuild \\
|
81
81
|
--identifier "#{identifier}" \\
|
82
|
-
--version "#{
|
83
|
-
--scripts "#{
|
84
|
-
--root "#{
|
85
|
-
--install-location "#{
|
82
|
+
--version "#{project.build_version}" \\
|
83
|
+
--scripts "#{project.package_scripts_path}" \\
|
84
|
+
--root "#{project.install_dir}" \\
|
85
|
+
--install-location "#{project.install_dir}" \\
|
86
86
|
"#{component_pkg}"
|
87
87
|
EOH
|
88
88
|
end
|
@@ -100,7 +100,7 @@ module Omnibus
|
|
100
100
|
file.puts <<-EOH.gsub(/^ {10}/, '')
|
101
101
|
<?xml version="1.0" standalone="no"?>
|
102
102
|
<installer-gui-script minSpecVersion="1">
|
103
|
-
<title>#{friendly_name}</title>
|
103
|
+
<title>#{project.friendly_name}</title>
|
104
104
|
<background file="background.png" alignment="bottomleft" mime-type="image/png"/>
|
105
105
|
<welcome file="welcome.html" mime-type="text/html"/>
|
106
106
|
<license file="license.html" mime-type="text/html"/>
|
@@ -117,7 +117,7 @@ module Omnibus
|
|
117
117
|
<choice id="#{identifier}" visible="false">
|
118
118
|
<pkg-ref id="#{identifier}"/>
|
119
119
|
</choice>
|
120
|
-
<pkg-ref id="#{identifier}" version="#{
|
120
|
+
<pkg-ref id="#{identifier}" version="#{project.build_version}" onConclusion="none">#{component_pkg}</pkg-ref>
|
121
121
|
</installer-gui-script>
|
122
122
|
EOH
|
123
123
|
end
|
@@ -128,16 +128,17 @@ module Omnibus
|
|
128
128
|
# product that is shipped to end users.
|
129
129
|
#
|
130
130
|
def build_product_pkg
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
131
|
+
command = <<-EOH.gsub(/^ {8}/, '')
|
132
|
+
productbuild \\
|
133
|
+
--distribution "#{distribution_file}" \\
|
134
|
+
--resources "#{staging_resources_path}" \\
|
135
|
+
EOH
|
136
136
|
|
137
|
-
|
138
|
-
|
137
|
+
command << %Q( --sign "#{Config.signing_identity}" \\\n) if Config.sign_pkg
|
138
|
+
command << %Q( "#{final_pkg}")
|
139
|
+
command << %Q(\n)
|
139
140
|
|
140
|
-
execute
|
141
|
+
execute(command)
|
141
142
|
end
|
142
143
|
|
143
144
|
# The identifier for this mac package (the com.whatever.thing.whatever).
|
@@ -161,7 +162,7 @@ module Omnibus
|
|
161
162
|
#
|
162
163
|
# @return [String] the filename of the component .pkg file to create.
|
163
164
|
def component_pkg
|
164
|
-
"#{name}-core.pkg"
|
165
|
+
"#{project.name}-core.pkg"
|
165
166
|
end
|
166
167
|
|
167
168
|
# Sanitize the given string for the package identifier.
|
@@ -32,7 +32,7 @@ module Omnibus
|
|
32
32
|
|
33
33
|
setup do
|
34
34
|
purge_directory(staging_dir)
|
35
|
-
purge_directory(
|
35
|
+
purge_directory(Config.package_dir)
|
36
36
|
purge_directory(staging_resources_path)
|
37
37
|
copy_directory(resources_path, staging_resources_path)
|
38
38
|
|
@@ -49,7 +49,7 @@ module Omnibus
|
|
49
49
|
# harvest the files with heat.exe
|
50
50
|
# recursively generate fragment for project directory
|
51
51
|
execute [
|
52
|
-
"heat.exe dir \"#{
|
52
|
+
"heat.exe dir \"#{project.install_dir}\"",
|
53
53
|
'-nologo -srd -gg -cg ProjectDir',
|
54
54
|
'-dr PROJECTLOCATION -var var.ProjectSourceDir',
|
55
55
|
'-out project-files.wxs',
|
@@ -58,7 +58,7 @@ module Omnibus
|
|
58
58
|
# compile with candle.exe
|
59
59
|
execute [
|
60
60
|
'candle.exe -nologo',
|
61
|
-
"-dProjectSourceDir=\"#{
|
61
|
+
"-dProjectSourceDir=\"#{project.install_dir}\" project-files.wxs",
|
62
62
|
"\"#{resource('source.wxs')}\"",
|
63
63
|
].join(' ')
|
64
64
|
|
@@ -78,14 +78,14 @@ module Omnibus
|
|
78
78
|
|
79
79
|
# @see Base#package_name
|
80
80
|
def package_name
|
81
|
-
"#{name}-#{
|
81
|
+
"#{project.name}-#{project.build_version}-#{project.iteration}.msi"
|
82
82
|
end
|
83
83
|
|
84
84
|
# The full path where the product package was/will be written.
|
85
85
|
#
|
86
86
|
# @return [String] Path to the packge file.
|
87
87
|
def final_pkg
|
88
|
-
File.expand_path("#{
|
88
|
+
File.expand_path("#{Config.package_dir}/#{package_name}")
|
89
89
|
end
|
90
90
|
|
91
91
|
# Helper method to set the msi version for a given project
|
@@ -101,8 +101,8 @@ module Omnibus
|
|
101
101
|
# MSI source files expect two versions to be set in the msi_parameters:
|
102
102
|
# msi_version & msi_display_version
|
103
103
|
|
104
|
-
versions =
|
105
|
-
@msi_version = "#{versions[0]}.#{versions[1]}.#{versions[2]}.#{
|
104
|
+
versions = project.build_version.split(/[.+-]/)
|
105
|
+
@msi_version = "#{versions[0]}.#{versions[1]}.#{versions[2]}.#{project.build_iteration}"
|
106
106
|
@msi_display_version = "#{versions[0]}.#{versions[1]}.#{versions[2]}"
|
107
107
|
end
|
108
108
|
end
|
data/lib/omnibus/project.rb
CHANGED
@@ -19,549 +19,514 @@ require 'time'
|
|
19
19
|
require 'json'
|
20
20
|
|
21
21
|
module Omnibus
|
22
|
+
#
|
22
23
|
# Omnibus project DSL reader
|
23
24
|
#
|
24
|
-
# @todo It seems like there's a bit of a conflation between a
|
25
|
-
# "
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
# @todo: Generate the DSL methods via metaprogramming... they're all so similar
|
25
|
+
# @todo It seems like there's a bit of a conflation between a "project" and a
|
26
|
+
# "package" in this class... perhaps the package-building portions should be
|
27
|
+
# extracted to a separate class.
|
28
|
+
#
|
29
|
+
#
|
30
30
|
class Project
|
31
|
+
class << self
|
32
|
+
#
|
33
|
+
# @param [String] filepath
|
34
|
+
# the path to the project definition to load from disk
|
35
|
+
#
|
36
|
+
# @return [Software]
|
37
|
+
#
|
38
|
+
def load(filepath)
|
39
|
+
instance = new(filepath)
|
40
|
+
instance.evaluate_file(filepath)
|
41
|
+
instance
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
include Cleanroom
|
46
|
+
include Digestable
|
31
47
|
include Logging
|
48
|
+
include NullArgumentable
|
49
|
+
include Sugarable
|
32
50
|
include Util
|
33
51
|
|
34
|
-
|
35
|
-
|
36
|
-
attr_reader :library
|
37
|
-
attr_accessor :dirty_cache
|
38
|
-
attr_accessor :build_version_dsl
|
39
|
-
attr_reader :resources_path
|
40
|
-
|
41
|
-
# Convenience method to initialize a Project from a DSL file.
|
42
|
-
#
|
43
|
-
# @param filename [String] the filename of the Project DSL file to load.
|
44
|
-
def self.load(filename)
|
45
|
-
new(IO.read(filename), filename)
|
52
|
+
def initialize(filepath = nil)
|
53
|
+
@filepath = filepath
|
46
54
|
end
|
47
55
|
|
48
|
-
# Create a new Project from the contents of a DSL file. Prefer
|
49
|
-
# calling {Omnibus::Project#load} instead of using this method
|
50
|
-
# directly.
|
51
56
|
#
|
52
|
-
#
|
53
|
-
# @param filename [String] unused!
|
57
|
+
# @!group DSL methods
|
54
58
|
#
|
55
|
-
#
|
56
|
-
|
57
|
-
|
58
|
-
@name = nil
|
59
|
-
@friendly_name = nil
|
60
|
-
@msi_parameters = {}
|
61
|
-
@package_name = nil
|
62
|
-
@install_path = nil
|
63
|
-
@resources_path = nil
|
64
|
-
@homepage = nil
|
65
|
-
@description = nil
|
66
|
-
@replaces = nil
|
67
|
-
@mac_pkg_identifier = nil
|
68
|
-
@overrides = {}
|
69
|
-
|
70
|
-
@exclusions = []
|
71
|
-
@conflicts = []
|
72
|
-
@config_files = []
|
73
|
-
@extra_package_files = []
|
74
|
-
@dependencies = []
|
75
|
-
@runtime_dependencies = []
|
76
|
-
@dirty_cache = false
|
77
|
-
instance_eval(io, filename)
|
78
|
-
validate
|
79
|
-
|
80
|
-
@library = Omnibus::Library.new(self)
|
81
|
-
end
|
82
|
-
|
83
|
-
def <=>(other)
|
84
|
-
self.name <=> other.name
|
85
|
-
end
|
86
|
-
|
87
|
-
def build_me
|
88
|
-
FileUtils.mkdir_p(config.package_dir)
|
89
|
-
FileUtils.mkdir_p('pkg')
|
90
|
-
FileUtils.rm_rf(install_path)
|
91
|
-
FileUtils.mkdir_p(install_path)
|
92
|
-
|
93
|
-
library.build_order.each do |software|
|
94
|
-
software.build_me
|
95
|
-
end
|
96
|
-
health_check_me
|
97
|
-
package_me
|
98
|
-
end
|
99
|
-
|
100
|
-
def health_check_me
|
101
|
-
if Ohai.platform == 'windows'
|
102
|
-
log.info(log_key) { 'Skipping health check on Windows' }
|
103
|
-
else
|
104
|
-
# build a list of all whitelist files from all project dependencies
|
105
|
-
whitelist_files = library.components.map { |component| component.whitelist_files }.flatten
|
106
|
-
Omnibus::HealthCheck.run(install_path, whitelist_files)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def package_me
|
111
|
-
package_types.each do |pkg_type|
|
112
|
-
if pkg_type == 'makeself'
|
113
|
-
run_makeself
|
114
|
-
elsif pkg_type == 'msi'
|
115
|
-
run_msi
|
116
|
-
elsif pkg_type == 'bff'
|
117
|
-
run_bff
|
118
|
-
elsif pkg_type == 'pkgmk'
|
119
|
-
run_pkgmk
|
120
|
-
elsif pkg_type == 'mac_pkg'
|
121
|
-
run_mac_package_build
|
122
|
-
elsif pkg_type == 'mac_dmg'
|
123
|
-
# noop, since the dmg creation is handled by the packager
|
124
|
-
else # pkg_type == "fpm"
|
125
|
-
run_fpm(pkg_type)
|
126
|
-
end
|
127
|
-
|
128
|
-
render_metadata(pkg_type)
|
59
|
+
# The following DSL methods are available from within the project
|
60
|
+
# definitions.
|
61
|
+
# --------------------------------------------------
|
129
62
|
|
130
|
-
if Ohai.platform == 'windows'
|
131
|
-
cp_cmd = "xcopy #{config.package_dir}\\*.msi pkg\\ /Y"
|
132
|
-
elsif Ohai.platform == 'aix'
|
133
|
-
cp_cmd = "cp #{config.package_dir}/*.bff pkg/"
|
134
|
-
else
|
135
|
-
cp_cmd = "cp #{config.package_dir}/* pkg/"
|
136
|
-
end
|
137
|
-
|
138
|
-
shellout!(cp_cmd)
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
# Ensures that certain project information has been set
|
143
63
|
#
|
144
|
-
#
|
145
|
-
# in the next major release
|
64
|
+
# **[Required]** Set or retrieve the name of the project.
|
146
65
|
#
|
147
|
-
# @
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
# @!group DSL methods
|
156
|
-
# Here is some broad documentation for the DSL methods as a whole.
|
157
|
-
|
158
|
-
# Set or retrieve the name of the project
|
66
|
+
# @example
|
67
|
+
# name 'chef'
|
68
|
+
#
|
69
|
+
# @raise [MissingProjectConfiguration] if a value was not set before being
|
70
|
+
# subsequently retrieved
|
71
|
+
#
|
72
|
+
# @param [String] val
|
73
|
+
# the name to set
|
159
74
|
#
|
160
|
-
# @param val [String] the name to set
|
161
75
|
# @return [String]
|
162
76
|
#
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
77
|
+
def name(val = NULL)
|
78
|
+
if null?(val)
|
79
|
+
@name || raise(MissingProjectConfiguration.new('name', 'my_project'))
|
80
|
+
else
|
81
|
+
@name = val
|
82
|
+
end
|
169
83
|
end
|
84
|
+
expose :name
|
170
85
|
|
171
|
-
# Set or retrieve a friendly name for the project
|
172
86
|
#
|
173
|
-
#
|
87
|
+
# Set or retrieve a friendly name for the project. This defaults to the
|
88
|
+
# capitalized name if not specified.
|
89
|
+
#
|
90
|
+
# @example
|
91
|
+
# friendly_name 'Chef'
|
92
|
+
#
|
93
|
+
# @param [String] val
|
94
|
+
# the name to set
|
95
|
+
#
|
174
96
|
# @return [String]
|
175
97
|
#
|
176
|
-
def friendly_name(val =
|
177
|
-
|
178
|
-
|
98
|
+
def friendly_name(val = NULL)
|
99
|
+
if null?(val)
|
100
|
+
@friendly_name || name.capitalize
|
101
|
+
else
|
102
|
+
@friendly_name = val
|
103
|
+
end
|
179
104
|
end
|
105
|
+
expose :friendly_name
|
180
106
|
|
107
|
+
#
|
181
108
|
# Set or retrieve the custom msi building parameters
|
182
109
|
#
|
183
|
-
# @
|
184
|
-
#
|
110
|
+
# @example Using a hash
|
111
|
+
# msi_parameters upgrade_code: 'ABCD-1234'
|
112
|
+
#
|
113
|
+
# @example Using a block
|
114
|
+
# msi_parameters do
|
115
|
+
# # some complex operation
|
116
|
+
# { key: value }
|
117
|
+
# end
|
118
|
+
#
|
119
|
+
# @param [Hash] val
|
120
|
+
# the parameters to set
|
121
|
+
# @param [Proc] block
|
122
|
+
# block to run when building the msi that returns a hash
|
123
|
+
#
|
185
124
|
# @return [Hash]
|
186
125
|
#
|
187
|
-
def msi_parameters(val =
|
188
|
-
if
|
189
|
-
|
190
|
-
|
191
|
-
|
126
|
+
def msi_parameters(val = NULL, &block)
|
127
|
+
if block && !null?(val)
|
128
|
+
raise Error, 'You cannot specify additional parameters to ' \
|
129
|
+
'#msi_parameters when a block is given!'
|
130
|
+
end
|
192
131
|
|
132
|
+
if block
|
193
133
|
@msi_parameters = block
|
194
134
|
else
|
195
|
-
if
|
196
|
-
@msi_parameters
|
197
|
-
else
|
198
|
-
# Return the value of msi_parameters
|
199
|
-
if @msi_parameters.is_a? Proc
|
135
|
+
if null?(val)
|
136
|
+
if @msi_parameters.is_a?(Proc)
|
200
137
|
@msi_parameters.call
|
201
138
|
else
|
202
|
-
@msi_parameters
|
139
|
+
@msi_parameters ||= {}
|
203
140
|
end
|
141
|
+
else
|
142
|
+
@msi_parameters = val
|
204
143
|
end
|
205
144
|
end
|
206
145
|
end
|
146
|
+
expose :msi_parameters
|
207
147
|
|
208
|
-
# Set or retrieve the package name of the project. Unless
|
209
|
-
# explicitly set, the package name defaults to the project name
|
210
148
|
#
|
211
|
-
#
|
149
|
+
# Set or retrieve the package name of the project. Defaults to the package
|
150
|
+
# name defaults to the project name.
|
151
|
+
#
|
152
|
+
# @example
|
153
|
+
# package_name 'com.chef.project'
|
154
|
+
#
|
155
|
+
# @param [String] val
|
156
|
+
# the package name to set
|
157
|
+
#
|
212
158
|
# @return [String]
|
213
|
-
|
214
|
-
|
215
|
-
|
159
|
+
#
|
160
|
+
def package_name(val = NULL)
|
161
|
+
if null?(val)
|
162
|
+
@package_name || name
|
163
|
+
else
|
164
|
+
@package_name = val
|
165
|
+
end
|
216
166
|
end
|
167
|
+
expose :package_name
|
217
168
|
|
218
|
-
#
|
169
|
+
#
|
170
|
+
# **[Required]** Set or retrieve the path at which the project should be
|
219
171
|
# installed by the generated package.
|
220
172
|
#
|
221
|
-
# @
|
173
|
+
# @example
|
174
|
+
# install_dir '/opt/chef'
|
175
|
+
#
|
176
|
+
# @raise [MissingProjectConfiguration] if a value was not set before being
|
177
|
+
# subsequently retrieved
|
178
|
+
#
|
179
|
+
# @param [String] val
|
180
|
+
# the install path to set
|
181
|
+
#
|
222
182
|
# @return [String]
|
223
183
|
#
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
184
|
+
def install_dir(val = NULL)
|
185
|
+
if null?(val)
|
186
|
+
@install_dir || raise(MissingProjectConfiguration.new('install_dir', '/opt/chef'))
|
187
|
+
else
|
188
|
+
@install_dir = windows_safe_path(val)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
expose :install_dir
|
192
|
+
|
193
|
+
#
|
194
|
+
# @deprecated Use {#install_dir} instead.
|
195
|
+
#
|
196
|
+
# @example (see #install_dir)
|
197
|
+
# @raise (see #install_dir)
|
198
|
+
# @param (see #install_dir)
|
199
|
+
# @return (see #install_dir)
|
200
|
+
#
|
201
|
+
def install_path(val = NULL)
|
202
|
+
log.deprecated(log_key) do
|
203
|
+
"install_path (DSL). Please use install_dir instead."
|
230
204
|
end
|
231
|
-
|
205
|
+
|
206
|
+
install_dir(val)
|
232
207
|
end
|
208
|
+
expose :install_path
|
233
209
|
|
234
|
-
# Set or retrieve the the package maintainer.
|
235
210
|
#
|
236
|
-
#
|
211
|
+
# Path to the +/files+ directory in the omnibus project. This directory can
|
212
|
+
# contain assets used for creating packages (e.g., Mac .pkg files and
|
213
|
+
# Windows MSIs can be installed by GUI which can optionally be customized
|
214
|
+
# with background images, license agreements, etc.)
|
215
|
+
#
|
216
|
+
# This method delegates to the {Config.project_root} module function so that
|
217
|
+
# Packagers classes rely only on the Project object for their inputs.
|
218
|
+
#
|
219
|
+
# @example
|
220
|
+
# patch = File.join(files_path, 'rubygems', 'patch.rb')
|
221
|
+
#
|
237
222
|
# @return [String]
|
223
|
+
# path to the files directory
|
238
224
|
#
|
239
|
-
|
240
|
-
|
241
|
-
# be set in order to build a project)
|
242
|
-
def maintainer(val = NULL_ARG)
|
243
|
-
@maintainer = val unless val.equal?(NULL_ARG)
|
244
|
-
@maintainer || raise(MissingProjectConfiguration.new('maintainer', 'Chef Software, Inc.'))
|
225
|
+
def files_path
|
226
|
+
"#{Config.project_root}/files"
|
245
227
|
end
|
228
|
+
expose :files_path
|
246
229
|
|
247
|
-
# Set or retrive the package homepage.
|
248
230
|
#
|
249
|
-
#
|
231
|
+
# **[Required]** Set or retrieve the the package maintainer.
|
232
|
+
#
|
233
|
+
# @example
|
234
|
+
# maintainer 'Chef Software, Inc.'
|
235
|
+
#
|
236
|
+
# @raise [MissingProjectConfiguration] if a value was not set before being
|
237
|
+
# subsequently retrieved
|
238
|
+
#
|
239
|
+
# @param [String] val
|
240
|
+
# the name of the maintainer
|
241
|
+
#
|
250
242
|
# @return [String]
|
251
243
|
#
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
244
|
+
def maintainer(val = NULL)
|
245
|
+
if null?(val)
|
246
|
+
@maintainer || raise(MissingProjectConfiguration.new('maintainer', 'Chef Software, Inc.'))
|
247
|
+
else
|
248
|
+
@maintainer = val
|
249
|
+
end
|
258
250
|
end
|
251
|
+
expose :maintainer
|
259
252
|
|
260
|
-
# Defines the iteration for the package to be generated. Adheres
|
261
|
-
# to the conventions of the platform for which the package is
|
262
|
-
# being built.
|
263
253
|
#
|
264
|
-
#
|
254
|
+
# **[Required]** Set or retrive the package homepage.
|
255
|
+
#
|
256
|
+
# @example
|
257
|
+
# homepage 'https://www.getchef.com'
|
258
|
+
#
|
259
|
+
# @raise [MissingProjectConfiguration] if a value was not set before being
|
260
|
+
# subsequently retrieved
|
261
|
+
#
|
262
|
+
# @param [String] val
|
263
|
+
# the homepage for the project
|
265
264
|
#
|
266
265
|
# @return [String]
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
maj = Regexp.last_match[1]
|
272
|
-
"#{build_iteration}.el#{maj}"
|
273
|
-
when 'freebsd'
|
274
|
-
platform_version =~ /^(\d+)/
|
275
|
-
maj = Regexp.last_match[1]
|
276
|
-
"#{build_iteration}.#{platform}.#{maj}.#{machine}"
|
277
|
-
when 'windows'
|
278
|
-
"#{build_iteration}.windows"
|
279
|
-
when 'aix', 'debian', 'mac_os_x'
|
280
|
-
"#{build_iteration}"
|
266
|
+
#
|
267
|
+
def homepage(val = NULL)
|
268
|
+
if null?(val)
|
269
|
+
@homepage || raise(MissingProjectConfiguration.new('homepage', 'http://www.getchef.com'))
|
281
270
|
else
|
282
|
-
|
271
|
+
@homepage = val
|
283
272
|
end
|
284
273
|
end
|
274
|
+
expose :homepage
|
285
275
|
|
286
|
-
# Set or retrieve the project description. Defaults to `"The full
|
287
|
-
# stack of #{name}"`
|
288
276
|
#
|
289
|
-
#
|
277
|
+
# Set or retrieve the project description.
|
278
|
+
#
|
279
|
+
# @example
|
280
|
+
# description 'This is my description'
|
281
|
+
#
|
282
|
+
# Corresponds to the +--description+ flag of
|
290
283
|
# {https://github.com/jordansissel/fpm fpm}.
|
291
284
|
#
|
292
|
-
# @param
|
285
|
+
# @param [String] val
|
286
|
+
# the project description
|
287
|
+
#
|
293
288
|
# @return [String]
|
294
289
|
#
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
290
|
+
def description(val = NULL)
|
291
|
+
if null?(val)
|
292
|
+
@description ||= "The full stack of #{name}"
|
293
|
+
else
|
294
|
+
@description = val
|
295
|
+
end
|
299
296
|
end
|
297
|
+
expose :description
|
300
298
|
|
299
|
+
#
|
301
300
|
# Set or retrieve the name of the package this package will replace.
|
302
301
|
#
|
303
|
-
# Ultimately used as the value for the
|
302
|
+
# Ultimately used as the value for the +--replaces+ flag in
|
304
303
|
# {https://github.com/jordansissel/fpm fpm}.
|
305
304
|
#
|
306
305
|
# This should only be used when renaming a package and obsoleting the old
|
307
|
-
# name of the package.
|
306
|
+
# name of the package. Setting this to the same name as package_name will
|
308
307
|
# cause RPM upgrades to fail.
|
309
308
|
#
|
310
|
-
# @
|
309
|
+
# @example
|
310
|
+
# replace 'the-old-package'
|
311
|
+
#
|
312
|
+
# @param [String] val
|
313
|
+
# the name of the package to replace
|
314
|
+
#
|
311
315
|
# @return [String]
|
312
|
-
|
313
|
-
|
314
|
-
|
316
|
+
#
|
317
|
+
def replaces(val = NULL)
|
318
|
+
if null?(val)
|
319
|
+
@replaces
|
320
|
+
else
|
321
|
+
@replaces = val
|
322
|
+
end
|
315
323
|
end
|
324
|
+
expose :replaces
|
316
325
|
|
326
|
+
#
|
317
327
|
# Add to the list of packages this one conflicts with.
|
318
328
|
#
|
319
|
-
# Specifying conflicts is optional. See the
|
329
|
+
# Specifying conflicts is optional. See the +--conflicts+ flag in
|
320
330
|
# {https://github.com/jordansissel/fpm fpm}.
|
321
331
|
#
|
322
|
-
# @
|
323
|
-
#
|
332
|
+
# @example
|
333
|
+
# conflicts 'foo'
|
334
|
+
# conflicts 'bar'
|
335
|
+
#
|
336
|
+
# @param [String] val
|
337
|
+
# the conflict to add
|
338
|
+
#
|
339
|
+
# @return [Array<String>]
|
340
|
+
# the list of conflicts
|
341
|
+
#
|
324
342
|
def conflict(val)
|
325
|
-
|
343
|
+
conflicts << val
|
344
|
+
conflicts.dup
|
326
345
|
end
|
346
|
+
expose :conflict
|
327
347
|
|
348
|
+
#
|
328
349
|
# Set or retrieve the version of the project.
|
329
350
|
#
|
330
|
-
#
|
351
|
+
# @example Using a string
|
352
|
+
# build_version '1.0.0'
|
331
353
|
#
|
332
|
-
#
|
333
|
-
# build_version
|
334
|
-
# 2. Get the build_version from git of the omnibus repo
|
335
|
-
# build version do
|
354
|
+
# @example From git
|
355
|
+
# build_version do
|
336
356
|
# source :git
|
337
357
|
# end
|
338
|
-
#
|
339
|
-
#
|
340
|
-
#
|
358
|
+
#
|
359
|
+
# @example From the version of a dependency
|
360
|
+
# build_version do
|
361
|
+
# source :version, from_dependency: 'chef'
|
341
362
|
# end
|
342
|
-
#
|
343
|
-
#
|
344
|
-
#
|
363
|
+
#
|
364
|
+
# @example From git of a dependency
|
365
|
+
# build_version do
|
366
|
+
# source :git, from_dependency: 'chef'
|
345
367
|
# end
|
346
368
|
#
|
347
|
-
# When using
|
348
|
-
# is semver. This can be modified using the
|
349
|
-
# of the methods of
|
369
|
+
# When using the +:git+ source, by default the output format of the
|
370
|
+
# +build_version+ is semver. This can be modified using the +:output_format+
|
371
|
+
# parameter to any of the methods of +BuildVersion+. For example:
|
372
|
+
#
|
350
373
|
# build version do
|
351
|
-
# source :git, from_dependency:
|
374
|
+
# source :git, from_dependency: 'chef'
|
352
375
|
# output_format :git_describe
|
353
376
|
# end
|
354
377
|
#
|
355
|
-
# @param val [String] the version to set
|
356
|
-
# @param block [Proc] block to run when constructing the build_version
|
357
|
-
# @return [String]
|
358
|
-
#
|
359
378
|
# @see Omnibus::BuildVersion
|
360
379
|
# @see Omnibus::BuildVersionDSL
|
361
|
-
|
362
|
-
|
363
|
-
|
380
|
+
#
|
381
|
+
# @param [String] val
|
382
|
+
# the build version to set
|
383
|
+
# @param [Proc] block
|
384
|
+
# the block to run when constructing the +build_version+
|
385
|
+
#
|
386
|
+
# @return [String]
|
387
|
+
#
|
388
|
+
def build_version(val = NULL, &block)
|
389
|
+
if block && !null?(val)
|
390
|
+
raise Error, 'You cannot specify additional parameters to ' \
|
391
|
+
'#build_version when a block is given!'
|
392
|
+
end
|
393
|
+
|
394
|
+
if block
|
395
|
+
@build_version_dsl = BuildVersionDSL.new(&block)
|
364
396
|
else
|
365
|
-
if
|
366
|
-
@build_version_dsl = BuildVersionDSL.new(val)
|
367
|
-
else
|
397
|
+
if null?(val)
|
368
398
|
@build_version_dsl.build_version
|
399
|
+
else
|
400
|
+
@build_version_dsl = BuildVersionDSL.new(val)
|
369
401
|
end
|
370
402
|
end
|
371
403
|
end
|
404
|
+
expose :build_version
|
372
405
|
|
373
|
-
# Set or retrieve the build iteration of the project. Defaults to
|
374
|
-
# `1` if not otherwise set.
|
375
406
|
#
|
376
|
-
#
|
407
|
+
# Set or retrieve the build iteration of the project. Defaults to +1+ if not
|
408
|
+
# otherwise set.
|
409
|
+
#
|
410
|
+
# @example
|
411
|
+
# build_iteration 5
|
412
|
+
#
|
413
|
+
# @param [Fixnum] val
|
414
|
+
# the build iteration number
|
415
|
+
#
|
377
416
|
# @return [Fixnum]
|
378
417
|
#
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
def mac_pkg_identifier(val = NULL_ARG)
|
387
|
-
@mac_pkg_identifier = val unless val.equal?(NULL_ARG)
|
388
|
-
@mac_pkg_identifier
|
418
|
+
def build_iteration(val = NULL)
|
419
|
+
if null?(val)
|
420
|
+
@build_iteration ||= 1
|
421
|
+
else
|
422
|
+
@build_iteration = val
|
423
|
+
end
|
389
424
|
end
|
425
|
+
expose :build_iteration
|
390
426
|
|
391
|
-
# Set or retrieve the {deb/rpm/solaris}-user fpm argument.
|
392
427
|
#
|
393
|
-
#
|
394
|
-
# @return [String]
|
395
|
-
def package_user(val = NULL_ARG)
|
396
|
-
@pkg_user = val unless val.equal?(NULL_ARG)
|
397
|
-
@pkg_user
|
398
|
-
end
|
399
|
-
|
400
|
-
# Set or retrieve the full overrides hash for all software being overridden. Calling it as
|
401
|
-
# a setter does not merge hash entries and will obliterate any previous overrides that have been setup.
|
428
|
+
# The identifer for the mac package.
|
402
429
|
#
|
403
|
-
# @
|
404
|
-
#
|
405
|
-
def overrides(val = NULL_ARG)
|
406
|
-
@overrides = val unless val.equal?(NULL_ARG)
|
407
|
-
@overrides
|
408
|
-
end
|
409
|
-
|
410
|
-
# Set or retrieve the overrides hash for one piece of software being overridden. Calling it as a
|
411
|
-
# setter does not merge hash entries and it will set all the overrides for a given software definition.
|
430
|
+
# @example
|
431
|
+
# mac_pkg_identifier 'com.getchef.chefdk'
|
412
432
|
#
|
413
|
-
# @param
|
414
|
-
#
|
415
|
-
def override(name, val = NULL_ARG)
|
416
|
-
@overrides[name] = val unless val.equal?(NULL_ARG)
|
417
|
-
@overrides[name]
|
418
|
-
end
|
419
|
-
|
420
|
-
# Set or retrieve the {deb/rpm/solaris}-group fpm argument.
|
433
|
+
# @param [String] val
|
434
|
+
# the package identifier
|
421
435
|
#
|
422
|
-
# @param val [String]
|
423
436
|
# @return [String]
|
424
|
-
def package_group(val = NULL_ARG)
|
425
|
-
@pkg_group = val unless val.equal?(NULL_ARG)
|
426
|
-
@pkg_group
|
427
|
-
end
|
428
|
-
|
429
|
-
# Set or retrieve the resources path to be used by packagers.
|
430
437
|
#
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
438
|
+
def mac_pkg_identifier(val = NULL)
|
439
|
+
if null?(val)
|
440
|
+
@mac_pkg_identifier
|
441
|
+
else
|
442
|
+
@mac_pkg_identifier = val
|
443
|
+
end
|
436
444
|
end
|
445
|
+
expose :mac_pkg_identifier
|
437
446
|
|
438
|
-
# Add an Omnibus software dependency.
|
439
447
|
#
|
440
|
-
#
|
441
|
-
# specify an external dependency that is required at runtime, see
|
442
|
-
# {#runtime_dependency} instead.
|
448
|
+
# Set or retrieve the +{deb/rpm/solaris}-user+ fpm argument.
|
443
449
|
#
|
444
|
-
# @
|
445
|
-
#
|
446
|
-
def dependency(val)
|
447
|
-
@dependencies << val
|
448
|
-
end
|
449
|
-
|
450
|
-
# Add a package that is a runtime dependency of this
|
451
|
-
# project.
|
450
|
+
# @example
|
451
|
+
# package_user 'build'
|
452
452
|
#
|
453
|
-
#
|
454
|
-
#
|
453
|
+
# @param [String] val
|
454
|
+
# the user to retrive for the fpm build
|
455
455
|
#
|
456
|
-
#
|
457
|
-
# {https://github.com/jordansissel/fpm fpm}.
|
456
|
+
# @return [String]
|
458
457
|
#
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
458
|
+
def package_user(val = NULL)
|
459
|
+
if null?(val)
|
460
|
+
@package_user
|
461
|
+
else
|
462
|
+
@package_user = val
|
463
|
+
end
|
463
464
|
end
|
465
|
+
expose :package_user
|
464
466
|
|
465
|
-
# Set or retrieve the list of software dependencies for this
|
466
|
-
# project. As this is a DSL method, only pass the names of
|
467
|
-
# software components, not {Omnibus::Software} objects.
|
468
467
|
#
|
469
|
-
#
|
470
|
-
#
|
468
|
+
# Set or retrieve the overrides hash for one piece of software being
|
469
|
+
# overridden. Calling it as a setter does not merge hash entries and it will
|
470
|
+
# set all the overrides for a given software definition.
|
471
471
|
#
|
472
|
-
# @
|
473
|
-
#
|
474
|
-
# {#dependency}.
|
475
|
-
#
|
476
|
-
# @param val [Array<String>] a list of names of Software components
|
477
|
-
# @return [Array<String>]
|
478
|
-
def dependencies(val = NULL_ARG)
|
479
|
-
@dependencies = val unless val.equal?(NULL_ARG)
|
480
|
-
@dependencies
|
481
|
-
end
|
482
|
-
|
483
|
-
# Add a new exclusion pattern.
|
472
|
+
# @example
|
473
|
+
# override 'chef', version: '1.2.3'
|
484
474
|
#
|
485
|
-
#
|
475
|
+
# @param [Hash] val
|
476
|
+
# the value to override
|
486
477
|
#
|
487
|
-
# @
|
488
|
-
# @return void
|
489
|
-
def exclude(pattern)
|
490
|
-
@exclusions << pattern
|
491
|
-
end
|
492
|
-
|
493
|
-
# Add a config file.
|
478
|
+
# @return [Hash]
|
494
479
|
#
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
480
|
+
def override(name, val = NULL)
|
481
|
+
if null?(val)
|
482
|
+
overrides[name]
|
483
|
+
else
|
484
|
+
overrides[name] = val
|
485
|
+
end
|
499
486
|
end
|
487
|
+
expose :override
|
500
488
|
|
501
|
-
# Add other files or dirs outside of install_path
|
502
489
|
#
|
503
|
-
#
|
504
|
-
# @return [void]
|
505
|
-
# NOTE: This option is currently only supported with FPM based package
|
506
|
-
# builds such as RPM, DEB and .sh (makeselfinst). This isn't supported
|
507
|
-
# on Mac OSX packages, Windows MSI, AIX and Solaris
|
508
|
-
def extra_package_file(val)
|
509
|
-
@extra_package_files << val
|
510
|
-
end
|
511
|
-
|
512
|
-
# Set or retrieve the array of files and directories used to
|
513
|
-
# build this project. If you use this to write, only pass the
|
514
|
-
# full path to the dir or file you want included in the omnibus
|
515
|
-
# package build.
|
490
|
+
# Set or retrieve the +{deb/rpm/solaris}+-group fpm argument.
|
516
491
|
#
|
517
|
-
# @
|
518
|
-
#
|
519
|
-
# {#file}.
|
492
|
+
# @example
|
493
|
+
# package_group 'build'
|
520
494
|
#
|
521
|
-
# @param
|
522
|
-
#
|
523
|
-
def extra_package_files(val = NULL_ARG)
|
524
|
-
@extra_package_files = val unless val.equal?(NULL_ARG)
|
525
|
-
@extra_package_files
|
526
|
-
end
|
527
|
-
|
528
|
-
# Returns the platform version of the machine on which Omnibus is
|
529
|
-
# running, as determined by Ohai.
|
495
|
+
# @param [String] val
|
496
|
+
# the group to retrive for the fpm build
|
530
497
|
#
|
531
498
|
# @return [String]
|
532
|
-
def platform_version
|
533
|
-
Ohai.platform_version
|
534
|
-
end
|
535
|
-
|
536
|
-
# Returns the platform of the machine on which Omnibus is running,
|
537
|
-
# as determined by Ohai.
|
538
499
|
#
|
539
|
-
|
540
|
-
|
541
|
-
|
500
|
+
def package_group(val = NULL)
|
501
|
+
if null?(val)
|
502
|
+
@package_group
|
503
|
+
else
|
504
|
+
@package_group = val
|
505
|
+
end
|
542
506
|
end
|
507
|
+
expose :package_group
|
543
508
|
|
544
|
-
# Returns the platform family of the machine on which Omnibus is
|
545
|
-
# running, as determined by Ohai.
|
546
509
|
#
|
547
|
-
#
|
548
|
-
def platform_family
|
549
|
-
Ohai.platform_family
|
550
|
-
end
|
551
|
-
|
552
|
-
def machine
|
553
|
-
Ohai['kernel']['machine']
|
554
|
-
end
|
555
|
-
|
556
|
-
# Convenience method for accessing the global Omnibus configuration object.
|
510
|
+
# Set or retrieve the resources path to be used by packagers.
|
557
511
|
#
|
558
|
-
# @
|
512
|
+
# @example
|
513
|
+
# resources_path '/path/to/resources'
|
559
514
|
#
|
560
|
-
# @
|
561
|
-
|
562
|
-
|
515
|
+
# @param [String] val
|
516
|
+
# the path where resources live
|
517
|
+
#
|
518
|
+
# @return [String]
|
519
|
+
#
|
520
|
+
def resources_path(val = NULL)
|
521
|
+
if null?(val)
|
522
|
+
@resources_path
|
523
|
+
else
|
524
|
+
@resources_path = val
|
525
|
+
end
|
563
526
|
end
|
527
|
+
expose :resources_path
|
564
528
|
|
529
|
+
#
|
565
530
|
# The path to the package scripts directory for this project.
|
566
531
|
# These are optional scripts that can be bundled into the
|
567
532
|
# resulting package for running at various points in the package
|
@@ -583,55 +548,563 @@ module Omnibus
|
|
583
548
|
# scripts directory will be incorporated into the package that is
|
584
549
|
# built. This only applies to fpm-built packages.
|
585
550
|
#
|
586
|
-
# Additionally, there may be a
|
551
|
+
# Additionally, there may be a +makeselfinst+ script.
|
587
552
|
#
|
588
553
|
# @return [String]
|
589
554
|
#
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
555
|
+
def package_scripts_path(arg = NULL)
|
556
|
+
if null?(arg)
|
557
|
+
@package_scripts_path || "#{Config.project_root}/package-scripts/#{name}"
|
558
|
+
else
|
559
|
+
@package_scripts_path = arg
|
560
|
+
end
|
594
561
|
end
|
562
|
+
expose :package_scripts_path
|
595
563
|
|
596
|
-
# Path to the /files directory in the omnibus project. This directory can
|
597
|
-
# contain assets used for creating packages (e.g., Mac .pkg files and
|
598
|
-
# Windows MSIs can be installed by GUI which can optionally be customized
|
599
|
-
# with background images, license agreements, etc.)
|
600
564
|
#
|
601
|
-
#
|
602
|
-
# Packagers classes rely only on the Project object for their inputs.
|
565
|
+
# Add a software dependency.
|
603
566
|
#
|
604
|
-
#
|
605
|
-
|
606
|
-
|
567
|
+
# Note that this is a *build time* dependency. If you need to specify an
|
568
|
+
# external dependency that is required at runtime, see {#runtime_dependency}
|
569
|
+
# instead.
|
570
|
+
#
|
571
|
+
# @example
|
572
|
+
# dependency 'foo'
|
573
|
+
# dependency 'bar'
|
574
|
+
#
|
575
|
+
# @param [String] val
|
576
|
+
# the name of a Software dependency
|
577
|
+
#
|
578
|
+
# @return [Array<String>]
|
579
|
+
# the list of dependencies
|
580
|
+
#
|
581
|
+
def dependency(val)
|
582
|
+
dependencies << val
|
583
|
+
dependencies.dup
|
584
|
+
end
|
585
|
+
expose :dependency
|
586
|
+
|
587
|
+
#
|
588
|
+
# Add a package that is a runtime dependency of this project.
|
589
|
+
#
|
590
|
+
# This is distinct from a build-time dependency, which should correspond to
|
591
|
+
# a software definition.
|
592
|
+
#
|
593
|
+
# Corresponds to the +--depends+ flag of
|
594
|
+
# {https://github.com/jordansissel/fpm fpm}.
|
595
|
+
#
|
596
|
+
# @example
|
597
|
+
# runtime_dependency 'foo'
|
598
|
+
#
|
599
|
+
# @param [String] val
|
600
|
+
# the name of the runtime dependency
|
601
|
+
#
|
602
|
+
# @return [Array<String>]
|
603
|
+
# the list of runtime dependencies
|
604
|
+
#
|
605
|
+
def runtime_dependency(val)
|
606
|
+
runtime_dependencies << val
|
607
|
+
runtime_dependencies.dup
|
608
|
+
end
|
609
|
+
expose :runtime_dependency
|
610
|
+
|
611
|
+
#
|
612
|
+
# Add a new exclusion pattern.
|
613
|
+
#
|
614
|
+
# Corresponds to the +--exclude+ flag of
|
615
|
+
# {https://github.com/jordansissel/fpm fpm}.
|
616
|
+
#
|
617
|
+
# @example
|
618
|
+
# exclude 'foo'
|
619
|
+
#
|
620
|
+
# @param [String] pattern
|
621
|
+
# the thing to exclude
|
622
|
+
#
|
623
|
+
# @return [Array<String>]
|
624
|
+
# the list of current exclusions
|
625
|
+
#
|
626
|
+
def exclude(pattern)
|
627
|
+
exclusions << pattern
|
628
|
+
exclusions.dup
|
629
|
+
end
|
630
|
+
expose :exclude
|
631
|
+
|
632
|
+
#
|
633
|
+
# Add a config file.
|
634
|
+
#
|
635
|
+
# @example
|
636
|
+
# config_file '/path/to/config.rb'
|
637
|
+
#
|
638
|
+
# @param [String] val
|
639
|
+
# the name of a config file of your software
|
640
|
+
#
|
641
|
+
# @return [Array<String>]
|
642
|
+
# the list of current config files
|
643
|
+
#
|
644
|
+
def config_file(val)
|
645
|
+
config_files << val
|
646
|
+
config_files.dup
|
647
|
+
end
|
648
|
+
expose :config_file
|
649
|
+
|
650
|
+
#
|
651
|
+
# Add other files or dirs outside of +install_dir+.
|
652
|
+
#
|
653
|
+
# @note This option is currently only supported with FPM based package
|
654
|
+
# builds such as RPM, DEB and .sh (makeselfinst). This is not supported
|
655
|
+
# on Mac OSX packages, Windows MSI, AIX and Solaris
|
656
|
+
#
|
657
|
+
# @example
|
658
|
+
# extra_package_file '/path/to/file'
|
659
|
+
#
|
660
|
+
# @param [String] val
|
661
|
+
# the name of a dir or file to include in build
|
662
|
+
#
|
663
|
+
# @return [Array<String>]
|
664
|
+
# the list of current extra package files
|
665
|
+
#
|
666
|
+
def extra_package_file(val)
|
667
|
+
extra_package_files << val
|
668
|
+
extra_package_files.dup
|
669
|
+
end
|
670
|
+
expose :extra_package_file
|
671
|
+
|
672
|
+
#
|
673
|
+
# The platform version of the machine on which Omnibus is running, as
|
674
|
+
# determined by Ohai.
|
675
|
+
#
|
676
|
+
# @deprecated Use +Ohai['platform_version']+ instead.
|
677
|
+
#
|
678
|
+
# @return [String]
|
679
|
+
#
|
680
|
+
def platform_version
|
681
|
+
log.deprecated(log_key) do
|
682
|
+
"platform_version (DSL). Please use Ohai['platform_version'] instead."
|
683
|
+
end
|
684
|
+
|
685
|
+
Ohai['platform_version']
|
686
|
+
end
|
687
|
+
expose :platform_version
|
688
|
+
|
689
|
+
#
|
690
|
+
# The platform of the machine on which Omnibus is running, as determined
|
691
|
+
# by Ohai.
|
692
|
+
#
|
693
|
+
# @deprecated Use +Ohai['platform']+ instead.
|
694
|
+
#
|
695
|
+
# @return [String]
|
696
|
+
#
|
697
|
+
def platform
|
698
|
+
log.deprecated(log_key) do
|
699
|
+
"platform (DSL). Please use Ohai['platform'] instead."
|
700
|
+
end
|
701
|
+
|
702
|
+
Ohai['platform']
|
703
|
+
end
|
704
|
+
expose :platform
|
705
|
+
|
706
|
+
#
|
707
|
+
# The platform family of the machine on which Omnibus is running, as
|
708
|
+
# determined by Ohai.
|
709
|
+
#
|
710
|
+
# @deprecated Use +Ohai['platform_family']+ instead.
|
711
|
+
#
|
712
|
+
# @return [String]
|
713
|
+
#
|
714
|
+
def platform_family
|
715
|
+
log.deprecated(log_key) do
|
716
|
+
"platform_family (DSL). Please use Ohai['platform_family'] instead."
|
717
|
+
end
|
718
|
+
|
719
|
+
Ohai['platform_family']
|
720
|
+
end
|
721
|
+
expose :platform_family
|
722
|
+
|
723
|
+
#
|
724
|
+
# The machine which this project is running on.
|
725
|
+
#
|
726
|
+
# @deprecated Use +Ohai['kernel']['machine']+ instead.
|
727
|
+
#
|
728
|
+
# @return [String]
|
729
|
+
#
|
730
|
+
def machine
|
731
|
+
log.deprecated(log_key) do
|
732
|
+
"machine (DSL). Please use Ohai['kernel']['machine'] instead."
|
733
|
+
end
|
734
|
+
|
735
|
+
Ohai['kernel']['machine']
|
736
|
+
end
|
737
|
+
expose :machine
|
738
|
+
|
739
|
+
#
|
740
|
+
# Convenience method for accessing the global Omnibus configuration object.
|
741
|
+
#
|
742
|
+
# @deprecated Use {Config} instead
|
743
|
+
#
|
744
|
+
# @return Config
|
745
|
+
#
|
746
|
+
# @see Config
|
747
|
+
#
|
748
|
+
def config
|
749
|
+
log.deprecated(log_key) do
|
750
|
+
'config (DSL). Please use Config.(thing) instead (capital C).'
|
751
|
+
end
|
752
|
+
|
753
|
+
Config
|
754
|
+
end
|
755
|
+
expose :config
|
756
|
+
|
757
|
+
#
|
758
|
+
# The list of software dependencies for this project. These is the software
|
759
|
+
# that comprises your project, and is distinct from runtime dependencies.
|
760
|
+
#
|
761
|
+
# @deprecated Use {#dependency} instead (as a setter; the getter will stay)
|
762
|
+
#
|
763
|
+
# @todo Remove the "setter" part of this method and unexpose it as part of
|
764
|
+
# the DSL in the next major release
|
765
|
+
#
|
766
|
+
# @see #dependency
|
767
|
+
#
|
768
|
+
# @param [Array<String>]
|
769
|
+
#
|
770
|
+
# @return [Array<String>]
|
771
|
+
#
|
772
|
+
def dependencies(*args)
|
773
|
+
@dependencies ||= []
|
774
|
+
|
775
|
+
# Handle the case where an array or list of args were given
|
776
|
+
flattened_args = Array(args).flatten
|
777
|
+
|
778
|
+
if flattened_args.empty?
|
779
|
+
@dependencies
|
780
|
+
else
|
781
|
+
log.deprecated(log_key) do
|
782
|
+
"dependencies (DSL). Please specify each dependency on its own " \
|
783
|
+
"line like `dependency '#{Array(val).first}'`."
|
784
|
+
end
|
785
|
+
|
786
|
+
@dependencies = flattened_args
|
787
|
+
end
|
788
|
+
end
|
789
|
+
expose :dependencies
|
790
|
+
|
791
|
+
#
|
792
|
+
# @!endgroup
|
793
|
+
# --------------------------------------------------
|
794
|
+
|
795
|
+
#
|
796
|
+
# @!group Public API
|
797
|
+
#
|
798
|
+
# In addition to the DSL methods, the following methods are considered to
|
799
|
+
# be the "public API" for a project.
|
800
|
+
# --------------------------------------------------
|
801
|
+
|
802
|
+
#
|
803
|
+
# The path (on disk) where this project came from. Warning: this can be
|
804
|
+
# +nil+ if a project was dynamically created!
|
805
|
+
#
|
806
|
+
# @return [String, nil]
|
807
|
+
#
|
808
|
+
def filepath
|
809
|
+
@filepath
|
810
|
+
end
|
811
|
+
|
812
|
+
#
|
813
|
+
#
|
814
|
+
# The list of config files for this software.
|
815
|
+
#
|
816
|
+
# @return [Array<String>]
|
817
|
+
#
|
818
|
+
def config_files
|
819
|
+
@config_files ||= []
|
820
|
+
end
|
821
|
+
|
822
|
+
#
|
823
|
+
# The list of files and directories used to build this project.
|
824
|
+
#
|
825
|
+
# @return [Array<String>]
|
826
|
+
#
|
827
|
+
def extra_package_files(val = NULL)
|
828
|
+
@extra_package_files ||= []
|
829
|
+
end
|
830
|
+
|
831
|
+
#
|
832
|
+
# The list of software dependencies for this project.
|
833
|
+
#
|
834
|
+
# These is the software that is used at runtime for your project.
|
835
|
+
#
|
836
|
+
# @return [Array<String>]
|
837
|
+
#
|
838
|
+
def runtime_dependencies
|
839
|
+
runtime_dependencies ||= []
|
840
|
+
end
|
841
|
+
|
842
|
+
#
|
843
|
+
# The list of things this project conflicts with.
|
844
|
+
#
|
845
|
+
# @return [Array<String>]
|
846
|
+
#
|
847
|
+
def conflicts
|
848
|
+
@conflicts ||= []
|
849
|
+
end
|
850
|
+
|
851
|
+
#
|
852
|
+
# The list of exclusions for this project.
|
853
|
+
#
|
854
|
+
# @return [Array<String>]
|
855
|
+
#
|
856
|
+
def exclusions
|
857
|
+
@exclusions ||= []
|
858
|
+
end
|
859
|
+
|
860
|
+
#
|
861
|
+
# Retrieve the list of overrides for all software being overridden.
|
862
|
+
#
|
863
|
+
# @return [Hash]
|
864
|
+
#
|
865
|
+
def overrides
|
866
|
+
@overrides ||= {}
|
867
|
+
end
|
868
|
+
|
869
|
+
#
|
870
|
+
# The DSL for this build version.
|
871
|
+
#
|
872
|
+
# @return [BuildVersionDSL]
|
873
|
+
#
|
874
|
+
def build_version_dsl
|
875
|
+
@build_version_dsl
|
876
|
+
end
|
877
|
+
|
878
|
+
#
|
879
|
+
# Indicates whether the given +software+ is defined as a software component
|
880
|
+
# of this project.
|
881
|
+
#
|
882
|
+
# @param [String, Software] software
|
883
|
+
# the software or name of the software to find
|
884
|
+
#
|
885
|
+
# @return [true, false]
|
886
|
+
#
|
887
|
+
def dependency?(software)
|
888
|
+
name = software.is_a?(Software) ? software.name : software
|
889
|
+
dependencies.include?(name)
|
890
|
+
end
|
891
|
+
|
892
|
+
#
|
893
|
+
# The library for this Omnibus project.
|
894
|
+
#
|
895
|
+
# @return [Library]
|
896
|
+
#
|
897
|
+
def library
|
898
|
+
@library ||= Library.new(self)
|
899
|
+
end
|
900
|
+
|
901
|
+
#
|
902
|
+
# Dirty the cache for this project. This can be called by other projects,
|
903
|
+
# install path cache, or software definitions to invalidate the cache for
|
904
|
+
# this project.
|
905
|
+
#
|
906
|
+
# @return [true, false]
|
907
|
+
#
|
908
|
+
def dirty!
|
909
|
+
@dirty = true
|
910
|
+
end
|
911
|
+
|
912
|
+
#
|
913
|
+
# Determine if the cache for this project is dirty.
|
914
|
+
#
|
915
|
+
# @return [true, false]
|
916
|
+
#
|
917
|
+
def dirty?
|
918
|
+
!!@dirty
|
919
|
+
end
|
920
|
+
|
921
|
+
#
|
922
|
+
# Comparator for two projects (+name+)
|
923
|
+
#
|
924
|
+
# @return [1, 0, -1]
|
925
|
+
#
|
926
|
+
def <=>(other)
|
927
|
+
self.name <=> other.name
|
928
|
+
end
|
929
|
+
|
930
|
+
# Defines the iteration for the package to be generated. Adheres
|
931
|
+
# to the conventions of the platform for which the package is
|
932
|
+
# being built.
|
933
|
+
#
|
934
|
+
# All iteration strings begin with the value set in {#build_iteration}
|
935
|
+
#
|
936
|
+
# @return [String]
|
937
|
+
def iteration
|
938
|
+
case Ohai['platform_family']
|
939
|
+
when 'rhel'
|
940
|
+
Ohai['platform_version'] =~ /^(\d+)/
|
941
|
+
maj = Regexp.last_match[1]
|
942
|
+
"#{build_iteration}.el#{maj}"
|
943
|
+
when 'freebsd'
|
944
|
+
Ohai['platform_version'] =~ /^(\d+)/
|
945
|
+
maj = Regexp.last_match[1]
|
946
|
+
"#{build_iteration}.#{Ohai['platform']}.#{maj}.#{Ohai['kernel']['machine']}"
|
947
|
+
when 'windows'
|
948
|
+
"#{build_iteration}.windows"
|
949
|
+
when 'aix', 'debian', 'mac_os_x'
|
950
|
+
"#{build_iteration}"
|
951
|
+
else
|
952
|
+
"#{build_iteration}.#{Ohai['platform']}.#{Ohai['platform_version']}"
|
953
|
+
end
|
954
|
+
end
|
955
|
+
|
956
|
+
def build_me
|
957
|
+
FileUtils.mkdir_p(Config.package_dir)
|
958
|
+
FileUtils.rm_rf(install_dir)
|
959
|
+
FileUtils.mkdir_p(install_dir)
|
960
|
+
|
961
|
+
# Cache the build order so we don't re-compute
|
962
|
+
softwares = library.build_order
|
963
|
+
|
964
|
+
# Download all softwares first
|
965
|
+
softwares.each do |software|
|
966
|
+
software.fetch
|
967
|
+
end
|
968
|
+
|
969
|
+
# Now build each software
|
970
|
+
softwares.each do |software|
|
971
|
+
software.build_me
|
972
|
+
end
|
973
|
+
|
974
|
+
# Health check
|
975
|
+
HealthCheck.run!(self)
|
976
|
+
|
977
|
+
# Package
|
978
|
+
package_me
|
979
|
+
end
|
980
|
+
|
981
|
+
def package_me
|
982
|
+
destination = File.expand_path('pkg', Config.project_root)
|
983
|
+
|
984
|
+
# Create the destination directory
|
985
|
+
unless File.directory?(destination)
|
986
|
+
FileUtils.mkdir_p(destination)
|
987
|
+
end
|
988
|
+
|
989
|
+
package_types.each do |pkg_type|
|
990
|
+
if pkg_type == 'makeself'
|
991
|
+
run_makeself
|
992
|
+
elsif pkg_type == 'msi'
|
993
|
+
run_msi
|
994
|
+
elsif pkg_type == 'bff'
|
995
|
+
run_bff
|
996
|
+
elsif pkg_type == 'pkgmk'
|
997
|
+
run_pkgmk
|
998
|
+
elsif pkg_type == 'mac_pkg'
|
999
|
+
run_mac_package_build
|
1000
|
+
elsif pkg_type == 'mac_dmg'
|
1001
|
+
# noop, since the dmg creation is handled by the packager
|
1002
|
+
else # pkg_type == "fpm"
|
1003
|
+
run_fpm(pkg_type)
|
1004
|
+
end
|
1005
|
+
|
1006
|
+
render_metadata(pkg_type)
|
1007
|
+
|
1008
|
+
if Ohai['platform'] == 'windows'
|
1009
|
+
FileUtils.cp(Dir["#{Config.package_dir}/*.msi*"], destination)
|
1010
|
+
elsif Ohai['platform'] == 'aix'
|
1011
|
+
FileUtils.cp(Dir["#{Config.package_dir}/*.bff*"], destination)
|
1012
|
+
else
|
1013
|
+
FileUtils.cp(Dir["#{Config.package_dir}/*"], destination)
|
1014
|
+
end
|
1015
|
+
end
|
1016
|
+
end
|
1017
|
+
|
1018
|
+
# Ensures that certain project information has been set
|
1019
|
+
#
|
1020
|
+
# @todo raise MissingProjectConfiguration instead of printing the warning
|
1021
|
+
# in the next major release
|
1022
|
+
#
|
1023
|
+
# @return [void]
|
1024
|
+
def validate
|
1025
|
+
name && install_dir && maintainer && homepage
|
1026
|
+
if package_name == replaces
|
1027
|
+
log.warn { BadReplacesLine.new.message }
|
1028
|
+
end
|
607
1029
|
end
|
608
1030
|
|
609
|
-
# The directory where packages are written when created. Delegates to
|
610
|
-
# #config. The delegation allows Packagers (like Packager::MacPkg) to
|
611
|
-
# define the implementation rather than using the global config everywhere.
|
612
1031
|
#
|
613
|
-
#
|
614
|
-
|
615
|
-
|
1032
|
+
# The unique "hash" for this project.
|
1033
|
+
#
|
1034
|
+
# @see (#shasum)
|
1035
|
+
#
|
1036
|
+
# @return [Fixnum]
|
1037
|
+
#
|
1038
|
+
def hash
|
1039
|
+
shasum.hash
|
616
1040
|
end
|
617
1041
|
|
618
|
-
# The directory where intermediate packaging products may be stored.
|
619
|
-
# Delegates to Config so that Packagers have a consistent API.
|
620
1042
|
#
|
621
|
-
#
|
622
|
-
#
|
623
|
-
|
624
|
-
|
1043
|
+
# Determine if two projects are identical.
|
1044
|
+
#
|
1045
|
+
# @param [Project] other
|
1046
|
+
#
|
1047
|
+
# @return [true, false]
|
1048
|
+
#
|
1049
|
+
def ==(other)
|
1050
|
+
self.hash == other.hash
|
625
1051
|
end
|
1052
|
+
alias_method :eql?, :==
|
1053
|
+
|
1054
|
+
#
|
1055
|
+
# The unique SHA256 for this project.
|
1056
|
+
#
|
1057
|
+
# A project is defined by its name, its build_version, its install_dir,
|
1058
|
+
# and any overrides (as JSON). Additionally, if provided, the actual file
|
1059
|
+
# contents are included in the SHA to ensure uniqueness.
|
1060
|
+
#
|
1061
|
+
# @return [String]
|
1062
|
+
#
|
1063
|
+
def shasum
|
1064
|
+
@shasum ||= begin
|
1065
|
+
digest = Digest::SHA256.new
|
626
1066
|
|
1067
|
+
log.info(log_key) { "Calculating shasum" }
|
1068
|
+
log.debug(log_key) { "name: #{name.inspect}" }
|
1069
|
+
log.debug(log_key) { "install_dir: #{install_dir.inspect}" }
|
1070
|
+
log.debug(log_key) { "overrides: #{overrides.inspect}" }
|
1071
|
+
|
1072
|
+
update_with_string(digest, name)
|
1073
|
+
update_with_string(digest, install_dir)
|
1074
|
+
update_with_string(digest, JSON.fast_generate(overrides))
|
1075
|
+
|
1076
|
+
if filepath && File.exist?(filepath)
|
1077
|
+
log.debug(log_key) { "filepath: #{filepath.inspect}" }
|
1078
|
+
update_with_file_contents(digest, filepath)
|
1079
|
+
else
|
1080
|
+
log.debug(log_key) { "filepath: <DYNAMIC>" }
|
1081
|
+
update_with_string(digest, '<DYNAMIC>')
|
1082
|
+
end
|
1083
|
+
|
1084
|
+
shasum = digest.hexdigest
|
1085
|
+
|
1086
|
+
log.debug(log_key) { "shasum: #{shasum.inspect}" }
|
1087
|
+
|
1088
|
+
shasum
|
1089
|
+
end
|
1090
|
+
end
|
1091
|
+
|
1092
|
+
#
|
1093
|
+
# @!endgroup
|
1094
|
+
# --------------------------------------------------
|
1095
|
+
|
1096
|
+
private
|
1097
|
+
|
1098
|
+
#
|
627
1099
|
# Determine the package type(s) to be built, based on the platform
|
628
1100
|
# family for which the package is being built.
|
629
1101
|
#
|
630
|
-
# If specific types cannot be determined, default to
|
1102
|
+
# If specific types cannot be determined, default to +["makeself"]+.
|
631
1103
|
#
|
632
1104
|
# @return [Array<(String)>]
|
1105
|
+
#
|
633
1106
|
def package_types
|
634
|
-
case platform_family
|
1107
|
+
case Ohai['platform_family']
|
635
1108
|
when 'debian'
|
636
1109
|
%w(deb)
|
637
1110
|
when 'fedora', 'rhel'
|
@@ -649,71 +1122,81 @@ module Omnibus
|
|
649
1122
|
end
|
650
1123
|
end
|
651
1124
|
|
652
|
-
# Indicates whether `software` is defined as a software component
|
653
|
-
# of this project.
|
654
|
-
#
|
655
|
-
# @param software [String, Omnibus::Software, #name]
|
656
|
-
# @return [Boolean]
|
657
1125
|
#
|
658
|
-
# @see #dependencies
|
659
|
-
def dependency?(software)
|
660
|
-
name = if software.respond_to?(:name)
|
661
|
-
software.send(:name)
|
662
|
-
else
|
663
|
-
software
|
664
|
-
end
|
665
|
-
@dependencies.include?(name)
|
666
|
-
end
|
667
|
-
|
668
|
-
# @!endgroup
|
669
|
-
|
670
|
-
private
|
671
|
-
|
672
|
-
# An Array of platform data suitable for `Artifact.new`. This will go into
|
673
|
-
# metadata generated for the artifact, and be used for the file hierarchy
|
674
|
-
# of released packages if the default release scripts are used.
|
675
|
-
# @return [Array<String>] platform_shortname, platform_version_for_package,
|
676
|
-
# machine architecture.
|
677
|
-
def platform_tuple
|
678
|
-
[platform_shortname, platform_version_for_package, machine]
|
679
|
-
end
|
680
|
-
|
681
1126
|
# Platform version to be used in package metadata. For rhel, the minor
|
682
1127
|
# version is removed, e.g., "5.6" becomes "5". For all other platforms,
|
683
1128
|
# this is just the platform_version.
|
684
|
-
#
|
1129
|
+
#
|
1130
|
+
# @return [String]
|
1131
|
+
# the platform version
|
1132
|
+
#
|
685
1133
|
def platform_version_for_package
|
686
|
-
|
687
|
-
|
1134
|
+
case Ohai['platform_family']
|
1135
|
+
when 'debian', 'fedora', 'freebsd', 'rhel'
|
1136
|
+
if Ohai['platform'] == 'ubuntu'
|
1137
|
+
# Only want MAJOR.MINOR (Ubuntu 12.04)
|
1138
|
+
Ohai['platform_version'].split('.')[0..1].join('.')
|
1139
|
+
else
|
1140
|
+
# Only want MAJOR (Debian 7)
|
1141
|
+
Ohai['platform_version'].split('.').first
|
1142
|
+
end
|
1143
|
+
when 'aix', 'arch', 'gentoo', 'mac_os_x', 'openbsd', 'slackware', 'solaris2', 'suse'
|
1144
|
+
# Only want MAJOR.MINOR
|
1145
|
+
Ohai['platform_version'].split('.')[0..1].join('.')
|
1146
|
+
when 'omnios', 'smartos'
|
1147
|
+
# Only want MAJOR
|
1148
|
+
Ohai['platform_version'].split('.').first
|
1149
|
+
when 'windows'
|
1150
|
+
# Windows has this really awesome "feature", where their version numbers
|
1151
|
+
# internally do not match the "marketing" name. Dear Microsoft, this is
|
1152
|
+
# why we cannot have nice things.
|
1153
|
+
case Ohai['platform_version']
|
1154
|
+
when '6.1.7600' then '7'
|
1155
|
+
when '6.1.7601' then '2008r2'
|
1156
|
+
when '6.2.9200' then '8'
|
1157
|
+
when '6.3.9200' then '8.1'
|
1158
|
+
else
|
1159
|
+
raise UnknownPlatformVersion.new(Ohai['platform'], Ohai['platform_version'])
|
1160
|
+
end
|
688
1161
|
else
|
689
|
-
|
1162
|
+
raise UnknownPlatformFamily.new(Ohai['platform_family'])
|
690
1163
|
end
|
691
1164
|
end
|
692
1165
|
|
1166
|
+
#
|
693
1167
|
# Platform name to be used when creating metadata for the artifact.
|
694
1168
|
# rhel/centos become "el", all others are just platform
|
695
|
-
#
|
1169
|
+
#
|
1170
|
+
# @return [String]
|
1171
|
+
# the platform family short name
|
1172
|
+
#
|
696
1173
|
def platform_shortname
|
697
|
-
if platform_family == 'rhel'
|
1174
|
+
if Ohai['platform_family'] == 'rhel'
|
698
1175
|
'el'
|
699
1176
|
else
|
700
|
-
platform
|
1177
|
+
Ohai['platform']
|
701
1178
|
end
|
702
1179
|
end
|
703
1180
|
|
704
1181
|
def render_metadata(pkg_type)
|
705
1182
|
basename = output_package(pkg_type)
|
706
|
-
pkg_path = "#{
|
1183
|
+
pkg_path = "#{Config.package_dir}/#{basename}"
|
707
1184
|
|
708
1185
|
# Don't generate metadata for packages that haven't been created.
|
709
1186
|
# TODO: Fix this and make it betterer
|
710
1187
|
return unless File.exist?(pkg_path)
|
711
1188
|
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
1189
|
+
package = Package.new(pkg_path)
|
1190
|
+
Package::Metadata.generate(package,
|
1191
|
+
name: name,
|
1192
|
+
friendly_name: friendly_name,
|
1193
|
+
homepage: homepage,
|
1194
|
+
platform: platform_shortname,
|
1195
|
+
platform_version: platform_version_for_package,
|
1196
|
+
arch: Ohai['kernel']['machine'],
|
1197
|
+
version: build_version,
|
1198
|
+
iteration: build_iteration,
|
1199
|
+
)
|
717
1200
|
end
|
718
1201
|
|
719
1202
|
# The basename of the resulting package file.
|
@@ -793,53 +1276,53 @@ module Omnibus
|
|
793
1276
|
command_and_opts << "--after-remove '#{File.join(package_scripts_path, "postrm")}'"
|
794
1277
|
end
|
795
1278
|
|
796
|
-
|
1279
|
+
exclusions.each do |pattern|
|
797
1280
|
command_and_opts << "--exclude '#{pattern}'"
|
798
1281
|
end
|
799
1282
|
|
800
|
-
|
1283
|
+
config_files.each do |config_file|
|
801
1284
|
command_and_opts << "--config-files '#{config_file}'"
|
802
1285
|
end
|
803
1286
|
|
804
|
-
|
1287
|
+
runtime_dependencies.each do |runtime_dep|
|
805
1288
|
command_and_opts << "--depends '#{runtime_dep}'"
|
806
1289
|
end
|
807
1290
|
|
808
|
-
|
1291
|
+
conflicts.each do |conflict|
|
809
1292
|
command_and_opts << "--conflicts '#{conflict}'"
|
810
1293
|
end
|
811
1294
|
|
812
|
-
if
|
1295
|
+
if package_user
|
813
1296
|
%w(deb rpm solaris).each do |type|
|
814
|
-
command_and_opts << " --#{type}-user #{
|
1297
|
+
command_and_opts << " --#{type}-user #{package_user}"
|
815
1298
|
end
|
816
1299
|
end
|
817
1300
|
|
818
|
-
if
|
1301
|
+
if package_group
|
819
1302
|
%w(deb rpm solaris).each do |type|
|
820
|
-
command_and_opts << " --#{type}-group #{
|
1303
|
+
command_and_opts << " --#{type}-group #{package_group}"
|
821
1304
|
end
|
822
1305
|
end
|
823
1306
|
|
824
|
-
command_and_opts << " --replaces #{
|
1307
|
+
command_and_opts << " --replaces #{replaces}" if replaces
|
825
1308
|
|
826
1309
|
# All project files must be appended to the command "last", but before
|
827
1310
|
# the final install path
|
828
|
-
|
1311
|
+
extra_package_files.each do |files|
|
829
1312
|
command_and_opts << files
|
830
1313
|
end
|
831
1314
|
|
832
1315
|
# Install path must be the final entry in the command
|
833
|
-
command_and_opts <<
|
1316
|
+
command_and_opts << install_dir
|
834
1317
|
command_and_opts
|
835
1318
|
end
|
836
1319
|
|
837
1320
|
# TODO: what's this do?
|
838
1321
|
def makeself_command
|
839
1322
|
command_and_opts = [
|
840
|
-
|
1323
|
+
Omnibus.source_root.join('bin', 'makeself.sh'),
|
841
1324
|
'--gzip',
|
842
|
-
|
1325
|
+
install_dir,
|
843
1326
|
output_package('makeself'),
|
844
1327
|
"'The full stack of #{@name}'",
|
845
1328
|
]
|
@@ -854,18 +1337,18 @@ module Omnibus
|
|
854
1337
|
package_commands = []
|
855
1338
|
# copy the makeself installer into package
|
856
1339
|
if File.exist?("#{package_scripts_path}/makeselfinst")
|
857
|
-
package_commands << "cp #{package_scripts_path}/makeselfinst #{
|
1340
|
+
package_commands << "cp #{package_scripts_path}/makeselfinst #{install_dir}/"
|
858
1341
|
end
|
859
1342
|
|
860
1343
|
# run the makeself program
|
861
1344
|
package_commands << makeself_command.join(' ')
|
862
1345
|
|
863
1346
|
# rm the makeself installer (for incremental builds)
|
864
|
-
package_commands << "rm -f #{
|
1347
|
+
package_commands << "rm -f #{install_dir}/makeselfinst"
|
865
1348
|
package_commands.each { |cmd| run_package_command(cmd) }
|
866
1349
|
end
|
867
1350
|
|
868
|
-
# Runs the necessary command to make an MSI. As a side-effect, sets
|
1351
|
+
# Runs the necessary command to make an MSI. As a side-effect, sets +output_package+
|
869
1352
|
# @return void
|
870
1353
|
def run_msi
|
871
1354
|
Packager::WindowsMsi.new(self).run!
|
@@ -880,15 +1363,15 @@ module Omnibus
|
|
880
1363
|
FileUtils.rm_rf '/tmp/bff'
|
881
1364
|
FileUtils.mkdir '/tmp/bff'
|
882
1365
|
|
883
|
-
system "find #{
|
1366
|
+
system "find #{install_dir} -print > /tmp/bff/file.list"
|
884
1367
|
|
885
1368
|
system "cat #{package_scripts_path}/aix/opscode.chef.client.template | sed -e 's/TBS/#{bff_version}/' > /tmp/bff/gen.preamble"
|
886
1369
|
|
887
1370
|
# @todo can we just use an erb template here?
|
888
1371
|
system "cat /tmp/bff/gen.preamble /tmp/bff/file.list #{package_scripts_path}/aix/opscode.chef.client.template.last > /tmp/bff/gen.template"
|
889
1372
|
|
890
|
-
FileUtils.cp "#{package_scripts_path}/aix/unpostinstall.sh", "#{
|
891
|
-
FileUtils.cp "#{package_scripts_path}/aix/postinstall.sh", "#{
|
1373
|
+
FileUtils.cp "#{package_scripts_path}/aix/unpostinstall.sh", "#{install_dir}/bin"
|
1374
|
+
FileUtils.cp "#{package_scripts_path}/aix/postinstall.sh", "#{install_dir}/bin"
|
892
1375
|
|
893
1376
|
run_package_command(bff_command)
|
894
1377
|
|
@@ -900,8 +1383,8 @@ module Omnibus
|
|
900
1383
|
end
|
901
1384
|
|
902
1385
|
def run_pkgmk
|
903
|
-
install_dirname = File.dirname(
|
904
|
-
install_basename = File.basename(
|
1386
|
+
install_dirname = File.dirname(install_dir)
|
1387
|
+
install_basename = File.basename(install_dir)
|
905
1388
|
|
906
1389
|
system 'sudo rm -rf /tmp/pkgmk'
|
907
1390
|
FileUtils.mkdir '/tmp/pkgmk'
|
@@ -959,7 +1442,7 @@ PSTAMP=#{`hostname`.chomp + Time.now.utc.iso8601}
|
|
959
1442
|
end
|
960
1443
|
|
961
1444
|
# Runs the necessary command to make a package with fpm. As a side-effect,
|
962
|
-
# sets
|
1445
|
+
# sets +output_package+
|
963
1446
|
# @return void
|
964
1447
|
def run_fpm(pkg_type)
|
965
1448
|
run_package_command(fpm_command(pkg_type).join(' '))
|
@@ -976,7 +1459,7 @@ PSTAMP=#{`hostname`.chomp + Time.now.utc.iso8601}
|
|
976
1459
|
command = cmd
|
977
1460
|
end
|
978
1461
|
|
979
|
-
shellout!(command, cwd:
|
1462
|
+
shellout!(command, cwd: Config.package_dir)
|
980
1463
|
end
|
981
1464
|
|
982
1465
|
def log_key
|