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
@@ -14,9 +14,9 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require 'fileutils'
18
- require 'uri'
19
- require 'omnibus/manifest_entry'
17
+ require "fileutils"
18
+ require "uri"
19
+ require "omnibus/manifest_entry"
20
20
 
21
21
  module Omnibus
22
22
  class Software
@@ -76,6 +76,7 @@ module Omnibus
76
76
  include Logging
77
77
  include NullArgumentable
78
78
  include Sugarable
79
+ include Util
79
80
 
80
81
  attr_reader :manifest
81
82
 
@@ -91,7 +92,7 @@ module Omnibus
91
92
  #
92
93
  # @return [Software]
93
94
  #
94
- def initialize(project, filepath = nil, manifest=nil)
95
+ def initialize(project, filepath = nil, manifest = nil)
95
96
  unless project.is_a?(Project)
96
97
  raise ArgumentError,
97
98
  "`project' must be a kind of `Omnibus::Project', but was `#{project.class.inspect}'!"
@@ -108,10 +109,10 @@ module Omnibus
108
109
 
109
110
  def manifest_entry
110
111
  @manifest_entry ||= if manifest
111
- log.info(log_key) {"Using user-supplied manifest entry for #{name}"}
112
+ log.info(log_key) { "Using user-supplied manifest entry for #{name}" }
112
113
  manifest.entry_for(name)
113
114
  else
114
- log.info(log_key) {"Resolving manifest entry for #{name}"}
115
+ log.info(log_key) { "Resolving manifest entry for #{name}" }
115
116
  to_manifest_entry
116
117
  end
117
118
  end
@@ -156,7 +157,7 @@ module Omnibus
156
157
  #
157
158
  def name(val = NULL)
158
159
  if null?(val)
159
- @name || raise(MissingRequiredAttribute.new(self, :name, 'libxslt'))
160
+ @name || raise(MissingRequiredAttribute.new(self, :name, "libxslt"))
160
161
  else
161
162
  @name = val
162
163
  end
@@ -183,7 +184,6 @@ module Omnibus
183
184
  end
184
185
  expose :description
185
186
 
186
-
187
187
  #
188
188
  # Sets the maintainer of the software. Currently this is for
189
189
  # human consumption only and the tool doesn't do anything with it.
@@ -352,7 +352,7 @@ module Omnibus
352
352
  #
353
353
  def license(val = NULL)
354
354
  if null?(val)
355
- @license || 'Unspecified'
355
+ @license || "Unspecified"
356
356
  else
357
357
  @license = val
358
358
  end
@@ -379,6 +379,26 @@ module Omnibus
379
379
  end
380
380
  expose :license_file
381
381
 
382
+ #
383
+ # Skip collecting licenses of transitive dependencies for this software
384
+ #
385
+ # @example
386
+ # skip_transitive_dependency_licensing true
387
+ #
388
+ # @param [Boolean] val
389
+ # set or reset transitive dependency license collection
390
+ #
391
+ # @return [Boolean]
392
+ #
393
+ def skip_transitive_dependency_licensing(val = NULL)
394
+ if null?(val)
395
+ @skip_transitive_dependency_licensing || false
396
+ else
397
+ @skip_transitive_dependency_licensing = val
398
+ end
399
+ end
400
+ expose :skip_transitive_dependency_licensing
401
+
382
402
  #
383
403
  # Evaluate a block only if the version matches.
384
404
  #
@@ -400,10 +420,29 @@ module Omnibus
400
420
  if block_given?
401
421
  if val.equal?(NULL)
402
422
  raise InvalidValue.new(:version,
403
- 'pass a block when given a version argument')
423
+ "pass a block when given a version argument")
404
424
  else
405
425
  if val == final_version
406
- block.call
426
+ #
427
+ # Unfortunately we need to make a specific logic here for license files.
428
+ # We support multiple calls `license_file` and we support overriding the
429
+ # license files inside a version block. We can not differentiate whether
430
+ # `license_file` is being called from a version block or not. So we need
431
+ # to check if the license files are being overridden during the call to
432
+ # block.
433
+ #
434
+ # If so we use the new set, otherwise we restore the old license files.
435
+ #
436
+ current_license_files = @license_files
437
+ @license_files = []
438
+
439
+ yield
440
+
441
+ new_license_files = @license_files
442
+
443
+ if new_license_files.empty?
444
+ @license_files = current_license_files
445
+ end
407
446
  end
