omnibus 5.4.0 → 5.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -3
  3. data/CHANGELOG.md +21 -0
  4. data/Gemfile +8 -5
  5. data/README.md +3 -1
  6. data/Rakefile +20 -13
  7. data/appveyor.yml +4 -3
  8. data/bin/omnibus +3 -3
  9. data/features/commands/manifest.feature +19 -5
  10. data/features/step_definitions/generator_steps.rb +5 -6
  11. data/features/support/env.rb +4 -4
  12. data/lib/omnibus/build_version.rb +14 -14
  13. data/lib/omnibus/build_version_dsl.rb +3 -3
  14. data/lib/omnibus/builder.rb +50 -61
  15. data/lib/omnibus/changelog.rb +2 -2
  16. data/lib/omnibus/changelog_printer.rb +4 -4
  17. data/lib/omnibus/cleaner.rb +4 -4
  18. data/lib/omnibus/cli/base.rb +15 -15
  19. data/lib/omnibus/cli/cache.rb +13 -13
  20. data/lib/omnibus/cli/changelog.rb +8 -9
  21. data/lib/omnibus/cli/publish.rb +12 -13
  22. data/lib/omnibus/cli.rb +26 -27
  23. data/lib/omnibus/compressor.rb +6 -6
  24. data/lib/omnibus/compressors/base.rb +7 -2
  25. data/lib/omnibus/compressors/dmg.rb +12 -12
  26. data/lib/omnibus/compressors/null.rb +1 -1
  27. data/lib/omnibus/compressors/tgz.rb +8 -8
  28. data/lib/omnibus/config.rb +37 -26
  29. data/lib/omnibus/core_extensions/open_uri.rb +3 -3
  30. data/lib/omnibus/core_extensions.rb +1 -1
  31. data/lib/omnibus/digestable.rb +5 -4
  32. data/lib/omnibus/download_helpers.rb +7 -6
  33. data/lib/omnibus/exceptions.rb +29 -13
  34. data/lib/omnibus/fetcher.rb +0 -1
  35. data/lib/omnibus/fetchers/git_fetcher.rb +7 -7
  36. data/lib/omnibus/fetchers/net_fetcher.rb +19 -19
  37. data/lib/omnibus/fetchers/path_fetcher.rb +1 -1
  38. data/lib/omnibus/file_syncer.rb +3 -3
  39. data/lib/omnibus/generator.rb +60 -47
  40. data/lib/omnibus/git_cache.rb +33 -22
  41. data/lib/omnibus/git_repository.rb +5 -5
  42. data/lib/omnibus/health_check.rb +122 -119
  43. data/lib/omnibus/instrumentation.rb +1 -1
  44. data/lib/omnibus/licensing.rb +348 -60
  45. data/lib/omnibus/logger.rb +12 -9
  46. data/lib/omnibus/logging.rb +1 -1
  47. data/lib/omnibus/manifest.rb +4 -4
  48. data/lib/omnibus/manifest_diff.rb +6 -7
  49. data/lib/omnibus/manifest_entry.rb +1 -1
  50. data/lib/omnibus/metadata.rb +36 -36
  51. data/lib/omnibus/ohai.rb +6 -7
  52. data/lib/omnibus/package.rb +1 -1
  53. data/lib/omnibus/packager.rb +37 -28
  54. data/lib/omnibus/packagers/appx.rb +86 -0
  55. data/lib/omnibus/packagers/base.rb +21 -18
  56. data/lib/omnibus/packagers/bff.rb +22 -24
  57. data/lib/omnibus/packagers/deb.rb +20 -20
  58. data/lib/omnibus/packagers/ips.rb +18 -17
  59. data/lib/omnibus/packagers/makeself.rb +7 -7
  60. data/lib/omnibus/packagers/msi.rb +38 -193
  61. data/lib/omnibus/packagers/pkg.rb +16 -16
  62. data/lib/omnibus/packagers/rpm.rb +53 -54
  63. data/lib/omnibus/packagers/solaris.rb +14 -14
  64. data/lib/omnibus/packagers/windows_base.rb +192 -0
  65. data/lib/omnibus/project.rb +45 -43
  66. data/lib/omnibus/publisher.rb +3 -3
  67. data/lib/omnibus/publishers/artifactory_publisher.rb +39 -39
  68. data/lib/omnibus/publishers/s3_publisher.rb +7 -7
  69. data/lib/omnibus/reports.rb +10 -10
  70. data/lib/omnibus/s3_cache.rb +7 -7
  71. data/lib/omnibus/s3_helpers.rb +8 -7
  72. data/lib/omnibus/semantic_version.rb +1 -1
  73. data/lib/omnibus/software.rb +131 -81
  74. data/lib/omnibus/sugarable.rb +10 -10
  75. data/lib/omnibus/templating.rb +5 -5
  76. data/lib/omnibus/thread_pool.rb +1 -1
  77. data/lib/omnibus/util.rb +5 -5
  78. data/lib/omnibus/version.rb +1 -1
  79. data/lib/omnibus.rb +65 -65
  80. data/omnibus.gemspec +34 -32
  81. data/resources/appx/AppxManifest.xml.erb +18 -0
  82. data/resources/appx/assets/clear.png +0 -0
  83. data/spec/fixtures/licensing/license_scout/snoopy/ruby_bundler-bundler-audit-0.5.0-COPYING.txt +674 -0
  84. data/spec/fixtures/licensing/license_scout/snoopy/ruby_bundler-inifile-3.0.0-README.md +215 -0
  85. data/spec/fixtures/licensing/license_scout/snoopy/snoopy-dependency-licenses.json +24 -0
  86. data/spec/fixtures/licensing/license_scout/zlib/ruby_bundler-inifile-3.0.0-README.md +215 -0
  87. data/spec/fixtures/licensing/license_scout/zlib/ruby_bundler-mime-types-3.1-Licence.rdoc +25 -0
  88. data/spec/fixtures/licensing/license_scout/zlib/ruby_bundler-mini_portile2-2.1.0-LICENSE.txt +20 -0
  89. data/spec/fixtures/licensing/license_scout/zlib/zlib-dependency-licenses.json +32 -0
  90. data/spec/functional/builder_spec.rb +149 -150
  91. data/spec/functional/fetchers/git_fetcher_spec.rb +69 -71
  92. data/spec/functional/fetchers/net_fetcher_spec.rb +79 -79
  93. data/spec/functional/fetchers/path_fetcher_spec.rb +19 -20
  94. data/spec/functional/file_syncer_spec.rb +74 -74
  95. data/spec/functional/licensing_spec.rb +344 -35
  96. data/spec/functional/templating_spec.rb +17 -17
  97. data/spec/spec_helper.rb +20 -20
  98. data/spec/support/examples.rb +21 -15
  99. data/spec/support/file_helpers.rb +1 -1
  100. data/spec/support/git_helpers.rb +37 -37
  101. data/spec/support/matchers.rb +3 -3
  102. data/spec/support/ohai_helpers.rb +4 -4
  103. data/spec/support/path_helpers.rb +2 -2
  104. data/spec/support/shell_helpers.rb +2 -2
  105. data/spec/unit/build_version_dsl_spec.rb +5 -5
  106. data/spec/unit/build_version_spec.rb +63 -63
  107. data/spec/unit/builder_spec.rb +86 -70
  108. data/spec/unit/changelog_spec.rb +4 -4
  109. data/spec/unit/changelogprinter_spec.rb +130 -0
  110. data/spec/unit/cleanroom_spec.rb +11 -11
  111. data/spec/unit/compressor_spec.rb +16 -16
  112. data/spec/unit/compressors/base_spec.rb +6 -6
  113. data/spec/unit/compressors/dmg_spec.rb +76 -76
  114. data/spec/unit/compressors/null_spec.rb +4 -4
  115. data/spec/unit/compressors/tgz_spec.rb +20 -20
  116. data/spec/unit/config_spec.rb +44 -43
  117. data/spec/unit/digestable_spec.rb +13 -13
  118. data/spec/unit/fetcher_spec.rb +11 -12
  119. data/spec/unit/fetchers/git_fetcher_spec.rb +31 -31
  120. data/spec/unit/fetchers/net_fetcher_spec.rb +172 -173
  121. data/spec/unit/fetchers/path_fetcher_spec.rb +18 -18
  122. data/spec/unit/generator_spec.rb +38 -38
  123. data/spec/unit/git_cache_spec.rb +56 -54
  124. data/spec/unit/git_repository_spec.rb +2 -2
  125. data/spec/unit/health_check_spec.rb +40 -40
  126. data/spec/unit/library_spec.rb +35 -35
  127. data/spec/unit/manifest_diff_spec.rb +10 -11
  128. data/spec/unit/manifest_spec.rb +17 -17
  129. data/spec/unit/metadata_spec.rb +152 -152
  130. data/spec/unit/ohai_spec.rb +5 -5
  131. data/spec/unit/omnibus_spec.rb +31 -31
  132. data/spec/unit/package_spec.rb +20 -20
  133. data/spec/unit/packager_spec.rb +48 -42
  134. data/spec/unit/packagers/appx_spec.rb +165 -0
  135. data/spec/unit/packagers/base_spec.rb +34 -34
  136. data/spec/unit/packagers/bff_spec.rb +60 -60
  137. data/spec/unit/packagers/deb_spec.rb +71 -71
  138. data/spec/unit/packagers/ips_spec.rb +45 -45
  139. data/spec/unit/packagers/makeself_spec.rb +22 -22
  140. data/spec/unit/packagers/msi_spec.rb +141 -147
  141. data/spec/unit/packagers/pkg_spec.rb +59 -60
  142. data/spec/unit/packagers/rpm_spec.rb +125 -126
  143. data/spec/unit/packagers/solaris_spec.rb +52 -52
  144. data/spec/unit/project_spec.rb +137 -135
  145. data/spec/unit/publisher_spec.rb +70 -70
  146. data/spec/unit/publishers/artifactory_publisher_spec.rb +85 -85
  147. data/spec/unit/publishers/s3_publisher_spec.rb +36 -36
  148. data/spec/unit/s3_cacher_spec.rb +34 -34
  149. data/spec/unit/s3_helpers_spec.rb +6 -6
  150. data/spec/unit/semantic_version_spec.rb +2 -2
  151. data/spec/unit/software_spec.rb +346 -384
  152. data/spec/unit/sugarable_spec.rb +10 -10
  153. data/spec/unit/util_spec.rb +60 -60
  154. metadata +54 -6
  155. data/.rubocop.yml +0 -48
