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
@@ -0,0 +1,28 @@
1
+ require 'aruba/api'
2
+
3
+ Given(/^I have an omnibus project named "(.+)"$/) do |name|
4
+ create_dir(name)
5
+ cd(name)
6
+
7
+ write_file("config/projects/#{name}.rb", <<-EOH.gsub(/^ {4}/, ''))
8
+ name '#{name}'
9
+ maintainer 'Mrs. Maintainer'
10
+ homepage 'https://example.com'
11
+ install_path './local/build/#{name}'
12
+
13
+ build_version '1.0.0'
14
+
15
+ exclude '\.git*'
16
+ exclude 'bundler\/git'
17
+ EOH
18
+
19
+ write_file('omnibus.rb', <<-EOH.gsub(/^ {4}/, ''))
20
+ # Build configuration
21
+ cache_dir './local/omnibus/cache'
22
+ install_path_cache_dir './local/omnibus/cache/install_path'
23
+ source_dir './local/omnibus/src'
24
+ build_dir './local/omnibus/build'
25
+ package_dir './local/omnibus/pkg'
26
+ package_tmp './local/omnibus/pkg-tmp'
27
+ EOH
28
+ end
@@ -0,0 +1,13 @@
1
+ require 'aruba'
2
+ require 'aruba/cucumber'
3
+ require 'aruba/in_process'
4
+
5
+ require 'omnibus/cli'
6
+
7
+ Before do
8
+ # Reset anything that might have been cached in the Omnibus project
9
+ Omnibus.reset!(true)
10
+
11
+ Aruba::InProcess.main_class = Omnibus::CLI::Runner
12
+ Aruba.process = Aruba::InProcess
13
+ end
@@ -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.
@@ -15,293 +14,373 @@
15
14
  # limitations under the License.
16
15
  #
17
16
 
18
- require 'ohai'
19
- o = Ohai::System.new
20
- o.require_plugin('os')
21
- o.require_plugin('platform')
22
- o.require_plugin('linux/cpu') if o.os == 'linux'
23
- o.require_plugin('kernel')
24
- OHAI = o
25
-
26
- require 'omnibus/library'
27
- require 'omnibus/reports'
28
- require 'omnibus/config'
17
+ require 'pathname'
18
+
29
19
  require 'omnibus/exceptions'
30
- require 'omnibus/software'
31
- require 'omnibus/project'
32
- require 'omnibus/fetchers'
33
- require 'omnibus/health_check'
34
- require 'omnibus/build_version'
35
- require 'omnibus/sugar'
36
- require 'omnibus/overrides'
37
20
  require 'omnibus/version'
38
21
 
39
- require 'pathname'
40
-
41
22
  module Omnibus
42
- DEFAULT_CONFIG_FILENAME = 'omnibus.rb'.freeze
43
-
44
- module Packager
45
- autoload :Base, 'omnibus/packagers/base'
46
- autoload :MacDmg, 'omnibus/packagers/mac_dmg'
47
- autoload :MacPkg, 'omnibus/packagers/mac_pkg'
48
- end
49
-
50
- # Configure Omnibus.
51
23
  #
52
- # After this has been called, the {Omnibus::Config} object is
53
- # available as `Omnibus.config`.
24
+ # The path to the default configuration file.
54
25
  #
55
- # @return [void]
26
+ # @return [String]
56
27
  #