408
447
  end
409
448
  end
@@ -465,7 +504,7 @@ module Omnibus
465
504
  #
466
505
  def relative_path(val = NULL)
467
506
  if null?(val)
468
- @relative_path || '.'
507
+ @relative_path || "."
469
508
  else
470
509
  @relative_path = val
471
510
  end
@@ -572,8 +611,6 @@ module Omnibus
572
611
  #
573
612
  # Supported options:
574
613
  # :aix => :use_gcc force using gcc/g++ compilers on aix
575
- # :bfd_flags => true the default build targets for windows based on
576
- # the current platform architecture are added ARFLAGS and RCFLAGS.
577
614
  #
578
615
  # @param [Hash] env
579
616
  # @param [Hash] opts
@@ -584,7 +621,7 @@ module Omnibus
584
621
  env ||= {}
585
622
  opts ||= {}
586
623
  compiler_flags =
587
- case Ohai['platform']
624
+ case Ohai["platform"]
588
625
  when "aix"
589
626
  {
590
627
  "CC" => "xlc_r -q64",
@@ -601,7 +638,7 @@ module Omnibus
601
638
  "CFLAGS" => "-I#{install_dir}/embedded/include -O2",
602
639
  }
603
640
  when "solaris2"
604
- if platform_version.satisfies?('<= 5.10')
641
+ if platform_version.satisfies?("<= 5.10")
605
642
  solaris_flags = {
606
643
  # this override is due to a bug in libtool documented here:
607
644
  # http://lists.gnu.org/archive/html/bug-libtool/2005-10/msg00004.html
@@ -609,7 +646,7 @@ module Omnibus
609
646
  "LDFLAGS" => "-R#{install_dir}/embedded/lib -L#{install_dir}/embedded/lib -static-libgcc",
610
647
  "CFLAGS" => "-I#{install_dir}/embedded/include",
611
648
  }
612
- elsif platform_version.satisfies?('>= 5.11')
649
+ elsif platform_version.satisfies?(">= 5.11")
613
650
  solaris_flags = {
614
651
  "CC" => "gcc -m64 -static-libgcc",
615
652
  "LDFLAGS" => "-Wl,-rpath,#{install_dir}/embedded/lib -L#{install_dir}/embedded/lib -static-libgcc",
@@ -623,25 +660,21 @@ module Omnibus
623
660
  "CFLAGS" => "-I#{install_dir}/embedded/include -O2",
624
661
  }
625
662
  # Enable gcc version 4.9 if it is available
626
- if (Ohai['os_version'].to_i <= 903000) && which('gcc49')
627
- freebsd_flags.merge!(
628
- "CC" => "gcc49",
629
- "CXX" => "g++49",
630
- )
663
+ if (Ohai["os_version"].to_i <= 903000) && which("gcc49")
664
+ freebsd_flags["CC"] = "gcc49"
665
+ freebsd_flags["CXX"] = "g++49"
631
666
  end
632
667
  # Clang became the default compiler in FreeBSD 10+
633
- if Ohai['os_version'].to_i >= 1000024
634
- freebsd_flags.merge!(
635
- "CC" => "clang",
636
- "CXX" => "clang++",
637
- )
668
+ if Ohai["os_version"].to_i >= 1000024
669
+ freebsd_flags["CC"] = "clang"
670
+ freebsd_flags["CXX"] = "clang++"
638
671
  end
639
672
  freebsd_flags
640
673
  when "windows"
641
674
  arch_flag = windows_arch_i386? ? "-m32" : "-m64"
642
675
  opt_flag = windows_arch_i386? ? "-march=i686" : "-march=x86-64"