@@ -46,9 +46,9 @@ EOH
46
46
  end
47
47
 
48
48
  class MissingRequiredAttribute < Error
49
- def initialize(instance, name, sample = '<VALUE>')
49
+ def initialize(instance, name, sample = "<VALUE>")
50
50
  @instance, @name, @sample = instance, name, sample
51
- @class = instance.class.name.split('::').last
51
+ @class = instance.class.name.split("::").last
52
52
  end
53
53
 
54
54
  def to_s
@@ -105,7 +105,7 @@ EOH
105
105
  <<-EOH
106
106
  I could not find a project named `#{@name}' in any of the project locations:"
107
107
 
108
- #{@possible_paths.map { |path| " #{path}"}.join("\n")}
108
+ #{@possible_paths.map { |path| " #{path}" }.join("\n")}
109
109
  EOH
110
110
  end
111
111
  end
@@ -120,7 +120,7 @@ EOH
120
120
  <<-EOH
121
121
  I could not find a software named `#{@name}' in any of the software locations:"
122
122
 
123
- #{@possible_paths.map { |path| " #{path}"}.join("\n")}
123
+ #{@possible_paths.map { |path| " #{path}" }.join("\n")}
124
124
  EOH
125
125
  end
126
126
  end
@@ -249,14 +249,14 @@ EOH
249
249
  if cmd.environment.nil? || cmd.environment.empty?
