omnibus 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +17 -1
  3. data/.travis.yml +11 -3
  4. data/CHANGELOG.md +39 -1
  5. data/Gemfile +0 -4
  6. data/README.md +10 -8
  7. data/Rakefile +18 -7
  8. data/bin/omnibus +3 -3
  9. data/docs/Building on Windows.md +98 -0
  10. data/features/commands/_deprecated.feature +46 -0
  11. data/features/commands/build.feature +9 -0
  12. data/features/commands/clean.feature +21 -0
  13. data/features/commands/list.feature +16 -0
  14. data/features/commands/new.feature +8 -0
  15. data/features/commands/version.feature +12 -0
  16. data/features/step_definitions/generator_steps.rb +28 -0
  17. data/features/support/env.rb +13 -0
  18. data/lib/omnibus.rb +319 -240
  19. data/lib/omnibus/artifact.rb +16 -0
  20. data/lib/omnibus/build_version.rb +39 -20
  21. data/lib/omnibus/build_version_dsl.rb +136 -0
  22. data/lib/omnibus/builder.rb +28 -23
  23. data/lib/omnibus/cleaner.rb +72 -0
  24. data/lib/omnibus/cli.rb +115 -11
  25. data/lib/omnibus/cli/base.rb +82 -81
  26. data/lib/omnibus/cli/cache.rb +80 -32
  27. data/lib/omnibus/cli/deprecated.rb +79 -0
  28. data/lib/omnibus/cli/release.rb +17 -21
  29. data/lib/omnibus/config.rb +38 -13
  30. data/lib/omnibus/exceptions.rb +70 -18
  31. data/lib/omnibus/fetcher.rb +18 -11
  32. data/lib/omnibus/fetchers/git_fetcher.rb +48 -53
  33. data/lib/omnibus/fetchers/net_fetcher.rb +29 -27
  34. data/lib/omnibus/fetchers/path_fetcher.rb +9 -12
  35. data/lib/omnibus/fetchers/s3_cache_fetcher.rb +5 -8
  36. data/lib/omnibus/generator.rb +131 -0
  37. data/lib/omnibus/{templates → generator_files}/.kitchen.local.yml.erb +0 -0
  38. data/lib/omnibus/{templates → generator_files}/.kitchen.yml.erb +0 -0
  39. data/lib/omnibus/{templates → generator_files}/Berksfile.erb +0 -0
  40. data/lib/omnibus/{templates → generator_files}/Gemfile.erb +2 -2
  41. data/lib/omnibus/{templates → generator_files}/README.md.erb +6 -7
  42. data/lib/omnibus/{templates → generator_files}/Vagrantfile.erb +0 -0
  43. data/lib/omnibus/{templates → generator_files}/gitignore.erb +0 -0
  44. data/lib/omnibus/{templates → generator_files}/mac_dmg/background.png +0 -0
  45. data/lib/omnibus/{templates → generator_files}/mac_dmg/icon.png +0 -0
  46. data/lib/omnibus/{templates → generator_files}/mac_pkg/background.png +0 -0
  47. data/lib/omnibus/{templates → generator_files}/mac_pkg/license.html.erb +0 -0
  48. data/lib/omnibus/{templates → generator_files}/mac_pkg/welcome.html.erb +0 -0
  49. data/lib/omnibus/{templates → generator_files}/omnibus.rb.example.erb +0 -0
  50. data/lib/omnibus/{templates → generator_files}/package_scripts/makeselfinst.erb +0 -0
  51. data/lib/omnibus/{templates → generator_files}/package_scripts/postinst.erb +0 -0
  52. data/lib/omnibus/{templates → generator_files}/package_scripts/postrm.erb +0 -0
  53. data/lib/omnibus/{templates → generator_files}/package_scripts/preinst.erb +0 -0
  54. data/lib/omnibus/{templates → generator_files}/package_scripts/prerm.erb +0 -0
  55. data/lib/omnibus/{templates → generator_files}/project.rb.erb +0 -1
  56. data/lib/omnibus/{templates → generator_files}/software/c-example.rb.erb +0 -0
  57. data/lib/omnibus/{templates → generator_files}/software/erlang-example.rb.erb +0 -0
  58. data/lib/omnibus/{templates → generator_files}/software/ruby-example.rb.erb +0 -0
  59. data/lib/omnibus/generator_files/windows_msi/assets/LICENSE.rtf +8 -0
  60. data/lib/omnibus/generator_files/windows_msi/assets/banner_background.bmp +0 -0
  61. data/lib/omnibus/generator_files/windows_msi/assets/dialog_background.bmp +0 -0
  62. data/lib/omnibus/generator_files/windows_msi/assets/project.ico +0 -0
  63. data/lib/omnibus/generator_files/windows_msi/assets/project_16x16.ico +0 -0
  64. data/lib/omnibus/generator_files/windows_msi/assets/project_32x32.ico +0 -0
  65. data/lib/omnibus/generator_files/windows_msi/localization-en-us.wxl.erb +20 -0
  66. data/lib/omnibus/generator_files/windows_msi/parameters.wxi.erb +9 -0
  67. data/lib/omnibus/generator_files/windows_msi/source.wxs.erb +74 -0
  68. data/lib/omnibus/health_check.rb +80 -40
  69. data/lib/omnibus/install_path_cache.rb +11 -12
  70. data/lib/omnibus/library.rb +30 -3
  71. data/lib/omnibus/logger.rb +47 -0
  72. data/lib/omnibus/logging.rb +60 -0
  73. data/lib/omnibus/null_builder.rb +23 -0
  74. data/lib/omnibus/ohai.rb +70 -0
  75. data/lib/omnibus/overrides.rb +69 -48
  76. data/lib/omnibus/package_release.rb +7 -14
  77. data/lib/omnibus/packagers/base.rb +66 -13
  78. data/lib/omnibus/packagers/mac_dmg.rb +23 -3
  79. data/lib/omnibus/packagers/mac_pkg.rb +20 -10
  80. data/lib/omnibus/packagers/windows_msi.rb +109 -0
  81. data/lib/omnibus/project.rb +136 -79
  82. data/lib/omnibus/reports.rb +1 -2
  83. data/lib/omnibus/{s3_cacher.rb → s3_cache.rb} +15 -37
  84. data/lib/omnibus/software.rb +77 -27
  85. data/lib/omnibus/software_s3_urls.rb +50 -0
  86. data/lib/omnibus/sugar.rb +1 -3
  87. data/lib/omnibus/util.rb +45 -18
  88. data/lib/omnibus/version.rb +2 -3
  89. data/omnibus.gemspec +5 -3
  90. data/spec/data/complicated/config/patches/bzip2/makefile_take_env_vars.patch +15 -0
  91. data/spec/data/complicated/config/patches/couchdb/patch_for_couchjs_stack.patch +19 -0
  92. data/spec/data/complicated/config/patches/gd/gd-2.0.33-configure-libpng.patch +100 -0
  93. data/spec/data/complicated/config/patches/keepalived/keepalived-1.2.9_opscode_centos_5.patch +15 -0
  94. data/spec/data/complicated/config/patches/libedit/freebsd-vi-fix.patch +24 -0
  95. data/spec/data/complicated/config/patches/libiconv/libiconv-1.14_srclib_stdio.in.h-remove-gets-declarations.patch +29 -0
  96. data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-makefile-dest-fix.patch +35 -0
  97. data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-malloc-fix.patch +13 -0
  98. data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-shared_lib_plus_plus-1.patch +1035 -0
  99. data/spec/data/complicated/config/patches/logrotate/logrotate_basedir_override.patch +12 -0
  100. data/spec/data/complicated/config/patches/ncurses/ncurses-5.9-solaris-xopen_source_extended-detection.patch +11 -0
  101. data/spec/data/complicated/config/patches/ncurses/ncurses-clang.patch +42 -0
  102. data/spec/data/complicated/config/patches/ncurses/patch-aa +23 -0
  103. data/spec/data/complicated/config/patches/ncurses/patch-ab +44 -0
  104. data/spec/data/complicated/config/patches/ncurses/patch-ac +40 -0
  105. data/spec/data/complicated/config/patches/ncurses/patch-ad +12 -0
  106. data/spec/data/complicated/config/patches/ncurses/patch-aix-configure +23 -0
  107. data/spec/data/complicated/config/patches/ncurses/patch-cxx_cursesf.h +22 -0
  108. data/spec/data/complicated/config/patches/ncurses/patch-cxx_cursesm.h +22 -0
  109. data/spec/data/complicated/config/patches/nrpe/fix_for_runit.patch +64 -0
  110. data/spec/data/complicated/config/patches/openssl/openssl-1.0.1f-do-not-build-docs.patch +101 -0
  111. data/spec/data/complicated/config/patches/postgresql/postgresql-9.1.2-configure-ncurses-fix.patch +12 -0
  112. data/spec/data/complicated/config/patches/ruby/patch-configure +103 -0
  113. data/spec/data/complicated/config/patches/ruby/ruby-aix-configure.patch +10 -0
  114. data/spec/data/complicated/config/patches/ruby/ruby-openssl-1.0.1c.patch +42 -0
  115. data/spec/data/complicated/config/patches/ruby/ruby_aix_1_9_3_448_ssl_EAGAIN.patch +57 -0
  116. data/spec/data/complicated/config/patches/ruby/rvm-cflags.patch +27 -0
  117. data/spec/data/complicated/config/projects/angrychef.rb +32 -0
  118. data/spec/data/complicated/config/projects/chef-windows.rb +32 -0
  119. data/spec/data/complicated/config/projects/chef.rb +32 -0
  120. data/spec/data/complicated/config/projects/chefdk-windows.rb +41 -0
  121. data/spec/data/complicated/config/projects/chefdk.rb +44 -0
  122. data/spec/data/complicated/config/software/appbundler.rb +25 -0
  123. data/spec/data/complicated/config/software/autoconf.rb +35 -0
  124. data/spec/data/complicated/config/software/automake.rb +39 -0
  125. data/spec/data/complicated/config/software/berkshelf.rb +44 -0
  126. data/{lib/omnibus/fetchers.rb → spec/data/complicated/config/software/bundler.rb} +8 -5
  127. data/spec/data/complicated/config/software/bzip2.rb +46 -0
  128. data/spec/data/complicated/config/software/cacerts.rb +44 -0
  129. data/spec/data/complicated/config/software/chef-client-msi.rb +88 -0
  130. data/spec/data/complicated/config/software/chef-gem.rb +26 -0
  131. data/spec/data/complicated/config/software/chef-vault.rb +43 -0
  132. data/spec/data/complicated/config/software/chef-windows.rb +158 -0
  133. data/spec/data/complicated/config/software/chef.rb +170 -0
  134. data/spec/data/complicated/config/software/chefdk.rb +103 -0
  135. data/spec/data/complicated/config/software/couchdb.rb +53 -0
  136. data/spec/data/complicated/config/software/curl.rb +48 -0
  137. data/spec/data/complicated/config/software/erlang.rb +65 -0
  138. data/spec/data/complicated/config/software/expat.rb +21 -0
  139. data/spec/data/complicated/config/software/fcgi.rb +56 -0
  140. data/spec/data/complicated/config/software/fcgiwrap.rb +41 -0
  141. data/spec/data/complicated/config/software/gd.rb +56 -0
  142. data/spec/data/complicated/config/software/gdbm.rb +40 -0
  143. data/spec/data/complicated/config/software/gecode.rb +48 -0
  144. data/spec/data/complicated/config/software/git.rb +40 -0
  145. data/spec/data/complicated/config/software/help2man.rb +30 -0
  146. data/spec/data/complicated/config/software/icu.rb +40 -0
  147. data/spec/data/complicated/config/software/jre.rb +48 -0
  148. data/spec/data/complicated/config/software/keepalived.rb +43 -0
  149. data/spec/data/complicated/config/software/libarchive.rb +50 -0
  150. data/spec/data/complicated/config/software/libedit.rb +69 -0
  151. data/spec/data/complicated/config/software/libffi.rb +71 -0
  152. data/spec/data/complicated/config/software/libgcc.rb +39 -0
  153. data/spec/data/complicated/config/software/libiconv.rb +66 -0
  154. data/spec/data/complicated/config/software/libjpeg.rb +39 -0
  155. data/spec/data/complicated/config/software/libpng.rb +38 -0
  156. data/spec/data/complicated/config/software/libtool.rb +52 -0
  157. data/spec/data/complicated/config/software/libwrap.rb +50 -0
  158. data/spec/data/complicated/config/software/libxml2.rb +51 -0
  159. data/spec/data/complicated/config/software/libxslt.rb +52 -0
  160. data/spec/data/complicated/config/software/libyaml-windows.rb +43 -0
  161. data/spec/data/complicated/config/software/libyaml.rb +62 -0
  162. data/spec/data/complicated/config/software/logrotate.rb +41 -0
  163. data/spec/data/complicated/config/software/makedepend.rb +73 -0
  164. data/spec/data/complicated/config/software/mysql2.rb +42 -0
  165. data/spec/data/complicated/config/software/nagios-plugins.rb +53 -0
  166. data/spec/data/complicated/config/software/nagios.rb +66 -0
  167. data/spec/data/complicated/config/software/ncurses.rb +149 -0
  168. data/spec/data/complicated/config/software/nginx.rb +40 -0
  169. data/spec/data/complicated/config/software/nodejs.rb +44 -0
  170. data/spec/data/complicated/config/software/nokogiri.rb +55 -0
  171. data/spec/data/complicated/config/software/nrpe.rb +61 -0
  172. data/spec/data/complicated/config/software/ohai.rb +64 -0
  173. data/spec/data/complicated/config/software/omnibus-ctl.rb +34 -0
  174. data/spec/data/complicated/config/software/openresty.rb +67 -0
  175. data/spec/data/complicated/config/software/openssl.rb +158 -0
  176. data/spec/data/complicated/config/software/pcre.rb +42 -0
  177. data/spec/data/complicated/config/software/perl-extutils-embed.rb +15 -0
  178. data/spec/data/complicated/config/software/perl-extutils-makemaker.rb +15 -0
  179. data/spec/data/complicated/config/software/perl.rb +48 -0
  180. data/spec/data/complicated/config/software/perl_pg_driver.rb +12 -0
  181. data/spec/data/complicated/config/software/php.rb +41 -0
  182. data/spec/data/complicated/config/software/pip.rb +30 -0
  183. data/spec/data/complicated/config/software/pkg-config.rb +66 -0
  184. data/spec/data/complicated/config/software/popt.rb +47 -0
  185. data/spec/data/complicated/config/software/postgresql.rb +51 -0
  186. data/spec/data/complicated/config/software/preparation.rb +30 -0
  187. data/spec/data/complicated/config/software/pygments.rb +25 -0
  188. data/spec/data/complicated/config/software/python.rb +49 -0
  189. data/spec/data/complicated/config/software/rabbitmq.rb +36 -0
  190. data/spec/data/complicated/config/software/rebar.rb +36 -0
  191. data/spec/data/complicated/config/software/redis.rb +33 -0
  192. data/spec/data/complicated/config/software/rsync.rb +48 -0
  193. data/spec/data/complicated/config/software/ruby-windows-devkit.rb +30 -0
  194. data/spec/data/complicated/config/software/ruby-windows.rb +30 -0
  195. data/spec/data/complicated/config/software/ruby.rb +162 -0
  196. data/spec/data/complicated/config/software/rubygems-customization.rb +57 -0
  197. data/spec/data/complicated/config/software/rubygems.rb +37 -0
  198. data/spec/data/complicated/config/software/runit.rb +118 -0
  199. data/spec/data/complicated/config/software/server-jre.rb +46 -0
  200. data/spec/data/complicated/config/software/setuptools.rb +30 -0
  201. data/spec/data/complicated/config/software/spawn-fcgi.rb +40 -0
  202. data/spec/data/complicated/config/software/sphinx.rb +26 -0
  203. data/spec/data/complicated/config/software/spidermonkey.rb +60 -0
  204. data/spec/data/complicated/config/software/sqitch.rb +24 -0
  205. data/spec/data/complicated/config/software/test-kitchen.rb +39 -0
  206. data/spec/data/complicated/config/software/unicorn.rb +27 -0
  207. data/spec/data/complicated/config/software/util-macros.rb +46 -0
  208. data/spec/data/complicated/config/software/version-manifest.rb +32 -0
  209. data/spec/data/complicated/config/software/xproto.rb +46 -0
  210. data/spec/data/complicated/config/software/yajl.rb +30 -0
  211. data/spec/data/complicated/config/software/zlib.rb +67 -0
  212. data/spec/data/projects/chefdk.rb +4 -4
  213. data/spec/data/projects/sample.rb +3 -0
  214. data/spec/data/software/erchef.rb +1 -1
  215. data/spec/fixtures/sample/files/windows_msi/Resources/assets/LICENSE.rtf +8 -0
  216. data/spec/fixtures/sample/files/windows_msi/Resources/assets/banner_background.bmp +0 -0
  217. data/spec/fixtures/sample/files/windows_msi/Resources/assets/dialog_background.bmp +0 -0
  218. data/spec/fixtures/sample/files/windows_msi/Resources/assets/project.ico +0 -0
  219. data/spec/fixtures/sample/files/windows_msi/Resources/assets/project_16x16.ico +0 -0
  220. data/spec/fixtures/sample/files/windows_msi/Resources/assets/project_32x32.ico +0 -0
  221. data/spec/fixtures/sample/files/windows_msi/Resources/localization-en-us.wxl +20 -0
  222. data/spec/fixtures/sample/files/windows_msi/Resources/parameters.wxi.erb +9 -0
  223. data/spec/fixtures/sample/files/windows_msi/Resources/source.wxs +74 -0
  224. data/spec/functional/packagers/mac_spec.rb +3 -20
  225. data/spec/functional/packagers/windows_spec.rb +69 -0
  226. data/spec/spec_helper.rb +79 -1
  227. data/spec/unit/artifact_spec.rb +0 -18
  228. data/spec/unit/build_version_dsl_spec.rb +136 -0
  229. data/spec/unit/build_version_spec.rb +185 -198
  230. data/spec/unit/config_spec.rb +18 -1
  231. data/spec/unit/fetchers/git_fetcher_spec.rb +55 -80
  232. data/spec/unit/fetchers/net_fetcher_spec.rb +11 -21
  233. data/spec/unit/install_path_cache_spec.rb +164 -136
  234. data/spec/unit/library_spec.rb +125 -5
  235. data/spec/unit/omnibus_spec.rb +25 -9
  236. data/spec/unit/overrides_spec.rb +2 -14
  237. data/spec/unit/package_release_spec.rb +0 -18
  238. data/spec/unit/packagers/base_spec.rb +84 -21
  239. data/spec/unit/packagers/mac_pkg_spec.rb +34 -24
  240. data/spec/unit/project_spec.rb +100 -102
  241. data/spec/unit/s3_cacher_spec.rb +0 -18
  242. data/spec/unit/software_spec.rb +152 -6
  243. data/spec/{sugar_spec.rb → unit/sugar_spec.rb} +0 -3
  244. metadata +365 -38
  245. data/lib/omnibus/cli/application.rb +0 -147
  246. data/lib/omnibus/cli/build.rb +0 -64