643
676
  {
644
- "LDFLAGS" => "-L#{install_dir}/embedded/lib #{arch_flag}",
677
+ "LDFLAGS" => "-L#{install_dir}/embedded/lib #{arch_flag} -fno-lto",
645
678
  # We do not wish to enable SSE even though we target i686 because
646
679
  # of a stack alignment issue with some libraries. We have not
647
680
  # exactly ascertained the cause but some compiled library/binary
@@ -651,7 +684,13 @@ module Omnibus
651
684
  # soon as gcc emits aligned SSE xmm register spills which generate
652
685
  # GPEs and terminate the application very rudely with very little
653
686
  # to debug with.
654
- "CFLAGS" => "-I#{install_dir}/embedded/include #{arch_flag} -O3 #{opt_flag}"
687
+ #
688
+ # TODO: This was true of our old TDM gcc 4.7 compilers. Is it still
689
+ # true with mingw-w64?
690
+ #
691
+ # XXX: Temporarily turning -O3 into -O2 -fno-lto to work around some
692
+ # weird linker issues.
693
+ "CFLAGS" => "-I#{install_dir}/embedded/include #{arch_flag} -O2 -fno-lto #{opt_flag}",
655
694
  }
656
695
  else
657
696
  {
@@ -660,18 +699,6 @@ module Omnibus
660
699
  }
661
700
  end
662
701
 
663
- # There are some weird, misbehaving makefiles on windows that hate ARFLAGS because it
664
- # replaces the "rcs" flags in some build steps. So we provide this flag behind an
665
- # optional flag.
666
- if opts[:bfd_flags] && windows?
667
- bfd_target = windows_arch_i386? ? "pe-i386" : "pe-x86-64"
668
- compiler_flags.merge!(
669
- {
670
- "RCFLAGS" => "--target=#{bfd_target}",
671
- "ARFLAGS" => "--target=#{bfd_target}",
672
- }
673
- )
674
- end
675
702
  # merge LD_RUN_PATH into the environment. most unix distros will fall
676
703
  # back to this if there is no LDFLAGS passed to the linker that sets
677
704
  # the rpath. the LDFLAGS -R or -Wl,-rpath will override this, but in
@@ -680,30 +707,26 @@ module Omnibus
680
707
  # better. in that case LD_RUN_PATH will probably survive whatever
681
708
  # edits the configure script does
682
709
  extra_linker_flags = {
683
- "LD_RUN_PATH" => "#{install_dir}/embedded/lib"
710
+ "LD_RUN_PATH" => "#{install_dir}/embedded/lib",
684
711
  }
685
712
 
686
713
  if solaris2?
687
714
  ld_options = "-R#{install_dir}/embedded/lib"
688
715
 
689
- if platform_version.satisfies?('<= 5.10')
716
+ if platform_version.satisfies?("<= 5.10")
690
717
  # in order to provide compatibility for earlier versions of libc on solaris 10,
691
718
  # we need to specify a mapfile that restricts the version of system libraries
692
719
  # used. See http://docs.oracle.com/cd/E23824_01/html/819-0690/chapter5-1.html
693
720
  # for more information
694
721
  # use the mapfile if it exists, otherwise ignore it
695
722
  mapfile_path = File.expand_path(Config.solaris_linker_mapfile, Config.project_root)
696
- ld_options << " -M #{mapfile_path}" if File.exist?(mapfile_path)
723
+ ld_options << " -M #{mapfile_path}" if File.exist?(mapfile_path)
697
724
  end
698
725
 
699
726
  # solaris linker can also use LD_OPTIONS, so we throw the kitchen sink against
700
727
  # the linker, to find every way to make it use our rpath. This is also required
701
728
  # to use the aforementioned mapfile.
702
- extra_linker_flags.merge!(
703
- {
704
- "LD_OPTIONS" => ld_options
705
- }
706
- )
729
+ extra_linker_flags["LD_OPTIONS"] = ld_options
707
730
  end
708
731
 
709
732
  env.merge(compiler_flags).
@@ -711,10 +734,10 @@ module Omnibus
711
734
  # always want to favor pkg-config from embedded location to not hose
712
735
  # configure scripts which try to be too clever and ignore our explicit
713
736
  # CFLAGS and LDFLAGS in favor of pkg-config info
714
- merge({"PKG_CONFIG_PATH" => "#{install_dir}/embedded/lib/pkgconfig"}).
737
+ merge({ "PKG_CONFIG_PATH" => "#{install_dir}/embedded/lib/pkgconfig" }).
715
738
  # Set default values for CXXFLAGS and CPPFLAGS.
716
- merge('CXXFLAGS' => compiler_flags['CFLAGS']).
717
- merge('CPPFLAGS' => compiler_flags['CFLAGS'])
739
+ merge("CXXFLAGS" => compiler_flags["CFLAGS"]).
740
+ merge("CPPFLAGS" => compiler_flags["CFLAGS"])
718
741
  end