250
250
  env = nil
251
251
  else
252
- env = cmd.environment.sort.map { |k,v| "#{k}=#{v}" }.join(' ')
252
+ env = cmd.environment.sort.map { |k, v| "#{k}=#{v}" }.join(" ")
253
253
  end
254
254
 
255
255
  command = cmd.command
256
- command_with_env = [env, command].compact.join(' ')
256
+ command_with_env = [env, command].compact.join(" ")
257
257
 
258
- stdout = cmd.stdout.empty? ? '(nothing)' : cmd.stdout.strip
259
- stderr = cmd.stderr.empty? ? '(nothing)' : cmd.stderr.strip
258
+ stdout = cmd.stdout.empty? ? "(nothing)" : cmd.stdout.strip
259
+ stderr = cmd.stderr.empty? ? "(nothing)" : cmd.stderr.strip
260
260
 
261
261
  super <<-EOH
262
262
  The following shell command exited with status #{status}:
@@ -281,13 +281,13 @@ EOH
281
281
  if cmd.environment.nil? || cmd.environment.empty?
282
282
  env = nil
283
283
  else
284
- env = cmd.environment.sort.map { |k,v| "#{k}=#{v}" }.join(' ')
284
+ env = cmd.environment.sort.map { |k, v| "#{k}=#{v}" }.join(" ")
285
285
  end
286
286
 
287
287
  command = cmd.command
288
- command_with_env = [env, command].compact.join(' ')
288
+ command_with_env = [env, command].compact.join(" ")
289
289
 
290
- timeout = cmd.timeout.to_s.reverse.gsub(/...(?=.)/,'\&,').reverse
290
+ timeout = cmd.timeout.to_s.reverse.gsub(/...(?=.)/, '\&,').reverse
291
291
 
292
292
  super <<-EOH
293
293
  The following shell command timed out at #{timeout} seconds:
@@ -330,9 +330,25 @@ EOF
330
330
  end
331
331
  end
332
332
 
333
- class FailedToTimestampMSI < Error
333
+ class FailedToSignWindowsPackage < Error
334
334
  def initialize
335
- super("Failed to add timestamp to MSI.")
335
+ super("Failed to sign Windows Package.")
336
+ end
337
+ end
338
+
339
+ class LicensingError < Error
340
+ def initialize(errors)
341
+ @errors = errors
342
+ end
343
+
344
+ def to_s
345
+ <<-EOH
346
+ Encountered error(s) with project's licensing information.
347
+ Failing the build because :fatal_licensing_warnings is set in the configuration.
348
+ Error(s):
349
+
350
+ #{@errors.join("\n ")}
351
+ EOH
336
352
  end
337
353
  end
338
354
  end
@@ -72,7 +72,6 @@ module Omnibus
72
72
  attr_reader :project_dir
73
73
  attr_reader :build_dir
74
74
 
75
-
76
75
  #
77
76
  # Create a new Fetcher object from the given software.
78
77
  #
@@ -46,9 +46,9 @@ module Omnibus
46
46
  # git checkout/clean.
47
47
  #
48
48
  def clean
49
- log.info(log_key) { 'Cleaning existing clone' }
49
+ log.info(log_key) { "Cleaning existing clone" }
50
50
  git_checkout
51
- git('clean -fdx')
51
+ git("clean -fdx")
52
52
  true
53
53
  end
54
54
 
@@ -114,7 +114,7 @@ module Omnibus
114
114
  # @return [true, false]
115
115
  #
116
116
  def dir_empty?(dir)
117
- Dir.entries(dir).reject {|d| ['.', '..'].include?(d) }.empty?
117
+ Dir.entries(dir).reject { |d| [".", ".."].include?(d) }.empty?
118
118
  end
