omnibus 6.1.9 → 7.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13c799a70980298bd1b9a949570129950948678e848013b5cc45e9c16163eed4
4
- data.tar.gz: f674f27153dd215d6718e988b6d4bc7b8c30e3b3b00e3b89aaffbab1c14a7bdd
3
+ metadata.gz: 426773f2a6ca96d0f7b36b5df60e01fb17b52bf747c2a19b040499e03737b20e
4
+ data.tar.gz: 8045d8e96683fafa5fcc1357d83701515ebbcd160d16743e1903c5fcb964284c
5
5
  SHA512:
6
- metadata.gz: 7bd5732c6df36ef63dff1bf783117fe40eb49934209e41fe4f5b9f03e64998a3f69e30d86183b4b70d9f9780682a8641bb1bde8c229213be53b69f30d6267259
7
- data.tar.gz: 74bbdef1a133d657e75853a0a44ee3eea4dc461bc8fda2a52c5623656e0a289f1c40ba9906da8179686e3998354a088d5e2410dfe6b2519c41f45823613317c6
6
+ metadata.gz: 427f1194c4141ff9ebd69a7bce99c2fb2f136a836e2fa3b99c842b3ae6d271698113027cf29ea25f7ac8a38a81b6448dd44a29faf2895e69f16ec537c0d789de
7
+ data.tar.gz: 7ae973fddc3895fc2bad09fa17316e5bc58aefb7cfa19efb4630fb44dd6a0d1e479715bde34b4d3195b560f704f5d1f47fe8543efe140913694e9723b20cd187
data/Gemfile CHANGED
@@ -11,7 +11,7 @@ end
11
11
  group :debug do
12
12
  gem "pry"
13
13
  gem "pry-byebug"
14
- gem "pry-stack_explorer"
14
+ gem "pry-stack_explorer", "~> 0.4.0" # 0.4 allows us to still test Ruby 2.5
15
15
  end
16
16
 
17
17
  if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.5")
data/README.md CHANGED
@@ -84,11 +84,19 @@ use_git_caching false
84
84
  # Enable S3 asset caching
85
85
  # ------------------------------
86
86
  use_s3_caching true
87
+ s3_bucket ENV['S3_BUCKET']
88
+
89
+ # There are three ways to authenticate to the S3 bucket
90
+
91
+ # 1. set `s3_access_key` and `s3_secret_key`
87
92
  s3_access_key ENV['S3_ACCESS_KEY']
88
93
  s3_secret_key ENV['S3_SECRET_KEY']
89
- # You can use the Shared Credentials files in place of the s3_access_key and s3_secret_key.
94
+
95
+ # 2. set `s3_profile` to use an AWS profile in the Shared Credentials files
90
96
  #s3_profile ENV['S3_PROFILE']
91
- s3_bucket ENV['S3_BUCKET']
97
+
98
+ # 3. set `s3_iam_role_arn` to use an AWS IAM role
99
+ #s3_iam_role_arn ENV['S3_IAM_ROLE_ARN']
92
100
  ```
93
101
 
94
102
  For more information, please see the [`Config` documentation](http://www.rubydoc.info/github/chef/omnibus/Omnibus/Config).
@@ -253,7 +261,7 @@ For all of these paths, **order matters**, so it is possible to depend on local
253
261
  $PWD/config/software/foo.rb
254
262
  /path/to/software/config/software/foo.rb
255
263
  /other/path/to/software/config/software/foo.rb
256
- /Users/sethvargo/.gems/.../my-comany-omnibus-software/config/software/foo.rb
264
+ /Users/sethvargo/.gems/.../my-company-omnibus-software/config/software/foo.rb
257
265
  /Users/sethvargo/.gems/.../omnibus-software/config/software/foo.rb
258
266
  ```
259
267
 
@@ -273,7 +281,7 @@ This will output a JSON-formatted manifest containing the resolved version of ev
273
281
 