719
742
  expose :with_standard_compiler_flags
720
743
 
@@ -724,19 +747,30 @@ module Omnibus
724
747
  # for the platform is used to join the paths.
725
748
  #
726
749
  # @param [Hash] env
727
- # @param [Hash] opts
728
- # :msys => true add the embedded msys path if building on windows.
729
750
  #
730
751
  # @return [Hash]
731
752
  #
732
- def with_embedded_path(env = {}, opts = {})
753
+ def with_embedded_path(env = {})
733
754
  paths = ["#{install_dir}/bin", "#{install_dir}/embedded/bin"]
734
- paths << "#{install_dir}/embedded/msys/1.0/bin" if opts[:msys] && windows?
735
755
  path_value = prepend_path(paths)
736
756
  env.merge(path_key => path_value)
737
757
  end
738
758
  expose :with_embedded_path
739
759
 
760
+ #
761
+ # Returns the platform safe full path under embedded/bin directory to the
762
+ # given binary
763
+ #
764
+ # @param [String] bin
765
+ # Name of the binary under embedded/bin
766
+ #
767
+ # @return [String]
768
+ #
769
+ def embedded_bin(bin)
770
+ windows_safe_path("#{install_dir}/embedded/bin/#{bin}")
771
+ end
772
+ expose :embedded_bin
773
+
740
774
  #
741
775
  # A PATH variable format string representing the current PATH with the
742
776
  # given path prepended. The correct path separator
@@ -750,7 +784,7 @@ module Omnibus
750
784
  path_values = Array(paths)
751
785
  path_values << ENV[path_key]
752
786
 
753
- separator = File::PATH_SEPARATOR || ':'
787
+ separator = File::PATH_SEPARATOR || ":"
754
788
  path_values.join(separator)
755
789
  end
756
790
  expose :prepend_path
@@ -807,7 +841,7 @@ module Omnibus
807
841
  described_version: version,
808
842
  locked_version: Fetcher.resolve_version(version, source),
809
843
  locked_source: source,
810
- license: license
844
+ license: license,
811
845
  })
812
846
  end
813
847
 
@@ -928,18 +962,18 @@ module Omnibus
928
962
  # Returns the version to be used in cache.
929
963
  def version_for_cache
930
964
  @version_for_cache ||= if fetcher.version_for_cache
931
- fetcher.version_for_cache
932
- elsif version
933
- version
934
- else
935
- log.warn(log_key) do
936
- "No version given! This is probably a bad thing. I am going to " \
937
- "assume the version `0.0.0', but that is most certainly not your " \
938
- "desired behavior. If git caching seems off, this is probably why."
939
- end
940
-
941
- '0.0.0'
942
- end
965
+ fetcher.version_for_cache
966
+ elsif version
967
+ version
968
+ else
969
+ log.warn(log_key) do
970
+ "No version given! This is probably a bad thing. I am going to " \
971
+ "assume the version `0.0.0', but that is most certainly not your " \
972
+ "desired behavior. If git caching seems off, this is probably why."
973
+ end
974
+
975
+ "0.0.0"
976
+ end
943
977
  end
944
978
 
945
979
  #
@@ -961,7 +995,7 @@ module Omnibus
961
995
  #
962
996
  def fetcher
963
997
  @fetcher ||=
964
- if source_type == :url && File.basename(source[:url], '?*').end_with?(*NetFetcher::ALL_EXTENSIONS)
998
+ if source_type == :url && File.basename(source[:url], "?*").end_with?(*NetFetcher::ALL_EXTENSIONS)
965
999
  Fetcher.fetcher_class_for_source(self.source).new(manifest_entry, fetch_dir, build_dir)
966
1000
  else
967
1001
  Fetcher.fetcher_class_for_source(self.source).new(manifest_entry, project_dir, build_dir)
@@ -994,25 +1028,33 @@ module Omnibus
994
1028
  # be restored (if the tag does not exist), the actual build steps are
995
1029
  # executed.
996
1030
  #
1031
+ # @param [Array<#execute_pre_build, #execute_post_build>] build_wrappers
1032
+ # Build wrappers inject behavior before or after the software is built.
1033
+ # They can be any object that implements `#execute_pre_build` and
1034
+ # `#execute_post_build`, taking this Software as an argument. Note that
1035
+ # these callbacks are only triggered when the software actually gets
1036
+ # built; if the build is skipped by the git cache, the callbacks DO NOT
1037
+ # run.
1038
+ #
997
1039
  # @return [true]