119
119
 
120
120
  #
@@ -164,7 +164,7 @@ module Omnibus
164
164
  #
165
165
  def git_fetch
166
166
  fetch_cmd = "fetch #{source_url} #{described_version}"
167
- fetch_cmd << ' --recurse-submodules=on-demand' if clone_submodules?
167
+ fetch_cmd << " --recurse-submodules=on-demand" if clone_submodules?
168
168
  git(fetch_cmd)
169
169
  end
170
170
 
@@ -174,7 +174,7 @@ module Omnibus
174
174
  # @return [String]
175
175
  #
176
176
  def current_revision
177
- cmd = git('rev-parse HEAD')
177
+ cmd = git("rev-parse HEAD")
178
178
  cmd.stdout.strip
179
179
  rescue CommandFailed
180
180
  log.debug(log_key) { "unable to determine current revision" }
@@ -188,7 +188,7 @@ module Omnibus
188
188
  #
189
189
  def contains_revision?(rev)
190
190
  cmd = git("cat-file -t #{rev}")
191
- cmd.stdout.strip == 'commit'
191
+ cmd.stdout.strip == "commit"
192
192
  rescue CommandFailed
193
193
  log.debug(log_key) { "unable to determine presence of commit #{rev}" }
194
194
  false
@@ -230,7 +230,7 @@ module Omnibus
230
230
  # Only when the service is specifically configured with
231
231
  # uploadpack.allowReachableSHA1InWant is there any guarantee that it
232
232
  # considers "naked" wants.
233
- log.warn(log_key) { 'git fetch on a sha1 is not guaranteed to work' }
233
+ log.warn(log_key) { "git fetch on a sha1 is not guaranteed to work" }
234
234
  log.warn(log_key) { "Specify a ref name instead of #{ref} on #{source}" }
235
235
  ref
236
236
  else
@@ -14,19 +14,19 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require 'fileutils'
18
- require 'omnibus/download_helpers'
17
+ require "fileutils"
18
+ require "omnibus/download_helpers"
19
19
 
20
20
  module Omnibus
21
21
  class NetFetcher < Fetcher
22
22
  include DownloadHelpers
23
23
 
24
24
  # Use 7-zip to extract 7z/zip for Windows
25
- WIN_7Z_EXTENSIONS = %w(.7z .zip)
25
+ WIN_7Z_EXTENSIONS = %w{.7z .zip}
26
26
 
27
27
  # tar probably has compression scheme linked in, otherwise for tarballs
28
- COMPRESSED_TAR_EXTENSIONS = %w(.tar.gz .tgz tar.bz2 .tar.xz .txz .tar.lzma)
29
- TAR_EXTENSIONS = COMPRESSED_TAR_EXTENSIONS + ['.tar']
28
+ COMPRESSED_TAR_EXTENSIONS = %w{.tar.gz .tgz tar.bz2 .tar.xz .txz .tar.lzma}
29
+ TAR_EXTENSIONS = COMPRESSED_TAR_EXTENSIONS + [".tar"]
30
30
 
31
31
  ALL_EXTENSIONS = WIN_7Z_EXTENSIONS + TAR_EXTENSIONS
32
32
 
@@ -118,7 +118,7 @@ module Omnibus
118
118
  # @return [String]
119
119
  #
120
120
  def downloaded_file
121
- filename = File.basename(source[:url], '?*')
121
+ filename = File.basename(source[:url], "?*")
122
122
  File.join(Config.cache_dir, filename)
123
123
  end
124
124
 
@@ -168,7 +168,7 @@ module Omnibus
168
168
  end
169
169
 
170
170
  # Set the cookie if one was given
171
- options['Cookie'] = source[:cookie] if source[:cookie]
171
+ options["Cookie"] = source[:cookie] if source[:cookie]
172
172
 
173
173
  download_file!(download_url, downloaded_file, options)
174
174
  end
@@ -229,18 +229,18 @@ module Omnibus
229
229
  #
230
230
  def extract
231
231
  # Only used by tar
232
- compression_switch = ''
233
- compression_switch = 'z' if downloaded_file.end_with?('gz')
234
- compression_switch = '--lzma -' if downloaded_file.end_with?('lzma')
235
- compression_switch = 'j' if downloaded_file.end_with?('bz2')
236
- compression_switch = 'J' if downloaded_file.end_with?('xz')
232
+ compression_switch = ""
233
+ compression_switch = "z" if downloaded_file.end_with?("gz")
234
+ compression_switch = "--lzma -" if downloaded_file.end_with?("lzma")
235
+ compression_switch = "j" if downloaded_file.end_with?("bz2")
236
+ compression_switch = "J" if downloaded_file.end_with?("xz")
237
237
 
238
- if Ohai['platform'] == 'windows'
238
+ if Ohai["platform"] == "windows"
239
239
  if downloaded_file.end_with?(*TAR_EXTENSIONS) && source[:extract] != :seven_zip
240
240
  returns = [0]
241
241
  returns << 1 if source[:extract] == :lax_tar
242
242
 
243
- shellout!("tar.exe #{compression_switch}xf #{safe_downloaded_file} -C#{safe_project_dir}", returns: returns)
243
+ shellout!("tar #{compression_switch}xf #{safe_downloaded_file} -C#{safe_project_dir}", returns: returns)
244
244
  elsif downloaded_file.end_with?(*COMPRESSED_TAR_EXTENSIONS)