@@ -1,6 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2014 Chef Software, Inc.
3
- # License:: Apache License, Version 2.0
2
+ # Copyright 2014 Chef Software, Inc.
4
3
  #
5
4
  # Licensed under the Apache License, Version 2.0 (the "License");
6
5
  # you may not use this file except in compliance with the License.
@@ -15,8 +14,6 @@
15
14
  # limitations under the License.
16
15
  #
17
16
 
18
- require 'omnibus/util'
19
- require 'omnibus/config'
20
17
  require 'fileutils'
21
18
  require 'digest'
22
19
 
@@ -25,7 +22,7 @@ module Omnibus
25
22
  include Util
26
23
 
27
24
  def initialize(install_path, software)
28
- @install_path = install_path
25
+ @install_path = install_path.sub(/^([A-Za-z]:)/, '') # strip drive letter on Windows
29
26
  @software = software
30
27
  end
31
28
 
@@ -42,14 +39,13 @@ module Omnibus
42
39
  # Creates the full path if it does not exist already
43
40
  def create_cache_path
44
41
  FileUtils.mkdir_p(File.dirname(cache_path))
45
- shellout!("git --git-dir=#{cache_path} init -q") unless cache_path_exists?
42
+ quiet_shellout!("git --git-dir=#{cache_path} init -q") unless cache_path_exists?
46
43
  true