998
1040
  #
999
- def build_me
1041
+ def build_me(build_wrappers = [])
1000
1042
  if Config.use_git_caching
1001
1043
  if project.dirty?
1002
1044
  log.info(log_key) do
1003
1045
  "Building because `#{project.culprit.name}' dirtied the cache"
1004
1046
  end
1005
- execute_build
1047
+ execute_build(build_wrappers)
1006
1048
  elsif git_cache.restore
1007
1049
  log.info(log_key) { "Restored from cache" }
1008
1050
  else
1009
1051
  log.info(log_key) { "Could not restore from cache" }
1010
- execute_build
1052
+ execute_build(build_wrappers)
1011
1053
  project.dirty!(self)
1012
1054
  end
1013
1055
  else
1014
1056
  log.debug(log_key) { "Forcing build because git caching is off" }
1015
- execute_build
1057
+ execute_build(build_wrappers)
1016
1058
  end
1017
1059
 
1018
1060
  project.build_version_dsl.resolve(self)
@@ -1064,7 +1106,7 @@ module Omnibus
1064
1106
  if filepath && File.exist?(filepath)
1065
1107
  update_with_file_contents(digest, filepath)
1066
1108
  else
1067
- update_with_string(digest, '<DYNAMIC>')
1109
+ update_with_string(digest, "<DYNAMIC>")
1068
1110
  end
1069
1111
 
1070
1112
  digest.hexdigest
@@ -1097,10 +1139,10 @@ module Omnibus
1097
1139
  # modify ENV['Path'] then it ignores that. So, we scan ENV and returns the first
1098
1140
  # one that we find.
1099
1141
  #
1100
- if Ohai['platform'] == 'windows'
1142
+ if Ohai["platform"] == "windows"
1101
1143
  ENV.keys.grep(/\Apath\Z/i).first
1102
1144
  else
1103
- 'PATH'
1145
+ "PATH"
1104
1146
  end
1105
1147
  end
1106
1148
 
@@ -1108,7 +1150,7 @@ module Omnibus
1108
1150
  # Apply overrides in the @overrides hash that mask instance variables
1109
1151
  # that are set by parsing the DSL
1110
1152
  #
1111
- def apply_overrides(attr, override=overrides[attr])
1153
+ def apply_overrides(attr, override = overrides[attr])
1112
1154
  val = instance_variable_get(:"@#{attr}")
1113
1155
  if val.is_a?(Hash) || override.is_a?(Hash)
1114
1156
  val ||= {}
@@ -1135,15 +1177,23 @@ module Omnibus
1135
1177
  # Actually build this software, executing the steps provided in the
1136
1178
  # {#build} block and dirtying the cache.
1137
1179
  #
1180
+ # @param [Array<#execute_pre_build, #execute_post_build>] build_wrappers
1181
+ # Build wrappers inject behavior before or after the software is built.
1182
+ # They can be any object that implements `#execute_pre_build` and
1183
+ # `#execute_post_build`
1184
+ #
1138
1185
  # @return [void]
1139
1186
  #
1140
- def execute_build
1187
+ def execute_build(build_wrappers)
1141
1188
  fetcher.clean
1189
+
1190
+ build_wrappers.each { |wrapper| wrapper.execute_pre_build(self) }
1142
1191
  builder.build
1192
+ build_wrappers.each { |wrapper| wrapper.execute_post_build(self) }
1143
1193
 
1144
1194
  if Config.use_git_caching
1145
1195
  git_cache.incremental
1146
- log.info(log_key) { 'Dirtied the cache' }
1196
+ log.info(log_key) { "Dirtied the cache" }
1147
1197
  end
1148
1198
  end
1149
1199
 