245
245
  Dir.mktmpdir do |temp_dir|
246
246
  log.debug(log_key) { "Temporarily extracting `#{safe_downloaded_file}' to `#{temp_dir}'" }
@@ -248,7 +248,7 @@ module Omnibus
248
248
  shellout!("7z.exe x #{safe_downloaded_file} -o#{windows_safe_path(temp_dir)} -r -y")
249
249
 
250
250
  fname = File.basename(downloaded_file, File.extname(downloaded_file))
251
- fname << ".tar" if downloaded_file.end_with?('tgz', 'txz')
251
+ fname << ".tar" if downloaded_file.end_with?("tgz", "txz")
252
252
  next_file = windows_safe_path(File.join(temp_dir, fname))
253
253
 
254
254
  log.debug(log_key) { "Temporarily extracting `#{next_file}' to `#{safe_project_dir}'" }
@@ -257,9 +257,9 @@ module Omnibus
257
257
  else
258
258
  shellout!("7z.exe x #{safe_downloaded_file} -o#{safe_project_dir} -r -y")
259
259
  end
260
- elsif downloaded_file.end_with?('.7z')
260
+ elsif downloaded_file.end_with?(".7z")
261
261
  shellout!("7z x #{safe_downloaded_file} -o#{safe_project_dir} -r -y")
262
- elsif downloaded_file.end_with?('.zip')
262
+ elsif downloaded_file.end_with?(".zip")
263
263
  shellout!("unzip #{safe_downloaded_file} -d #{safe_project_dir}")
264
264
  else
265
265
  shellout!("#{tar} #{compression_switch}xf #{safe_downloaded_file} -C#{safe_project_dir}")
@@ -288,7 +288,7 @@ module Omnibus
288
288
  # if the checksum does not match
289
289
  #
290
290
  def verify_checksum!
291
- log.info(log_key) { 'Verifying checksum' }
291
+ log.info(log_key) { "Verifying checksum" }
292
292
 
293
293
  expected = checksum
294
294
  actual = digest(downloaded_file, digest_type)
@@ -321,7 +321,7 @@ module Omnibus
321
321
  # @return [String]
322
322
  #
323
323
  def tar
324
- Omnibus.which('gtar') ? 'gtar' : 'tar'
324
+ Omnibus.which("gtar") ? "gtar" : "tar"
325
325
  end
326
326
  end
327
327
  end
@@ -14,7 +14,7 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require 'fileutils'
17
+ require "fileutils"
18
18
 
19
19
  module Omnibus
20
20
  class PathFetcher < Fetcher
@@ -14,14 +14,14 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require 'fileutils'
17
+ require "fileutils"
18
18
 
19
19
  module Omnibus
20
20
  module FileSyncer
21
21
  extend self
22
22
 
23
23
  # Files to be ignored during a directory globbing
24
- IGNORED_FILES = %w(. ..).freeze
24
+ IGNORED_FILES = %w{. ..}.freeze
25
25
 
26
26
  #
27
27
  # Glob across the given pattern, accounting for dotfiles, removing Ruby's
@@ -58,7 +58,7 @@ module Omnibus
58
58
  [exclude, "#{exclude}/*"]
59
59
  end.flatten
60
60
 
61
- source_files = glob(File.join(source, '**/*'))
61
+ source_files = glob(File.join(source, "**/*"))
62
62
  source_files = source_files.reject do |source_file|
63
63
  basename = relative_path_for(source_file, source)
64
64
  excludes.any? { |exclude| File.fnmatch?(exclude, basename, File::FNM_DOTMATCH) }
@@ -14,7 +14,7 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require 'thor'
17
+ require "thor"
18
18
 
19
19
  module Omnibus
20
20
  class Generator < Thor::Group
@@ -23,78 +23,83 @@ module Omnibus
23
23
  namespace :new
24
24
 
25
25
  argument :name,
26
- banner: 'NAME',
27
- desc: 'The name of the Omnibus project',
26
+ banner: "NAME",
27
+ desc: "The name of the Omnibus project",
28
28
  type: :string,
29
29
  required: true
30
30
 
31
31
  class_option :path,
32
- banner: 'PATH',
33
- aliases: '-p',
34
- desc: 'The path to create the Omnibus project',
32
+ banner: "PATH",
33
+ aliases: "-p",
34
+ desc: "The path to create the Omnibus project",
35
35
  type: :string,
36
- default: '.'
36
+ default: "."
37
+
38
+ class_option :appx_assets,
39
+ desc: "Generate Windows APPX assets",
40
+ type: :boolean,
41
+ default: false
37
42
 
38
43
  class_option :bff_assets,
39
- desc: 'Generate AIX bff assets',
44
+ desc: "Generate AIX bff assets",
40
45
  type: :boolean,
41
46
  default: false
42
47
 
43
48
  class_option :deb_assets,
44
- desc: 'Generate Debian deb assets',
49
+ desc: "Generate Debian deb assets",
45
50
  type: :boolean,
46
51
  default: false
47
52
 
48
53
  class_option :dmg_assets,