57
- # @deprecated Use {#load_configuration} if you need to process a
58
- # config file, followed by {#process_configuration} to act upon it.
59
- def self.configure
60
- load_configuration
61
- process_configuration
28
+ DEFAULT_CONFIG = 'omnibus.rb'
29
+
30
+ autoload :Artifact, 'omnibus/artifact'
31
+ autoload :Builder, 'omnibus/builder'
32
+ autoload :BuildVersion, 'omnibus/build_version'
33
+ autoload :BuildVersionDSL, 'omnibus/build_version_dsl'
34
+ autoload :Cleaner, 'omnibus/cleaner'
35
+ autoload :Config, 'omnibus/config'
36
+ autoload :Error, 'omnibus/exceptions'
37
+ autoload :Fetcher, 'omnibus/fetcher'
38
+ autoload :Generator, 'omnibus/generator'
39
+ autoload :HealthCheck, 'omnibus/health_check'
40
+ autoload :InstallPathCache, 'omnibus/install_path_cache'
41
+ autoload :Library, 'omnibus/library'
42
+ autoload :Logger, 'omnibus/logger'
43
+ autoload :Logging, 'omnibus/logging'
44
+ autoload :NullBuilder, 'omnibus/null_builder'
45
+ autoload :Ohai, 'omnibus/ohai'
46
+ autoload :Overrides, 'omnibus/overrides'
47
+ autoload :PackageRelease, 'omnibus/package_release'
48
+ autoload :Project, 'omnibus/project'
49
+ autoload :Reports, 'omnibus/reports'
50
+ autoload :S3Cache, 'omnibus/s3_cache'
51
+ autoload :Software, 'omnibus/software'
52
+ autoload :SoftwareS3URLs, 'omnibus/software_s3_urls'
53
+ autoload :Util, 'omnibus/util'
54
+
55
+ # @todo Remove this in the next major release
56
+ autoload :OHAI, 'omnibus/ohai'
57
+
58
+ # @todo Refactor these under a +Fetcher module
59
+ autoload :GitFetcher, 'omnibus/fetchers/git_fetcher'
60
+ autoload :NetFetcher, 'omnibus/fetchers/net_fetcher'
61
+ autoload :PathFetcher, 'omnibus/fetchers/path_fetcher'
62
+ autoload :S3CacheFetcher, 'omnibus/fetchers/s3_cache_fetcher'
63
+
64
+ module Command
65
+ autoload :Base, 'omnibus/cli/base'
66
+ autoload :Cache, 'omnibus/cli/cache'
67
+ autoload :Release, 'omnibus/cli/release'
62
68
  end
63
69
 
64
- # Convenience method for access to the Omnibus::Config object.
65
- # Provided for backward compatibility.
66
- #
67
- # @ return [Omnibus::Config]
68
- #
69
- # @deprecated Just refer to {Omnibus::Config} directly.
70
- def self.config
71
- Config
70
+ module Packager
71
+ autoload :Base, 'omnibus/packagers/base'
72
+ autoload :MacDmg, 'omnibus/packagers/mac_dmg'
73
+ autoload :MacPkg, 'omnibus/packagers/mac_pkg'
74
+ autoload :WindowsMsi, 'omnibus/packagers/windows_msi'
72
75
  end
73
76
 
74
- # Load in an Omnibus configuration file. Values will be merged with
75
- # and override the defaults defined in {Omnibus::Config}.
76
- #
77
- # @param file [String] path to a configuration file to load
78
- #
79
- # @return [void]
80
- def self.load_configuration(file = nil)
81
- if file
82
- Config.from_file(file)
83
- end
84
- end
77
+ class << self
78
+ #
79
+ # Reset the current Omnibus configuration. This is primary an internal API
80
+ # used in testing, but it can also be useful when Omnibus is used as a
81
+ # library.
82
+ #
83
+ # Note - this persists the +Logger+ object by default.
84
+ #
85
+ # @param [true, false] include_logger
86
+ # whether the logger object should be cleared as well
87
+ #
88
+ # @return [void]
89
+ #
90
+ def reset!(include_logger = false)
91
+ instance_variables.each do |instance_variable|
92
+ unless include_logger
93
+ next if instance_variable == :@logger
94
+ end
95
+
96
+ remove_instance_variable(instance_variable)
97
+ end
85
98
 
86
- # Processes the configuration to construct the dependency tree of
87
- # projects and software.
88
- #
89
- # @return [void]
90
- def self.process_configuration
91
- Config.validate
92
- process_dsl_files
93
- end
99
+ Config.reset!
100
+ end
94
101
 