@@ -14,15 +14,15 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require 'chef/sugar/architecture'
18
- require 'chef/sugar/cloud'
19
- require 'chef/sugar/constraints'
20
- require 'chef/sugar/ip'
21
- require 'chef/sugar/platform'
22
- require 'chef/sugar/platform_family'
23
- require 'chef/sugar/ruby'
24
- require 'chef/sugar/shell'
25
- require 'chef/sugar/vagrant'
17
+ require "chef/sugar/architecture"
18
+ require "chef/sugar/cloud"
19
+ require "chef/sugar/constraints"
20
+ require "chef/sugar/ip"
21
+ require "chef/sugar/platform"
22
+ require "chef/sugar/platform_family"
23
+ require "chef/sugar/ruby"
24
+ require "chef/sugar/shell"
25
+ require "chef/sugar/vagrant"
26
26
 
27
27
  module Omnibus
28
28
  module Sugarable
@@ -42,7 +42,7 @@ module Omnibus
42
42
  end
43
43
 
44
44
  # Make all the common "sugars" available in the cleanroom (DSL)
45
- Omnibus::Sugar.instance_methods.each do |instance_method|
45
+ Omnibus::Sugar.instance_methods.each do |instance_method|
46
46
  base.send(:expose, instance_method)
47
47
  end
48
48
  end
@@ -14,7 +14,7 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require 'erb'
17
+ require "erb"
18
18
 
19
19
  module Omnibus
20
20
  module Templating
@@ -40,7 +40,7 @@ module Omnibus
40
40
  # the list of variables to pass to the template
41
41
  #
42
42
  def render_template(source, options = {})
43
- destination = options.delete(:destination) || source.chomp('.erb')
43
+ destination = options.delete(:destination) || source.chomp(".erb")
44
44
 
45
45
  mode = options.delete(:mode) || 0644
46
46
  variables = options.delete(:variables) || {}
@@ -52,7 +52,7 @@ module Omnibus
52
52
  "Unknown option(s): #{options.keys.map(&:inspect).join(', ')}"
53
53
  end
54
54
 
55
- template = ERB.new(File.read(source), nil, '-')
55
+ template = ERB.new(File.read(source), nil, "-")
56
56
 
57
57
  struct =
58
58
  if variables.empty?
@@ -61,9 +61,9 @@ module Omnibus
61
61
  Struct.new(*variables.keys).new(*variables.values)
62
62
  end
63
63
 
64
- result = template.result(struct.instance_eval { binding })
64
+ result = template.result(struct.instance_eval { binding })
65
65
 
66
- File.open(destination, 'w', mode) do |file|
66
+ File.open(destination, "w", mode) do |file|
67
67
  file.write(result)
68
68
  end
69
69
 
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require 'thread'
18
+ require "thread"
19
19
 
20
20
  module Omnibus
21
21
  class ThreadPool
data/lib/omnibus/util.rb CHANGED
@@ -14,7 +14,7 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require 'mixlib/shellout'
17
+ require "mixlib/shellout"
18
18
 
19
19
  module Omnibus
20
20
  module Util
@@ -67,9 +67,9 @@ module Omnibus
67
67
 
68
68
  # Log any environment options given
69
69
  unless options[:environment].empty?
70
- log.public_send(log_level, log_key) { 'Environment:' }
70
+ log.public_send(log_level, log_key) { "Environment:" }
71
71
  options[:environment].sort.each do |key, value|
72
- log.public_send(log_level, log_key) { " #{key}=#{value.inspect}" }
72
+ log.public_send(log_level, log_key) { " #{key}=#{value.inspect}" }
73
73
  end
74
74
  end
75
75
 
@@ -77,7 +77,7 @@ module Omnibus
77
77
  log.public_send(log_level, log_key) { "$ #{args.join(' ')}" }
78
78
 
79
79
  cmd = Mixlib::ShellOut.new(*args, options)
80
- cmd.environment['HOME'] = '/tmp' unless ENV['HOME']
80
+ cmd.environment["HOME"] = "/tmp" unless ENV["HOME"]
81
81
  cmd.run_command
82
82
  cmd
83
83
  end
@@ -202,7 +202,7 @@ module Omnibus
202
202
  FileUtils.mkdir_p(File.dirname(path))
203
203
 
204
204
  if block
205
- File.open(path, 'wb') { |f| f.write(block.call) }
205
+ File.open(path, "wb") { |f| f.write(yield) }
206
206
  else
207
207
  FileUtils.touch(path)
208
208
  end
@@ -15,5 +15,5 @@
15
15
  #
16
16
 
17
17
  module Omnibus
18
- VERSION = '5.4.0'
18
+ VERSION = "5.5.0"
19
19
  end