47
44
  end
48
45
 
49
46
  # Computes the tag for this cache entry
50
47
  def tag
51
48
  name = @software.name
52
- version = @software.version
53
49
 
54
50
  # Accumulate an array of all the software projects that come before
55
51
  # the name and version we are tagging. So if you have
@@ -69,26 +65,29 @@ module Omnibus
69
65
  # build params invalidate cache.
70
66
  dep_string = IO.read(@software.source_config) + dep_string
71
67
  digest = Digest::SHA256.hexdigest(dep_string)
68
+
69
+ version = @software.version_for_cache
70
+
72
71
  "#{name}-#{version}-#{digest}"
73
72
  end
74
73
 
75
74
  # Create an incremental install path cache for the software step
76
75
  def incremental
77
76
  create_cache_path
78
- shellout!("git --git-dir=#{cache_path} --work-tree=#{@install_path} add -A -f")
77
+ quiet_shellout!(%Q(git --git-dir=#{cache_path} --work-tree=#{@install_path} add -A -f))
79
78
  begin
80
- shellout!("git --git-dir=#{cache_path} --work-tree=#{@install_path} commit -q -m 'Backup of #{tag}'")
79
+ quiet_shellout!(%Q(git --git-dir=#{cache_path} --work-tree=#{@install_path} commit -q -m "Backup of #{tag}"))
81
80
  rescue Mixlib::ShellOut::ShellCommandFailed => e
82
81
  if e.message !~ /nothing to commit/
83
82
  raise
84
83
  end
85
84
  end
86
- shellout!("git --git-dir=#{cache_path} --work-tree=#{@install_path} tag -f '#{tag}'")
85
+ quiet_shellout!(%Q(git --git-dir=#{cache_path} --work-tree=#{@install_path} tag -f "#{tag}"))
87
86
  end
88
87
 
89
88
  def restore
90
89
  create_cache_path
91
- cmd = shellout("git --git-dir=#{cache_path} --work-tree=#{@install_path} tag -l #{tag}")
90
+ cmd = quiet_shellout(%Q(git --git-dir=#{cache_path} --work-tree=#{@install_path} tag -l "#{tag}"))
92
91
 
93
92
  restore_me = false
94
93
  cmd.stdout.each_line do |line|
@@ -96,7 +95,7 @@ module Omnibus
96
95
  end
97
96
 
98
97
  if restore_me
99
- shellout!("git --git-dir=#{cache_path} --work-tree=#{@install_path} checkout -f '#{tag}'")
98
+ quiet_shellout!(%Q(git --git-dir=#{cache_path} --work-tree=#{@install_path} checkout -f "#{tag}"))
100
99
  true
101
100
  else
102
101
  false
@@ -1,6 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
3
- # License:: Apache License, Version 2.0
2
+ # Copyright 2012-2014 Chef Software, Inc.
4
3
  #
5
4
  # Licensed under the Apache License, Version 2.0 (the "License");
6
5
  # you may not use this file except in compliance with the License.
@@ -19,6 +18,14 @@ module Omnibus
19
18
  #
20
19
  # Used to generate the manifest of all software components with versions
21
20
  class Library
21
+ # The list of Omnibus::Software definitions. This is populated by calling
22
+ # #component_added during code loading. The list is expected to be sorted
23
+ # in a valid order according to project and software dependencies, but this
24
+ # class does not verify that condition.
25
+ #
26
+ # @see Omnibus.expand_software
27
+ # @return [Array<Omnibus::Software>] the software components in optimized
28
+ # order.
22
29
  attr_reader :components
23
30
 
24
31
  def initialize(project)
@@ -26,19 +33,39 @@ module Omnibus
26
33
  @project = project
27
34
  end
28
35
 
36
+ # Callback method that should be called each time an Omnibus::Software
37
+ # definition file is loaded.
38
+ #
39
+ # @param component [Omnibus::Software]
40
+ # @return [void]
29
41
  def component_added(component)
30
42
  unless @components.find { |c| c.name == component.name }
31
43
  @components << component
32
44
  end
33
45
  end
34
46
 
47
+ # The order in which each Software component should be built. The order is
48
+ # based on the order of #components, optimized to move top-level
49
+ # dependencies later in the build order to make the git caching feature
50
+ # more effective. It is assumed that #components is already sorted in a
51
+ # valid dependency order. The optimization works as follows:
52
+ #
53
+ # 1. The first component is assumed to be a preparation step that needs to
54
+ # run first, so it is not moved.
55
+ # 2. If a component is a top-level dependency of the project AND no other
56
+ # software depends on it, it is shifted to last in the optimized order.
57
+ # 3. If none of the above conditions are met, the order of that component
58
+ # is unchanged.
59
+ #
60
+ # @return [Array<Omnibus::Software>] the software components in optimized
61
+ # order.
35
62
  def build_order
36
63
  head = []
37
64
  tail = []
38
65
  @components.each do |component|
39
66
  if head.length == 0
40
67
  head << component
41
- elsif @project.dependencies.include?(component.name)
68
+ elsif @project.dependencies.include?(component.name) && @components.none? { |c| c.dependencies.include?(component.name) }
42
69
  tail << component
43
70
  else
44
71
  head << component
@@ -0,0 +1,47 @@
1
+ require 'logger'
2
+
3
+ module Omnibus
4
+ class Logger < ::Logger
5
+ def initialize(logdev = $stdout, *)
6
+ super
7
+ @level = Logger::WARN
8
+ end
9
+
10
+ #
11
+ # Print a deprecation warning.
12
+ #
13
+ # @see (Logger#add)
14
+ #
15
+ def deprecated(progname = nil, &block)
16
+ if level <= WARN
17
+ add(WARN, 'DEPRECATED: ' + (block ? yield : progname), progname)
18
+ end
19
+ end
20
+
21
+ #
22
+ # Set the log lever for this logger instance.
23
+ #
24
+ # @example
25
+ # logger.level = :info
26
+ #
27
+ # @param [Symbol] level
28
+ #
29
+ def level=(level)
30
+ @level = ::Logger.const_get(level.to_s.upcase)
31
+ rescue NameError
32
+ raise "'#{level.inspect}' does not appear to be a valid log level!"
33
+ end
34
+
35
+ private
36
+
37
+ def format_message(severity, _datetime, progname, msg)
38
+ left = if progname
39
+ "[#{progname}] #{severity[0]} | "
40
+ else
41
+ "#{severity[0]} | "
42
+ end
43
+
44
+ "#{left.rjust(30)}#{msg}\n"
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,60 @@
1
+ #
2
+ # Copyright 2013-2014 Chef Software, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ module Omnibus
18
+ module Logging
19
+ def self.included(base)
20
+ base.send(:include, InstanceMethods)
21
+ base.send(:extend, ClassMethods)
22
+ end
23
+
24
+ module ClassMethods
25
+ private
26
+
27
+ #
28
+ # A helpful DSL method for logging an action.
29
+ #
30
+ # @return [Logger]
31
+ #
32
+ def log
33
+ Omnibus.logger
34
+ end
35
+
36
+ #
37
+ # The key to log with.
38
+ #
39
+ # @return [String]
40
+ #
41
+ def log_key
42
+ @log_key ||= name.split('::')[1..-1].join('::')
43
+ end
44
+ end
45
+
46
+ module InstanceMethods
47
+ private
48
+
49
+ # @see (ClassMethods#log)
50
+ def log
51
+ self.class.send(:log)
52
+ end
53
+
54
+ # @see (ClassMethods#log_key)
55
+ def log_key
56
+ self.class.send(:log_key)
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,23 @@
1
+ #
2
+ # Copyright 2014 Chef Software, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ module Omnibus
18
+ class NullBuilder < Builder
19
+ def build
20
+ log.info(log_key) { "Nothing to build for #{name}" }
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,70 @@
1
+ #
2
+ # Copyright 2012-2014 Chef Software, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'ohai'
18
+
19
+ module Omnibus
20
+ class Ohai
21
+ class << self
22
+ def method_missing(m, *args, &block)
23
+ ohai.send(m, *args, &block)
24
+ end
25
+
26
+ private
27
+
28
+ def ohai
29
+ return @ohai if @ohai
30
+
31
+ @ohai = ::Ohai::System.new
32
+ @ohai.require_plugin('os')
33
+ @ohai.require_plugin('platform')
34
+ @ohai.require_plugin('linux/cpu') if @ohai.os == 'linux'
35
+ @ohai.require_plugin('kernel')
36
+ @ohai
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ module Omnibus
43
+ class OhaiWithWarning < Ohai
44
+ include Logging
45
+
46
+ class << self
47
+ def method_missing(m, *args, &block)
48
+ bad_boy = caller[2]
49
+
50
+ unless warned[bad_boy]
51
+ log.deprecated('OHAI') do
52
+ "OHAI constant. Please use Ohai instead: #{bad_boy}"
53
+ end
54
+ warned[bad_boy] = true
55
+ end
56
+
57
+ Ohai.send(m, *args, &block)
58
+ end
59
+
60
+ def warned
61
+ @warned ||= {}
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ #
68
+ # @todo remove in the next major release
69
+ #
70
+ OHAI = Omnibus::OhaiWithWarning
@@ -1,67 +1,88 @@
1
+ #
2
+ # Copyright 2014 Chef Software, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
1
17
  require 'pp'
2
18
 
3
19
  module Omnibus
4
20
  module Overrides
21
+ include Logging
22
+
5
23
  DEFAULT_OVERRIDE_FILE_NAME = 'omnibus.overrides'
6
24
 
7
- # Parses a file of override information into a Hash.
8
- #
9
- # Each line of the file must be of the form
10
- #
11
- #
12
- # <package_name> <version>
13
- #
14
- # where the two pieces of data are separated by whitespace.
15
- #
16
- # @param file [String] the path to an overrides file
17
- # @return [Hash, nil]
18
- def self.parse_file(file)
19
- if file
20
- File.readlines(file).reduce({}) do |acc, line|
21
- info = line.split
25
+ class << self
26
+ # Parses a file of override information into a Hash.
27
+ #
28
+ # Each line of the file must be of the form
29
+ #
30
+ #
31
+ # <package_name> <version>
32
+ #
33
+ # where the two pieces of data are separated by whitespace.
34
+ #
35
+ # @param file [String] the path to an overrides file
36
+ # @return [Hash, nil]
37
+ def parse_file(file)
38
+ if file
39
+ File.readlines(file).reduce({}) do |acc, line|
40
+ info = line.split
22
41
 
23
- unless info.count == 2
24
- fail ArgumentError, "Invalid overrides line: '#{line.chomp}'"
25
- end
42
+ unless info.count == 2
43
+ raise ArgumentError, "Invalid overrides line: '#{line.chomp}'"
44
+ end
26
45
 
27
- package, version = info
46
+ package, version = info
28
47
 
29
- if acc[package]
30
- fail ArgumentError, "Multiple overrides present for '#{package}' in overrides file #{file}!"
31
- end
48
+ if acc[package]
49
+ raise ArgumentError, "Multiple overrides present for '#{package}' in overrides file #{file}!"
50
+ end
32
51
 
33
- acc[package] = version
34
- acc
52
+ acc[package] = version
53
+ acc
54
+ end
55
+ else
56
+ nil
35
57
  end
36
- else
37
- nil
38
58
  end
39
- end
40
59
 
41
- # Return the full path to an overrides file, or +nil+ if no such
42
- # file exists.
43
- def self.resolve_override_file
44
- file = ENV['OMNIBUS_OVERRIDE_FILE'] || DEFAULT_OVERRIDE_FILE_NAME
45
- path = File.expand_path(file)
46
- File.exist?(path) ? path : nil
47
- end
60
+ # Return the full path to an overrides file, or +nil+ if no such
61
+ # file exists.
62
+ def resolve_override_file
63
+ file = ENV['OMNIBUS_OVERRIDE_FILE'] || DEFAULT_OVERRIDE_FILE_NAME
64
+ path = File.expand_path(file)
65
+ File.exist?(path) ? path : nil
66
+ end
48
67
 
49
- # Return a hash of override information. If no such information
50
- # can be found, the hash will be empty
51
- #
52
- # @return [Hash]
53
- def self.overrides
54
- file = resolve_override_file
55
- overrides = parse_file(file)
68
+ # Return a hash of override information. If no such information
69
+ # can be found, the hash will be empty
70
+ #
71
+ # @return [Hash]
72
+ def overrides
73
+ file = resolve_override_file
74
+ overrides = parse_file(file)
56
75
 
57
- if overrides
58
- puts '********************************************************************************'
59
- puts "Using Overrides from #{Omnibus::Overrides.resolve_override_file}"
60
- pp overrides
61
- puts '********************************************************************************'
62
- end
76
+ if overrides
77
+ log.info(log_key) do
78
+ out = "Using overrides from #{resolve_override_file}\n"
79
+ out << overrides.pretty_inspect
80
+ out
81
+ end
82
+ end
63
83
 
64
- overrides || {}
84
+ overrides || {}
85
+ end
65
86
  end
66
87
  end
67
88
  end