95
- # All {Omnibus::Project} instances that have been created.
96
- #
97
- # @return [Array<Omnibus::Project>]
98
- def self.projects
99
- @projects ||= []
100
- end
102
+ #
103
+ # The logger for this Omnibus instance.
104
+ #
105
+ # @example
106
+ # Omnibus.logger.debug { 'This is a message!' }
107
+ #
108
+ # @return [Logger]
109
+ #
110
+ def logger
111
+ @logger ||= Logger.new
112
+ end
101
113
 
102
- # Names of all the {Omnibus::Project} instances that have been created.
103
- #
104
- # @return [Array<String>]
105
- def self.project_names
106
- projects.map { |p| p.name }
107
- end
114
+ def logger=(logger)
115
+ @logger = logger
116
+ end
108
117
 
109
- # Load the {Omnibus::Project} instance with the given name.
110
- #
111
- # @param name [String]
112
- # @return {Omnibus::Project}
113
- def self.project(name)
114
- projects.find { |p| p.name == name }
115
- end
118
+ def ui
119
+ @ui ||= Thor::Base.shell.new
120
+ end
116
121
 
117
- # The absolute path to the Omnibus project/repository directory.
118
- #
119
- # @return [String]
120
- #
121
- # @deprecated Call {Omnibus::Config.project_root} instead. We need
122
- # to be able to easily tweak this at runtime via the CLI tool.
123
- def self.project_root
124
- Config.project_root
125
- end
122
+ # Configure Omnibus.
123
+ #
124
+ # After this has been called, the {Omnibus::Config} object is
125
+ # available as `Omnibus.config`.
126
+ #
127
+ # @return [void]
128
+ #
129
+ # @deprecated Use {#load_configuration} if you need to process a
130
+ # config file, followed by {#process_configuration} to act upon it.
131
+ def configure
132
+ load_configuration
133
+ process_configuration
134
+ end
126
135
 
127
- # The source root is the path to the root directory of the `omnibus` gem.
128
- #
129
- # @return [Pathname]
130
- def self.source_root
131
- @source_root ||= Pathname.new(File.expand_path('../..', __FILE__))
132
- end
136
+ # Convenience method for access to the Omnibus::Config object.
137
+ # Provided for backward compatibility.
138
+ #
139
+ # @ return [Omnibus::Config]
140
+ #
141
+ # @deprecated Just refer to {Omnibus::Config} directly.
142
+ def config
143
+ Config
144
+ end
133
145
 
134
- # The source root is the path to the root directory of the `omnibus-software`
135
- # gem.
136
- #
137
- # @return [Pathname]
138
- def self.omnibus_software_root
139
- @omnibus_software_root ||= begin
140
- if (spec = Gem::Specification.find_all_by_name(Config.software_gem).first)
141
- Pathname.new(spec.gem_dir)
142
- else
143
- nil
146
+ # Load in an Omnibus configuration file. Values will be merged with
147
+ # and override the defaults defined in {Omnibus::Config}.
148
+ #
149
+ # @param file [String] path to a configuration file to load
150
+ #
151
+ # @return [void]
152
+ def load_configuration(file = nil)
153
+ if file
154
+ Config.from_file(file)
144
155
  end
145
156
  end
146
- end
147
157
 
148
- # Return paths to all configured {Omnibus::Project} DSL files.
149
- #
150
- # @return [Array<String>]
151
- def self.project_files
152
- ruby_files(File.join(project_root, Config.project_dir))
153
- end
158
+ # Processes the configuration to construct the dependency tree of
159
+ # projects and software.
160
+ #
161
+ # @return [void]
162
+ def process_configuration
163
+ Config.validate
164
+ process_dsl_files
165
+ end
154
166
 
155
- # Return paths to all configured {Omnibus::Software} DSL files.
156
- #
157
- # @return [Array<String>]
158
- def self.software_files
159
- ruby_files(File.join(project_root, Config.software_dir))
160
- end
167
+ # All {Omnibus::Project} instances that have been created.
168
+ #
169
+ # @return [Array<Omnibus::Project>]
170
+ def projects
171
+ @projects ||= []
172
+ end
161
173
 