49
- desc: 'Generate Mac OS X dmg assets',
54
+ desc: "Generate Mac OS X dmg assets",
50
55
  type: :boolean,
51
56
  default: false
52
57
 
53
58
  class_option :msi_assets,
54
- desc: 'Generate Windows MSI assets',
59
+ desc: "Generate Windows MSI assets",
55
60
  type: :boolean,
56
61
  default: false
57
62
 
58
63
  class_option :pkg_assets,
59
- desc: 'Generate Mac OS X pkg assets',
64
+ desc: "Generate Mac OS X pkg assets",
60
65
  type: :boolean,
61
66
  default: false
62
67
 
63
68
  class_option :rpm_assets,
64
- desc: 'Generate RHEL/CentOS rpm assets',
69
+ desc: "Generate RHEL/CentOS rpm assets",
65
70
  type: :boolean,
66
71
  default: false
67
72
 
68
73
  class << self
69
74
  # Set the source root for Thor
70
75
  def source_root
71
- File.expand_path('../generator_files', __FILE__)
76
+ File.expand_path("../generator_files", __FILE__)
72
77
  end
73
78
  end
74
79
 
75
80
  def create_project_files
76
- template('Gemfile.erb', "#{target}/Gemfile", template_options)
77
- template('gitignore.erb', "#{target}/.gitignore", template_options)
78
- template('README.md.erb', "#{target}/README.md", template_options)
79
- template('omnibus.rb.erb', "#{target}/omnibus.rb", template_options)
81
+ template("Gemfile.erb", "#{target}/Gemfile", template_options)
82
+ template("gitignore.erb", "#{target}/.gitignore", template_options)
83
+ template("README.md.erb", "#{target}/README.md", template_options)
84
+ template("omnibus.rb.erb", "#{target}/omnibus.rb", template_options)
80
85
  end
81
86
 
82
87
  def create_project_definition
83
- template('config/projects/project.rb.erb', "#{target}/config/projects/#{name}.rb", template_options)
88
+ template("config/projects/project.rb.erb", "#{target}/config/projects/#{name}.rb", template_options)
84
89
  end
85
90
 
86
91
  def create_example_software_definitions
87
- template('config/software/zlib.rb.erb', "#{target}/config/software/#{name}-zlib.rb", template_options)
92
+ template("config/software/zlib.rb.erb", "#{target}/config/software/#{name}-zlib.rb", template_options)
88
93
  end
89
94
 
90
95
  def create_kitchen_files
91
- template('.kitchen.local.yml.erb', "#{target}/.kitchen.local.yml", template_options)
92
- template('.kitchen.yml.erb', "#{target}/.kitchen.yml", template_options)
93
- template('Berksfile.erb', "#{target}/Berksfile", template_options)
96
+ template(".kitchen.local.yml.erb", "#{target}/.kitchen.local.yml", template_options)
97
+ template(".kitchen.yml.erb", "#{target}/.kitchen.yml", template_options)
98
+ template("Berksfile.erb", "#{target}/Berksfile", template_options)
94
99
  end
95
100
 
96
101
  def create_package_scripts
97
- %w(preinst prerm postinst postrm).each do |package_script|
102
+ %w{preinst prerm postinst postrm}.each do |package_script|
98
103
  script_path = "#{target}/package-scripts/#{name}/#{package_script}"
99
104
  template("package_scripts/#{package_script}.erb", script_path, template_options)
100
105
 
@@ -103,58 +108,66 @@ module Omnibus
103
108
  end
104
109
  end
105
110
 
111
+ def create_appx_assets
112
+ return unless options[:appx_assets]
113
+
114
+ copy_file(resource_path("appx/AppxManifest.xml.erb"), "#{target}/resources/#{name}/appx/AppxManifest.xml.erb")
115
+ copy_file(resource_path("appx/assets/clear.png"), "#{target}/resources/#{name}/appx/assets/clear.png")
116
+ end
117
+
106
118
  def create_bff_assets
107
119
  return unless options[:bff_assets]
108
120
 
109
- copy_file(resource_path('bff/gen.template.erb'), "#{target}/resources/#{name}/bff/gen.template.erb")
121
+ copy_file(resource_path("bff/gen.template.erb"), "#{target}/resources/#{name}/bff/gen.template.erb")
110
122
  end
111
123
 
112
124
  def create_deb_assets
113
125
  return unless options[:deb_assets]
114
126
 
115
- copy_file(resource_path('deb/conffiles.erb'), "#{target}/resources/#{name}/deb/conffiles.erb")
116
- copy_file(resource_path('deb/control.erb'), "#{target}/resources/#{name}/deb/control.erb")
117
- copy_file(resource_path('deb/md5sums.erb'), "#{target}/resources/#{name}/deb/md5sums.erb")
127
+ copy_file(resource_path("deb/conffiles.erb"), "#{target}/resources/#{name}/deb/conffiles.erb")
128
+ copy_file(resource_path("deb/control.erb"), "#{target}/resources/#{name}/deb/control.erb")
129
+ copy_file(resource_path("deb/md5sums.erb"), "#{target}/resources/#{name}/deb/md5sums.erb")
118
130
  end
119
131
 
120
132
  def create_dmg_assets
121
133
  return unless options[:dmg_assets]
122
134
 