274
282
  Sometimes a platform has libraries that need to be whitelisted so the healthcheck can pass. The whitelist found in the [healthcheck](https://github.com/chef/omnibus/blob/master/lib/omnibus/health_check.rb) code comprises the minimal required for successful builds on supported platforms.
275
283
 
276
- To add your own whitelisted library, simply add the a regex to your software definition in your omnibus project as follows:
284
+ To add your own whitelisted library, simply add a regex to your software definition in your omnibus project as follows:
277
285
 
278
286
  ```
279
287
  whitelist_file /libpcrecpp\.so\..+/
@@ -289,11 +297,11 @@ STATUS: _EXPERIMENTAL_
289
297
 
290
298
  `omnibus changelog generate` will generate a changelog for an omnibus project. This command currently assumes:
291
299
 
292
- - version-manifest.json is checked into the project root
293
- - the project is a git repository
294
- - each version is tagged with a SemVer compliant annotated tag
300
+ - A version-manifest.json file is checked into the project root
301
+ - The project is a git repository
302
+ - Each version is tagged with a SemVer compliant annotated tag
295
303
  - Any git-based sources are checked out at ../COMPONENT_NAME
296
- - Any commit message line prepended with ChangeLog-Entry: should be added to the changelog.
304
+ - Any commit message line prepended with ChangeLog-Entry: should be added to the changelog
297
305
 
298
306
  These assumptions _will_ change as we determine what works best for a number of our projects.
299
307
 
@@ -49,10 +49,10 @@ module Omnibus
49
49
  end
50
50
 
51
51
  if compressors.include?(:tgz)
52
- return TGZ
52
+ TGZ
53
53
  else
54
54
  log.info(log_key) { "No compressor defined for `#{family}'." }
55
- return Null
55
+ Null
56
56
  end
57
57
  end
58
58
  module_function :for_current_system
@@ -30,7 +30,7 @@ module Omnibus
30
30
  # @param [Project] project
31
31
  #
32
32
  def initialize(project)
33
- @project = project
33
+ @project = project
34
34
 
35
35
  # There can now be multiple packagers per platform
36
36
  # but windows is the only platform that uses multiple
@@ -285,7 +285,7 @@ module Omnibus
285
285
  #
286
286
  # @return [String, nil]
287
287
  default(:s3_access_key) do
288
- if s3_profile
288
+ if s3_profile || s3_iam_role_arn
289
289
  nil
290
290
  else
291
291
  raise MissingRequiredAttribute.new(self, :s3_access_key, "'ABCD1234'")
@@ -296,7 +296,7 @@ module Omnibus
296
296
  #
297
297
  # @return [String, nil]
298
298
  default(:s3_secret_key) do
299
- if s3_profile
299
+ if s3_profile || s3_iam_role_arn
300
300
  nil
301
301
  else
302
302
  raise MissingRequiredAttribute.new(self, :s3_secret_key, "'EFGH5678'")
@@ -308,6 +308,11 @@ module Omnibus
308
308
  # @return [String, nil]
309
309
  default(:s3_profile, nil)
310
310
 
311
+ # The AWS IAM role arn to use with S3 caching.
312
+ #
313
+ # @return [String, nil]
314
+ default(:s3_iam_role_arn, nil)
315
+
311
316
  # The region of the S3 bucket you want to cache software artifacts in.
312
317
  # Defaults to 'us-east-1'
313
318
  #
@@ -455,6 +460,11 @@ module Omnibus
455
460
  # @return [String, nil]
456
461
  default(:publish_s3_profile, nil)
457
462
 
463
+ # The AWS IAM role arn to use with S3 publisher.
464
+ #
465
+ # @return [String, nil]
466
+ default(:publish_s3_iam_role_arn, nil)
467
+
458
468
  # Directory pattern for the S3 publisher.
459
469
  # Interpolation of metadata keys is supported.
460
470
  #
@@ -47,8 +47,8 @@ $ bin/omnibus clean <%= config[:name] %> --purge
47
47
  ### Publish
48
48
 
49
49
  Omnibus has a built-in mechanism for releasing to a variety of "backends", such
50
- as Amazon S3. You must set the proper credentials in your `omnibus.rb` config
51
- file or specify them via the command line.
50
+ as Amazon S3. You must set the proper credentials in your
51
+ [`omnibus.rb`](omnibus.rb) config file or specify them via the command line.
52
52
 
53
53
  ```shell
54
54
  $ bin/omnibus publish path/to/*.deb --backend s3
@@ -82,37 +82,40 @@ version of every software definition.
82
82
 
83
83
  Kitchen-based Build Environment
84
84
  -------------------------------
85
- Every Omnibus project ships will a project-specific
86
- [Berksfile](https://docs.chef.io/berkshelf.html) that will allow you to build your omnibus projects on all of the projects listed
87
- in the `.kitchen.yml`. You can add/remove additional platforms as needed by
88
- changing the list found in the `.kitchen.yml` `platforms` YAML stanza.
85
+ Every Omnibus project ships with a project-specific
86
+ [Berksfile](https://docs.chef.io/berkshelf.html) that will allow you to build
87
+ your omnibus projects on all of the platforms listed in the
88
+ [`.kitchen.yml`](.kitchen.yml). You can add/remove additional platforms as
89
+ needed by changing the list found in the [`.kitchen.yml`](.kitchen.yml)
90
+ `platforms` YAML stanza.
89
91
 
90
92
  This build environment is designed to get you up-and-running quickly. However,
91
- there is nothing that restricts you to building on other platforms. Simply use
92
- the [omnibus cookbook](https://github.com/chef-cookbooks/omnibus) to setup
93
- your desired platform and execute the build steps listed above.
93
+ there is nothing that restricts you from building on other platforms. Simply use
94
+ the [omnibus cookbook](https://github.com/chef-cookbooks/omnibus) to setup your
95
+ desired platform and execute the build steps listed above.
94
96
 
95
97
  The default build environment requires Test Kitchen and VirtualBox for local
96
98
  development. Test Kitchen also exposes the ability to provision instances using
97
99
  various cloud providers like AWS, DigitalOcean, or OpenStack. For more
98
100
  information, please see the [Test Kitchen documentation](https://kitchen.ci/).
99
101
 
100
- Once you have tweaked your `.kitchen.yml` (or `.kitchen.local.yml`) to your
101
- liking, you can bring up an individual build environment using the `kitchen`
102
- command.
102
+ Once you have tweaked your [`.kitchen.yml`](.kitchen.yml) (or
103
+ [`.kitchen.local.yml`](.kitchen.local.yml)) to your liking, you can bring up an
104
+ individual build environment using the `kitchen` command.
105
+
103
106
 
104
107
  ```shell
105
- $ bin/kitchen converge ubuntu-1204
108
+ $ bin/kitchen converge ubuntu-1804
106
109
  ```
107
110
 
108
111
  Then login to the instance and build the project as described in the Usage
109
112
  section:
110
113
 
111
114
  ```shell
112
- $ bundle exec kitchen login ubuntu-1204
115
+ $ bin/kitchen login ubuntu-1804
116
+ [vagrant@ubuntu...] $ . load-omnibus-toolchain.sh
113
117
  [vagrant@ubuntu...] $ cd <%= config[:name] %>
114
118
  [vagrant@ubuntu...] $ bundle install
115
- [vagrant@ubuntu...] $ ...
116
119
  [vagrant@ubuntu...] $ bin/omnibus build <%= config[:name] %>
117
120
  ```
118
121
 
@@ -15,7 +15,7 @@
15
15
  #
16
16
 
17
17
  name "preparation"
18
- description "the steps required to preprare the build"
18
+ description "the steps required to prepare the build"
19
19
  default_version "1.0.0"
20
20
 
21
21
  license :project_license
@@ -31,10 +31,11 @@
31
31
  # Enable S3 asset caching
32
32
  # ------------------------------
33
33
  # use_s3_caching true
34
- # s3_access_key ENV['AWS_ACCESS_KEY_ID']
35
- # s3_secret_key ENV['AWS_SECRET_ACCESS_KEY']
36
- # s3_profile ENV['AWS_S3_PROFILE']
37
- # s3_bucket ENV['AWS_S3_BUCKET']
34
+ # s3_access_key ENV['AWS_ACCESS_KEY_ID']
35
+ # s3_secret_key ENV['AWS_SECRET_ACCESS_KEY']
36
+ # s3_profile ENV['AWS_S3_PROFILE']
37
+ # s3_iam_role_arn ENV['S3_IAM_ROLE_ARN']
38
+ # s3_bucket ENV['AWS_S3_BUCKET']
38
39
 
39
40
  # Customize compiler bits
40
41
  # ------------------------------
@@ -439,7 +439,7 @@ module Omnibus
439
439
 
440
440
  if Config.fatal_transitive_dependency_licensing_warnings && !transitive_dependency_licensing_warnings.empty?
441
441
  warnings_to_raise << transitive_dependency_licensing_warnings
442
- warnings_to_raise << "If you are encountering missing license or missing license file errors for **transitive** dependencies, you can provide overrides for the missing information at https://github.com/chef/license_scout/blob/master/lib/license_scout/overrides.rb#L93"
442
+ warnings_to_raise << "If you are encountering missing license or missing license file errors for **transitive** dependencies, you can provide overrides for the missing information at https://github.com/chef/license_scout/blob/1-stable/lib/license_scout/overrides.rb#L93. \n Promote license_scout to Rubygems with `/expeditor promote chef/license_scout:1-stable X.Y.Z` in slack."
443
443
  end
444
444
 
445
445
  warnings_to_raise.flatten!
@@ -83,7 +83,7 @@ module Omnibus
83
83
  data = File.read(path_for(package))
84
84
  hash = FFI_Yajl::Parser.parse(data, symbolize_names: true)
85
85
 
86
- # Ensure Platform version has been truncated
86
+ # Ensure Platform version has been truncated
87
87
  if hash[:platform_version] && hash[:platform]
88
88
  hash[:platform_version] = truncate_platform_version(hash[:platform_version], hash[:platform])
89
89
  end
@@ -64,6 +64,8 @@ module Omnibus
64
64
  build do
65
65
  write_scripts
66
66
 
67
+ sign_software_libs_and_bins
68
+
67
69
  build_component_pkg
68
70
 
69
71
  write_distribution_file
@@ -177,6 +179,67 @@ module Omnibus
177
179
  end
178
180
  end
179
181
 
182
+ def sign_software_libs_and_bins
183
+ if signing_identity
184
+ log.info(log_key) { "Finding libraries and binaries that require signing." }
185
+
186
+ bin_dirs = Set[]
187
+ lib_dirs = Set[]
188
+ binaries = Set[]
189
+ libraries = Set[]
190
+
191
+ # Capture lib_dirs and bin_dirs from each software
192
+ project.softwares.each do |software|
193
+ lib_dirs.merge(software.lib_dirs)
194
+ bin_dirs.merge(software.bin_dirs)
195
+ end
196
+
197
+ # Find all binaries in each bind_dir
198
+ bin_dirs.each do |dir|
199
+ binaries.merge Dir["#{dir}/*"]
200
+ end
201
+ # Filter out symlinks, non-files, and non-executables
202
+ log.debug(log_key) { " Filtering non-binary files:" }
203
+ binaries.select! { |bin| is_binary?(bin) }
204
+
205
+ # Use otool to find all libries that are used by our binaries
206
+ binaries.each do |bin|
207
+ libraries.merge find_linked_libs bin
208
+ end
209
+
210
+ # Find all libraries in each lib_dir and add any we missed with otool
211
+ lib_dirs.each do |dir|
212
+ libraries.merge Dir["#{dir}/*"]
213
+ end
214
+
215
+ # Filter Mach-O libraries and bundles
216
+ log.debug(log_key) { " Filtering non-library files:" }
217
+ libraries.select! { |lib| is_macho?(lib) }
218
+
219
+ # Use otool to find all libries that are used by our libraries
220
+ otool_libs = Set[]
221
+ libraries.each do |lib|
222
+ otool_libs.merge find_linked_libs lib
223
+ end
224
+
225
+ # Filter Mach-O libraries and bundles
226
+ otool_libs.select! { |lib| is_macho?(lib) }
227
+ libraries.merge otool_libs
228
+
229
+ log.info(log_key) { " Signing libraries:" } unless libraries.empty?
230
+ libraries.each do |library|
231
+ log.debug(log_key) { " Signing: #{library}" }
232
+ sign_library(library)
233
+ end
234
+
235
+ log.info(log_key) { " Signing binaries:" } unless binaries.empty?
236
+ binaries.each do |binary|
237
+ log.debug(log_key) { " Signing: #{binary}" }
238
+ sign_binary(binary, true)
239
+ end
240
+ end
241
+ end
242
+
180
243
  #
181
244
  # Construct the intermediate build product. It can be installed with the
182
245
  # Installer.app, but doesn't contain the data needed to customize the
@@ -185,16 +248,20 @@ module Omnibus
185
248
  # @return [void]
186
249
  #
187
250
  def build_component_pkg
188
- command = <<-EOH.gsub(/^ {8}/, "")
251
+ command = <<~EOH
189
252
  pkgbuild \\
190
253
  --identifier "#{safe_identifier}" \\
191
254
  --version "#{safe_version}" \\
192
255
  --scripts "#{scripts_dir}" \\
193
256
  --root "#{project.install_dir}" \\
194
257
  --install-location "#{project.install_dir}" \\
195
- "#{component_pkg}"
258
+ --preserve-xattr \\
196
259
  EOH
197
260
 
261
+ command << %Q{ --sign "#{signing_identity}" \\\n} if signing_identity
262
+ command << %Q{ "#{component_pkg}"}
263
+ command << %Q{\n}
264
+
198
265
  Dir.chdir(staging_dir) do
199
266
  shellout!(command)
200
267
  end
@@ -229,7 +296,7 @@ module Omnibus
229
296
  # @return [void]
230
297
  #
231
298
  def build_product_pkg
232
- command = <<-EOH.gsub(/^ {8}/, "")
299
+ command = <<~EOH
233
300
  productbuild \\
234
301
  --distribution "#{staging_dir}/Distribution" \\
235
302
  --resources "#{resources_dir}" \\
@@ -320,5 +387,57 @@ module Omnibus
320
387
  converted
321
388
  end
322
389
  end
390
+
391
+ #
392
+ # Given a file path return any linked libraries.
393
+ #
394
+ # @param [String] file_path
395
+ # The path to a file
396
+ # @return [Array<String>]
397
+ # The linked libs
398
+ #
399
+ def find_linked_libs(file_path)
400
+ # Find all libaries for each bin
401
+ command = "otool -L #{file_path}"
402
+
403
+ stdout = shellout!(command).stdout
404
+ stdout.slice!(file_path)
405
+ stdout.scan(/#{install_dir}\S*/)
406
+ end
407
+
408
+ def sign_library(lib)
409
+ sign_binary(lib)
410
+ end
411
+
412
+ def sign_binary(bin, hardened_runtime = false)
413
+ command = "codesign -s '#{signing_identity}' '#{bin}'"
414
+ command << %q{ --options=runtime} if hardened_runtime
415
+ command << %Q{ --entitlements #{resource_path("entitlements.plist")}} if File.exist?(resource_path("entitlements.plist")) && hardened_runtime
416
+ ## Force re-signing to deal with binaries that have the same sha.
417
+ command << %q{ --force}
418
+ command << %Q{\n}
419
+
420
+ shellout!(command)
421
+ end
422
+
423
+ def is_binary?(bin)
424
+ is_binary = File.file?(bin) &&
425
+ File.executable?(bin) &&
426
+ !File.symlink?(bin)
427
+ log.debug(log_key) { " removing from signing: #{bin}" } unless is_binary
428
+ is_binary
429
+ end
430
+
431
+ def is_macho?(lib)
432
+ is_macho = false
433
+ if is_binary?(lib)
434
+ command = "file #{lib}"
435
+
436
+ stdout = shellout!(command).stdout
437
+ is_macho = stdout.match?(/Mach-O.*library/) || stdout.match?(/Mach-O.*bundle/)
438
+ end
439
+ log.debug(log_key) { " removing from signing: #{lib}" } unless is_macho
440
+ is_macho
441
+ end
323
442
  end
324
443
  end
@@ -65,11 +65,13 @@ module Omnibus
65
65
  bucket_name: @options[:bucket],
66
66
  }
67
67
 
68
- if Config.publish_s3_profile
69
- config[:profile] = Config.publish_s3_profile
68
+ if Config.publish_s3_iam_role_arn
69
+ config[:publish_s3_iam_role_arn] = Config.publish_s3_iam_role_arn
70
+ elsif Config.publish_s3_profile
71
+ config[:profile] = Config.publish_s3_profile
70
72
  else
71
- config[:access_key_id] = Config.publish_s3_access_key
72
- config[:secret_access_key] = Config.publish_s3_secret_key
73
+ config[:access_key_id] = Config.publish_s3_access_key
74
+ config[:secret_access_key] = Config.publish_s3_secret_key
73
75
  end
74
76
 
75
77
  config
@@ -147,7 +147,9 @@ module Omnibus
147
147
  force_path_style: Config.s3_force_path_style,
148
148
  }
149
149
 
150
- if Config.s3_profile
150
+ if Config.s3_iam_role_arn
151
+ config[:iam_role_arn] = Config.s3_iam_role_arn
152
+ elsif Config.s3_profile
151
153
  config[:profile] = Config.s3_profile
152
154
  else
153
155
  config[:access_key_id] = Config.s3_access_key