162
- # Return directories to search for {Omnibus::Software} DSL files.
163
- #
164
- # @return [Array<String>]
165
- def self.software_dirs
166
- @software_dirs ||= begin
167
- software_dirs = [File.join(project_root, Config.software_dir)]
168
- software_dirs << File.join(omnibus_software_root, 'config', 'software') if omnibus_software_root
169
- software_dirs
174
+ # Names of all the {Omnibus::Project} instances that have been created.
175
+ #
176
+ # @return [Array<String>]
177
+ def project_names
178
+ projects.map { |p| p.name }
170
179
  end
171
- end
172
180
 
173
- # Backward compat alias
174
- #
175
- # @todo print a deprecation message
176
- class << self
177
- alias_method :root, :project_root
178
- end
181
+ # Load the {Omnibus::Project} instance with the given name.
182
+ #
183
+ # @param name [String]
184
+ # @return {Omnibus::Project}
185
+ def project(name)
186
+ projects.find { |p| p.name == name }
187
+ end
179
188
 
180
- private
189
+ # The absolute path to the Omnibus project/repository directory.
190
+ #
191
+ # @return [String]
192
+ def project_root
193
+ Config.project_root
194
+ end
181
195
 
182
- # Generates {Omnibus::Project}s for each project DSL file in
183
- # `project_specs`. All projects are then accessible at
184
- # {Omnibus#projects}
185
- #
186
- # @return [void]
187
- #
188
- # @see Omnibus::Project
189
- def self.expand_projects
190
- project_files.each do |spec|
191
- Omnibus.projects << Omnibus::Project.load(spec)
196
+ # The source root is the path to the root directory of the `omnibus` gem.
197
+ #
198
+ # @return [Pathname]
199
+ def source_root
200
+ @source_root ||= Pathname.new(File.expand_path('../..', __FILE__))
192
201
  end
193
- end
194
202
 
195
- # Generate {Omnibus::Software} objects for all software DSL files in
196
- # `software_specs`.
197
- #
198
- # @param overrides [Hash] a hash of version override information.
199
- # @param software_files [Array<String>]
200
- # @return [void]
201
- #
202
- # @see Omnibus::Overrides#overrides
203
- def self.expand_software(overrides, software_map)
204
- unless overrides.is_a? Hash
205
- fail ArgumentError, "Overrides argument must be a hash! You passed #{overrides.inspect}."
203
+ # The source root is the path to the root directory of the `omnibus-software`
204
+ # gem.
205
+ #
206
+ # @return [Pathname]
207
+ def omnibus_software_root
208
+ @omnibus_software_root ||= begin
209
+ if (spec = Gem::Specification.find_all_by_name(Config.software_gem).first)
210
+ Pathname.new(spec.gem_dir)
211
+ else
212
+ nil
213
+ end
214
+ end
215
+ end
216
+
217
+ # Return paths to all configured {Omnibus::Project} DSL files.
218
+ #
219
+ # @return [Array<String>]
220
+ def project_files
221
+ ruby_files(File.join(project_root, Config.project_dir))
206
222
  end
207
223
 
208
- Omnibus.projects.each do |project|
209
- project.dependencies.each do |dependency|
210
- recursively_load_dependency(dependency, project, overrides, software_map)
224
+ # Return paths to all configured {Omnibus::Software} DSL files.
225
+ #
226
+ # @return [Array<String>]
227
+ def software_files
228
+ ruby_files(File.join(project_root, Config.software_dir))
229
+ end
230
+
231
+ # Return directories to search for {Omnibus::Software} DSL files.
232
+ #
233
+ # @return [Array<String>]
234
+ def software_dirs
235
+ @software_dirs ||= begin
236
+ software_dirs = [File.join(project_root, Config.software_dir)]
237
+ software_dirs << File.join(omnibus_software_root, 'config', 'software') if omnibus_software_root
238
+ software_dirs
211
239
  end
212
240
  end
213
- end
214
241
 