123
- copy_file(resource_path('dmg/background.png'), "#{target}/resources/#{name}/dmg/background.png")
124
- copy_file(resource_path('dmg/icon.png'), "#{target}/resources/#{name}/dmg/icon.png")
135
+ copy_file(resource_path("dmg/background.png"), "#{target}/resources/#{name}/dmg/background.png")
136
+ copy_file(resource_path("dmg/icon.png"), "#{target}/resources/#{name}/dmg/icon.png")
125
137
  end
126
138
 
127
139
  def create_msi_assets
128
140
  return unless options[:msi_assets]
129
141
 
130
- copy_file(resource_path('msi/localization-en-us.wxl.erb'), "#{target}/resources/#{name}/msi/localization-en-us.wxl.erb")
131
- copy_file(resource_path('msi/parameters.wxi.erb'), "#{target}/resources/#{name}/msi/parameters.wxi.erb")
132
- copy_file(resource_path('msi/source.wxs.erb'), "#{target}/resources/#{name}/msi/source.wxs.erb")
142
+ copy_file(resource_path("msi/localization-en-us.wxl.erb"), "#{target}/resources/#{name}/msi/localization-en-us.wxl.erb")
143
+ copy_file(resource_path("msi/parameters.wxi.erb"), "#{target}/resources/#{name}/msi/parameters.wxi.erb")
144
+ copy_file(resource_path("msi/source.wxs.erb"), "#{target}/resources/#{name}/msi/source.wxs.erb")
133
145
 
134
- copy_file(resource_path('msi/assets/LICENSE.rtf'), "#{target}/resources/#{name}/msi/assets/LICENSE.rtf")
135
- copy_file(resource_path('msi/assets/banner_background.bmp'), "#{target}/resources/#{name}/msi/assets/banner_background.bmp")
136
- copy_file(resource_path('msi/assets/dialog_background.bmp'), "#{target}/resources/#{name}/msi/assets/dialog_background.bmp")
137
- copy_file(resource_path('msi/assets/project.ico'), "#{target}/resources/#{name}/msi/assets/project.ico")
138
- copy_file(resource_path('msi/assets/project_16x16.ico'), "#{target}/resources/#{name}/msi/assets/project_16x16.ico")
139
- copy_file(resource_path('msi/assets/project_32x32.ico'), "#{target}/resources/#{name}/msi/assets/project_32x32.ico")
146
+ copy_file(resource_path("msi/assets/LICENSE.rtf"), "#{target}/resources/#{name}/msi/assets/LICENSE.rtf")
147
+ copy_file(resource_path("msi/assets/banner_background.bmp"), "#{target}/resources/#{name}/msi/assets/banner_background.bmp")
148
+ copy_file(resource_path("msi/assets/dialog_background.bmp"), "#{target}/resources/#{name}/msi/assets/dialog_background.bmp")
149
+ copy_file(resource_path("msi/assets/project.ico"), "#{target}/resources/#{name}/msi/assets/project.ico")
150
+ copy_file(resource_path("msi/assets/project_16x16.ico"), "#{target}/resources/#{name}/msi/assets/project_16x16.ico")
151
+ copy_file(resource_path("msi/assets/project_32x32.ico"), "#{target}/resources/#{name}/msi/assets/project_32x32.ico")
140
152
  end
141
153
 
142
154
  def create_pkg_assets
143
155
  return unless options[:pkg_assets]
144
156
 
145
- copy_file(resource_path('pkg/background.png'), "#{target}/resources/#{name}/pkg/background.png")
146
- copy_file(resource_path('pkg/license.html.erb'), "#{target}/resources/#{name}/pkg/license.html.erb")
147
- copy_file(resource_path('pkg/welcome.html.erb'), "#{target}/resources/#{name}/pkg/welcome.html.erb")
148
- copy_file(resource_path('pkg/distribution.xml.erb'), "#{target}/resources/#{name}/pkg/distribution.xml.erb")
157
+ copy_file(resource_path("pkg/background.png"), "#{target}/resources/#{name}/pkg/background.png")
158
+ copy_file(resource_path("pkg/license.html.erb"), "#{target}/resources/#{name}/pkg/license.html.erb")
159
+ copy_file(resource_path("pkg/welcome.html.erb"), "#{target}/resources/#{name}/pkg/welcome.html.erb")
160
+ copy_file(resource_path("pkg/distribution.xml.erb"), "#{target}/resources/#{name}/pkg/distribution.xml.erb")
149
161
  end
150
162
 
151
163
  def create_rpm_assets
152
164
  return unless options[:rpm_assets]
153
165
 
154
- copy_file(resource_path('rpm/rpmmacros.erb'), "#{target}/resources/#{name}/rpm/rpmmacros.erb")
155
- copy_file(resource_path('rpm/signing.erb'), "#{target}/resources/#{name}/rpm/signing.erb")
156
- copy_file(resource_path('rpm/spec.erb'), "#{target}/resources/#{name}/rpm/spec.erb")
166
+ copy_file(resource_path("rpm/rpmmacros.erb"), "#{target}/resources/#{name}/rpm/rpmmacros.erb")
167
+ copy_file(resource_path("rpm/signing.erb"), "#{target}/resources/#{name}/rpm/signing.erb")
168
+ copy_file(resource_path("rpm/spec.erb"), "#{target}/resources/#{name}/rpm/spec.erb")
157
169
  end