215
- # Processes all configured {Omnibus::Project} and
216
- # {Omnibus::Software} DSL files.
217
- #
218
- # @return [void]
219
- def self.process_dsl_files
220
- # Do projects first
221
- expand_projects
242
+ # Backward compat alias
243
+ #
244
+ # @todo Remve this in the next major release (4.0)
245
+ #
246
+ # @see (Omnibus.project_root)
247
+ def root
248
+ Omnibus.logger.deprecated('Omnibus') do
249
+ 'Omnibus.root. Please use Omnibus.project_root instead.'
250
+ end
222
251
 
223
- # Then do software
224
- final_software_map = prefer_local_software(omnibus_software_files, software_files)
252
+ project_root
253
+ end
225
254
 
226
- overrides = Config.override_file ? Omnibus::Overrides.overrides : {}
255
+ # Processes all configured {Omnibus::Project} and
256
+ # {Omnibus::Software} DSL files.
257
+ #
258
+ # @return [void]
259
+ def process_dsl_files
260
+ # Do projects first
261
+ expand_projects
227
262
 
228
- expand_software(overrides, final_software_map)
229
- end
263
+ # Then do software
264
+ final_software_map = prefer_local_software(omnibus_software_files, software_files)
230
265
 
231
- # Return a list of all the Ruby files (i.e., those with an "rb"
232
- # extension) in the given directory
233
- #
234
- # @param dir [String]
235
- # @return [Array<String>]
236
- def self.ruby_files(dir)
237
- Dir.glob("#{dir}/*.rb")
238
- end
266
+ overrides = Config.override_file ? Omnibus::Overrides.overrides : {}
239
267
 
240
- # Retrieve the fully-qualified paths to every software definition
241
- # file bundled in the {https://github.com/opscode/omnibus-software omnibus-software} gem.
242
- #
243
- # @return [Array<String>] the list of paths. Will be empty if the
244
- # `omnibus-software` gem is not in the gem path.
245
- def self.omnibus_software_files
246
- if omnibus_software_root
247
- Dir.glob(File.join(omnibus_software_root, 'config', 'software', '*.rb'))
248
- else
249
- []
268
+ expand_software(overrides, final_software_map)
250
269
  end
251
- end
252
270
 
253
- # Given a list of software definitions from `omnibus-software` itself, and a
254
- # list of software files local to the current project, create a
255
- # single list of software definitions. If the software was defined
256
- # in both sets, the locally-defined one ends up in the final list.
257
- #
258
- # The base name of the software file determines what software it
259
- # defines.
260
- #
261
- # @param omnibus_files [Array<String>]
262
- # @param local_files [Array<String>]
263
- # @return [Array<String>]
264
- def self.prefer_local_software(omnibus_files, local_files)
265
- base = software_map(omnibus_files)
266
- local = software_map(local_files)
267
- base.merge(local)
268
- end
271
+ private
272
+
273
+ # Generates {Omnibus::Project}s for each project DSL file in
274
+ # `project_specs`. All projects are then accessible at
275
+ # {Omnibus#projects}
276
+ #
277
+ # @return [void]
278
+ #
279
+ # @see Omnibus::Project
280
+ def expand_projects
281
+ project_files.each do |spec|
282
+ Omnibus.projects << Omnibus::Project.load(spec)
283
+ end
284
+ end
269
285
 
270
- # Given a list of file paths, create a map of the basename (without
271
- # extension) to the complete path.
272
- #
273
- # @param files [Array<String>]
274
- # @return [Hash<String, String>]
275
- def self.software_map(files)
276
- files.each_with_object({}) do |file, collection|
277
- software_name = File.basename(file, '.*')
278
- collection[software_name] = file
286
+ # Generate {Omnibus::Software} objects for all software DSL files in
287
+ # `software_specs`.
288
+ #
289
+ # @param overrides [Hash] a hash of version override information.
290
+ # @param software_files [Array<String>]
291
+ # @return [void]
292
+ #
293
+ # @see Omnibus::Overrides#overrides
294
+ def expand_software(overrides, software_map)
295
+ unless overrides.is_a? Hash
296
+ raise ArgumentError, "Overrides argument must be a hash! You passed #{overrides.inspect}."
297
+ end
298
+
299
+ Omnibus.projects.each do |project|
300
+ project.dependencies.each do |dependency|
301
+ recursively_load_dependency(dependency, project, overrides, software_map)
302
+ end
303
+ end
279
304
  end
280
- end
281
305
 
282
- # Loads a project's dependency recursively, ensuring all transitive dependencies
283
- # are also loaded.
284
- #
285
- # @param dependency_name [String]
286
- # @param project [Omnibus::Project]
287
- # @param overrides [Hash] a hash of version override information.
288
- # @param software_map [Hash<String, String>]
289
- #
290
- # @return [void]
291
- def self.recursively_load_dependency(dependency_name, project, overrides, software_map)
292
- dep_file = software_map[dependency_name]
306
+ # Return a list of all the Ruby files (i.e., those with an "rb"
307
+ # extension) in the given directory
308
+ #
309
+ # @param dir [String]
310
+ # @return [Array<String>]
311
+ def ruby_files(dir)
312
+ Dir.glob("#{dir}/*.rb")
313
+ end
293
314
 
294
- unless dep_file
295
- fail MissingProjectDependency.new(dependency_name, software_dirs)
315
+ # Retrieve the fully-qualified paths to every software definition
316
+ # file bundled in the {https://github.com/opscode/omnibus-software omnibus-software} gem.
317
+ #
318
+ # @return [Array<String>] the list of paths. Will be empty if the
319
+ # `omnibus-software` gem is not in the gem path.
320
+ def omnibus_software_files
321
+ if omnibus_software_root
322
+ Dir.glob(File.join(omnibus_software_root, 'config', 'software', '*.rb'))
323
+ else
324
+ []
325
+ end
296
326
  end
297
327
 
298
- dep_software = Omnibus::Software.load(dep_file, project, overrides)
328
+ # Given a list of software definitions from `omnibus-software` itself, and a
329
+ # list of software files local to the current project, create a
330
+ # single list of software definitions. If the software was defined
331
+ # in both sets, the locally-defined one ends up in the final list.
332
+ #
333
+ # The base name of the software file determines what software it
334
+ # defines.
335
+ #
336
+ # @param omnibus_files [Array<String>]
337
+ # @param local_files [Array<String>]
338
+ # @return [Array<String>]
339
+ def prefer_local_software(omnibus_files, local_files)
340
+ base = software_map(omnibus_files)
341
+ local = software_map(local_files)
342
+ base.merge(local)
343
+ end
299
344
 
300
- # load any transitive deps for the component into the library also
301
- dep_software.dependencies.each do |dep|
302
- recursively_load_dependency(dep, project, overrides, software_map)
345
+ # Given a list of file paths, create a map of the basename (without
346
+ # extension) to the complete path.
347
+ #
348
+ # @param files [Array<String>]
349
+ # @return [Hash<String, String>]
350
+ def software_map(files)
351
+ files.each_with_object({}) do |file, collection|
352
+ software_name = File.basename(file, '.*')
353
+ collection[software_name] = file
354
+ end
303
355
  end
304
356
 
305
- project.library.component_added(dep_software)
357
+ # Loads a project's dependency recursively, ensuring all transitive dependencies
358
+ # are also loaded.
359
+ #
360
+ # @param dependency_name [String]
361
+ # @param project [Omnibus::Project]
362
+ # @param overrides [Hash] a hash of version override information.
363
+ # @param software_map [Hash<String, String>]
364
+ #
365
+ # @return [void]
366
+ def recursively_load_dependency(dependency_name, project, overrides, software_map)
367
+ dep_file = software_map[dependency_name]
368
+
369
+ unless dep_file
370
+ raise MissingProjectDependency.new(dependency_name, software_dirs)
371
+ end
372
+
373
+ dep_software = Omnibus::Software.load(dep_file, project, overrides)
374
+
375
+ # load any transitive deps for the component into the library also
376
+ dep_software.dependencies.each do |dep|
377
+ recursively_load_dependency(dep, project, overrides, software_map)
378
+ end
379
+
380
+ project.library.component_added(dep_software)
381
+ end
306
382
  end
307
383
  end
384
+
385
+ # Sugars must be loaded after everything else has been registered
386
+ require 'omnibus/sugar'