170
+
158
171
  private
159
172
 
160
173
  #
@@ -184,7 +197,7 @@ module Omnibus
184
197
  # @return [String]
185
198
  #
186
199
  def resource_path(*args)
187
- Omnibus.source_root.join('resources', *args).to_s
200
+ Omnibus.source_root.join("resources", *args).to_s
188
201
  end
189
202
  end
190
203
  end
@@ -14,22 +14,33 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require 'digest'
18
- require 'fileutils'
17
+ require "digest"
18
+ require "fileutils"
19
19
 
20
20
  module Omnibus
21
21
  class GitCache
22
22
  include Util
23
23
  include Logging
24
24
 
25
- REQUIRED_GIT_FILES = [
26
- 'HEAD',
27
- 'description',
28
- 'hooks',
29
- 'info',
30
- 'objects',
31
- 'refs',
32
- ].freeze
25
+ # The serial number represents compatibility of a cache entry with the
26
+ # current version of the omnibus code base. Any time a change is made to
27
+ # omnibus that makes the code incompatible with any cache entries created
28
+ # before the code change, the serial number should be incremented.
29
+ #
30
+ # For example, if a code change generates content in the `install_dir`
31
+ # before cache snapshots are taken, any snapshots created before upgrade
32
+ # will not have the generated content, so these snapshots would be
33
+ # incompatible with the current omnibus codebase. Incrementing the serial
34
+ # number ensures these old shapshots will not be used in subsequent builds.
35
+ SERIAL_NUMBER = 1
36
+
37
+ REQUIRED_GIT_FILES = %w{
38
+ HEAD
39
+ description
40
+ hooks
41
+ info
42
+ objects
43
+ refs}.freeze
33
44
 
34
45
  #
35
46
  # @return [Software]
@@ -64,7 +75,7 @@ module Omnibus
64
75
  false
65
76
  else
66
77
  create_directory(File.dirname(cache_path))
67
- git_cmd('init -q')
78
+ git_cmd("init -q")
68
79
  true
69
80
  end
70
81
  end
@@ -98,8 +109,8 @@ module Omnibus
98
109
  # This is the list of all the unqiue shasums of all the software build
99
110
  # dependencies, including the on currently being acted upon.
100
111
  shasums = [dep_list.map(&:shasum), software.shasum].flatten
101
- suffix = Digest::SHA256.hexdigest(shasums.join('|'))
102
- @tag = "#{software.name}-#{suffix}"
112
+ suffix = Digest::SHA256.hexdigest(shasums.join("|"))
113
+ @tag = "#{software.name}-#{suffix}-#{SERIAL_NUMBER}"
103
114
 
104
115
  log.internal(log_key) { "tag: #{@tag}" }
105
116
 
@@ -108,29 +119,29 @@ module Omnibus
108
119
 
109
120
  # Create an incremental install path cache for the software step
110
121
  def incremental
111
- log.internal(log_key) { 'Performing incremental cache' }
122
+ log.internal(log_key) { "Performing incremental cache" }
112
123
 
113
124
  create_cache_path
114
125
  remove_git_dirs
115
126
 
116
- git_cmd('add -A -f')
127
+ git_cmd("add -A -f")
117
128
 
118
129
  begin
119
- git_cmd(%Q(commit -q -m "Backup of #{tag}"))
130
+ git_cmd(%Q{commit -q -m "Backup of #{tag}"})
120
131
  rescue CommandFailed => e
121
- raise unless e.message.include?('nothing to commit')
132
+ raise unless e.message.include?("nothing to commit")
122
133
  end
123
134
 
124
- git_cmd(%Q(tag -f "#{tag}"))
135
+ git_cmd(%Q{tag -f "#{tag}"})
125
136
  end
126
137
 
127
138
  def restore
128
- log.internal(log_key) { 'Performing cache restoration' }
139
+ log.internal(log_key) { "Performing cache restoration" }
129
140
 
130
141
  create_cache_path
131
142
 
132
143
  restore_me = false
133
- cmd = git_cmd(%Q(tag -l "#{tag}"))
144
+ cmd = git_cmd(%Q{tag -l "#{tag}"})
134
145
 
135
146
  cmd.stdout.each_line do |line|
136
147
  restore_me = true if tag == line.chomp
@@ -138,7 +149,7 @@ module Omnibus
138
149
 
139
150
  if restore_me
140
151
  log.internal(log_key) { "Detected tag `#{tag}' can be restored, restoring" }
141
- git_cmd(%Q(checkout -f "#{tag}"))
152
+ git_cmd(%Q{checkout -f "#{tag}"})
142
153
  true
143
154
  else
144
155
  log.internal(log_key) { "Could not find tag `#{tag}', skipping restore" }
@@ -190,7 +201,7 @@ module Omnibus
190
201
  # @return [String]
191
202
  #
192
203
  def install_dir
193
- @install_dir ||= software.project.install_dir.sub(/^([A-Za-z]:)/, '')
204
+ @install_dir ||= software.project.install_dir.sub(/^([A-Za-z]:)/, "")
194
205
  end
195
206
 
196
207
  # Override the log_key for this class to include the software name