omnibus 3.2.2 → 4.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (302) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +140 -10
  3. data/CHANGELOG.md +181 -8
  4. data/README.md +63 -35
  5. data/Rakefile +1 -1
  6. data/docs/omnibus-build-cache.md b/data/docs/Build → Cache.md +0 -0
  7. data/docs/Building on Debian.md +59 -0
  8. data/docs/Building on OSX.md +61 -35
  9. data/docs/Building on RHEL.md +74 -0
  10. data/docs/Building on Windows.md +40 -81
  11. data/features/commands/build.feature +1 -2
  12. data/features/commands/clean.feature +1 -1
  13. data/lib/omnibus.rb +111 -204
  14. data/lib/omnibus/build_version.rb +3 -20
  15. data/lib/omnibus/build_version_dsl.rb +2 -3
  16. data/lib/omnibus/builder.rb +103 -211
  17. data/lib/omnibus/cleaner.rb +5 -7
  18. data/lib/omnibus/cli.rb +1 -4
  19. data/lib/omnibus/cli/base.rb +9 -16
  20. data/lib/omnibus/compressor.rb +60 -0
  21. data/{spec/data/complicated/config/software/version-manifest.rb → lib/omnibus/compressors/base.rb} +17 -12
  22. data/lib/omnibus/compressors/dmg.rb +312 -0
  23. data/lib/omnibus/{null_builder.rb → compressors/null.rb} +10 -4
  24. data/lib/omnibus/compressors/tgz.rb +141 -0
  25. data/lib/omnibus/config.rb +89 -83
  26. data/lib/omnibus/core_extensions.rb +1 -0
  27. data/lib/omnibus/core_extensions/open_uri.rb +58 -0
  28. data/lib/omnibus/digestable.rb +9 -3
  29. data/lib/omnibus/exceptions.rb +116 -175
  30. data/lib/omnibus/fetcher.rb +97 -138
  31. data/lib/omnibus/fetchers/git_fetcher.rb +130 -165
  32. data/lib/omnibus/fetchers/net_fetcher.rb +205 -164
  33. data/lib/omnibus/fetchers/{s3_cache_fetcher.rb → null_fetcher.rb} +27 -17
  34. data/lib/omnibus/fetchers/path_fetcher.rb +74 -32
  35. data/lib/omnibus/file_syncer.rb +149 -0
  36. data/lib/omnibus/generator.rb +103 -32
  37. data/lib/omnibus/generator_files/.kitchen.yml.erb +5 -1
  38. data/lib/omnibus/generator_files/Gemfile.erb +13 -7
  39. data/lib/omnibus/generator_files/config/projects/project.rb.erb +28 -0
  40. data/lib/omnibus/generator_files/config/software/zlib.rb.erb +55 -0
  41. data/lib/omnibus/generator_files/omnibus.rb.erb +5 -7
  42. data/lib/omnibus/git_cache.rb +11 -13
  43. data/lib/omnibus/logger.rb +76 -22
  44. data/lib/omnibus/logging.rb +1 -1
  45. data/lib/omnibus/metadata.rb +264 -0
  46. data/lib/omnibus/ohai.rb +0 -51
  47. data/lib/omnibus/package.rb +4 -228
  48. data/lib/omnibus/packager.rb +71 -0
  49. data/lib/omnibus/packagers/base.rb +118 -176
  50. data/lib/omnibus/packagers/bff.rb +136 -0
  51. data/lib/omnibus/packagers/deb.rb +389 -0
  52. data/lib/omnibus/packagers/makeself.rb +114 -0
  53. data/lib/omnibus/packagers/msi.rb +346 -0
  54. data/lib/omnibus/packagers/pkg.rb +278 -0
  55. data/lib/omnibus/packagers/rpm.rb +438 -0
  56. data/lib/omnibus/packagers/solaris.rb +110 -0
  57. data/lib/omnibus/project.rb +263 -666
  58. data/lib/omnibus/publisher.rb +3 -3
  59. data/lib/omnibus/s3_cache.rb +21 -30
  60. data/lib/omnibus/software.rb +132 -271
  61. data/lib/omnibus/templating.rb +66 -0
  62. data/lib/omnibus/thread_pool.rb +109 -0
  63. data/lib/omnibus/util.rb +137 -15
  64. data/lib/omnibus/version.rb +1 -1
  65. data/omnibus.gemspec +2 -2
  66. data/resources/bff/gen.template.erb +22 -0
  67. data/resources/bff/postinstall.sh +0 -0
  68. data/resources/bff/unpostinstall.sh +0 -0
  69. data/resources/deb/conffiles.erb +3 -0
  70. data/resources/deb/control.erb +25 -0
  71. data/resources/deb/md5sums.erb +3 -0
  72. data/{lib/omnibus/generator_files/mac_dmg → resources/dmg}/background.png +0 -0
  73. data/resources/dmg/create_dmg.osascript.erb +17 -0
  74. data/{lib/omnibus/generator_files/mac_dmg → resources/dmg}/icon.png +0 -0
  75. data/{bin → resources/makeself}/makeself-header.sh +0 -0
  76. data/{bin → resources/makeself}/makeself.sh +0 -0
  77. data/{lib/omnibus/generator_files/package_scripts/makeselfinst.erb → resources/makeself/post_extract.sh.erb} +4 -4
  78. data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/LICENSE.rtf +0 -0
  79. data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/banner_background.bmp +0 -0
  80. data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/dialog_background.bmp +0 -0
  81. data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/project.ico +0 -0
  82. data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/project_16x16.ico +0 -0
  83. data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/project_32x32.ico +0 -0
  84. data/{spec/fixtures/sample/files/windows_msi/Resources/localization-en-us.wxl → resources/msi/localization-en-us.wxl.erb} +3 -4
  85. data/resources/msi/parameters.wxi.erb +9 -0
  86. data/{lib/omnibus/generator_files/windows_msi → resources/msi}/source.wxs.erb +14 -15
  87. data/{lib/omnibus/generator_files/mac_pkg → resources/pkg}/background.png +0 -0
  88. data/resources/pkg/distribution.xml.erb +21 -0
  89. data/resources/pkg/license.html.erb +3 -0
  90. data/resources/pkg/welcome.html.erb +7 -0
  91. data/resources/rpm/rpmmacros.erb +3 -0
  92. data/resources/rpm/signing.erb +40 -0
  93. data/resources/rpm/spec.erb +70 -0
  94. data/spec/functional/builder_spec.rb +90 -111
  95. data/spec/functional/fetchers/git_fetcher_spec.rb +130 -0
  96. data/spec/functional/fetchers/net_fetcher_spec.rb +110 -0
  97. data/spec/functional/fetchers/path_fetcher_spec.rb +97 -0
  98. data/spec/functional/file_syncer_spec.rb +206 -0
  99. data/spec/functional/templating_spec.rb +73 -0
  100. data/spec/spec_helper.rb +31 -94
  101. data/spec/support/env_helpers.rb +20 -0
  102. data/spec/support/examples.rb +56 -0
  103. data/spec/support/file_helpers.rb +46 -0
  104. data/spec/support/git_helpers.rb +107 -0
  105. data/spec/support/logging_helpers.rb +33 -0
  106. data/spec/support/matchers.rb +36 -0
  107. data/spec/support/ohai_helpers.rb +22 -0
  108. data/spec/support/path_helpers.rb +19 -0
  109. data/spec/support/shell_helpers.rb +14 -0
  110. data/spec/unit/build_version_dsl_spec.rb +0 -17
  111. data/spec/unit/build_version_spec.rb +1 -19
  112. data/spec/unit/builder_spec.rb +158 -46
  113. data/spec/unit/compressor_spec.rb +45 -0
  114. data/spec/unit/compressors/base_spec.rb +26 -0
  115. data/spec/unit/compressors/dmg_spec.rb +291 -0
  116. data/spec/unit/compressors/null_spec.rb +23 -0
  117. data/spec/unit/compressors/tgz_spec.rb +67 -0
  118. data/spec/unit/config_spec.rb +27 -34
  119. data/spec/unit/digestable_spec.rb +4 -4
  120. data/spec/unit/fetchers/git_fetcher_spec.rb +110 -39
  121. data/spec/unit/fetchers/net_fetcher_spec.rb +182 -72
  122. data/spec/unit/fetchers/path_fetcher_spec.rb +111 -0
  123. data/spec/unit/generator_spec.rb +137 -0
  124. data/spec/unit/git_cache_spec.rb +24 -34
  125. data/spec/unit/library_spec.rb +21 -82
  126. data/spec/unit/metadata_spec.rb +207 -0
  127. data/spec/unit/ohai_spec.rb +0 -7
  128. data/spec/unit/omnibus_spec.rb +41 -36
  129. data/spec/unit/package_spec.rb +1 -216
  130. data/spec/unit/packagers/base_spec.rb +76 -190
  131. data/spec/unit/packagers/bff_spec.rb +160 -0
  132. data/spec/unit/packagers/deb_spec.rb +324 -0
  133. data/spec/unit/packagers/makeself_spec.rb +80 -0
  134. data/spec/unit/packagers/msi_spec.rb +267 -0
  135. data/spec/unit/packagers/pkg_spec.rb +219 -0
  136. data/spec/unit/packagers/rpm_spec.rb +328 -0
  137. data/spec/unit/project_spec.rb +217 -80
  138. data/spec/unit/publisher_spec.rb +6 -2
  139. data/spec/unit/publishers/artifactory_publisher_spec.rb +1 -1
  140. data/spec/unit/publishers/s3_publisher_spec.rb +1 -1
  141. data/spec/unit/s3_cacher_spec.rb +22 -5
  142. data/spec/unit/software_spec.rb +89 -232
  143. data/spec/unit/util_spec.rb +188 -0
  144. metadata +159 -402
  145. data/features/commands/_deprecated.feature +0 -84
  146. data/lib/omnibus/cleanroom.rb +0 -141
  147. data/lib/omnibus/cli/deprecated.rb +0 -132
  148. data/lib/omnibus/generator_files/mac_pkg/license.html.erb +0 -1
  149. data/lib/omnibus/generator_files/mac_pkg/welcome.html.erb +0 -9
  150. data/lib/omnibus/generator_files/project.rb.erb +0 -20
  151. data/lib/omnibus/generator_files/software/c-example.rb.erb +0 -42
  152. data/lib/omnibus/generator_files/software/erlang-example.rb.erb +0 -38
  153. data/lib/omnibus/generator_files/software/ruby-example.rb.erb +0 -24
  154. data/lib/omnibus/generator_files/windows_msi/localization-en-us.wxl.erb +0 -20
  155. data/lib/omnibus/generator_files/windows_msi/parameters.wxi.erb +0 -9
  156. data/lib/omnibus/packagers/mac_dmg.rb +0 -235
  157. data/lib/omnibus/packagers/mac_pkg.rb +0 -176
  158. data/lib/omnibus/packagers/windows_msi.rb +0 -109
  159. data/spec/data/complicated/config/patches/bzip2/makefile_take_env_vars.patch +0 -15
  160. data/spec/data/complicated/config/patches/couchdb/patch_for_couchjs_stack.patch +0 -19
  161. data/spec/data/complicated/config/patches/gd/gd-2.0.33-configure-libpng.patch +0 -100
  162. data/spec/data/complicated/config/patches/keepalived/keepalived-1.2.9_opscode_centos_5.patch +0 -15
  163. data/spec/data/complicated/config/patches/libedit/freebsd-vi-fix.patch +0 -24
  164. data/spec/data/complicated/config/patches/libiconv/libiconv-1.14_srclib_stdio.in.h-remove-gets-declarations.patch +0 -29
  165. data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-makefile-dest-fix.patch +0 -35
  166. data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-malloc-fix.patch +0 -13
  167. data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-shared_lib_plus_plus-1.patch +0 -1035
  168. data/spec/data/complicated/config/patches/logrotate/logrotate_basedir_override.patch +0 -12
  169. data/spec/data/complicated/config/patches/ncurses/ncurses-5.9-solaris-xopen_source_extended-detection.patch +0 -11
  170. data/spec/data/complicated/config/patches/ncurses/ncurses-clang.patch +0 -42
  171. data/spec/data/complicated/config/patches/ncurses/patch-aa +0 -23
  172. data/spec/data/complicated/config/patches/ncurses/patch-ab +0 -44
  173. data/spec/data/complicated/config/patches/ncurses/patch-ac +0 -40
  174. data/spec/data/complicated/config/patches/ncurses/patch-ad +0 -12
  175. data/spec/data/complicated/config/patches/ncurses/patch-aix-configure +0 -23
  176. data/spec/data/complicated/config/patches/ncurses/patch-cxx_cursesf.h +0 -22
  177. data/spec/data/complicated/config/patches/ncurses/patch-cxx_cursesm.h +0 -22
  178. data/spec/data/complicated/config/patches/nrpe/fix_for_runit.patch +0 -64
  179. data/spec/data/complicated/config/patches/openssl/openssl-1.0.1f-do-not-build-docs.patch +0 -101
  180. data/spec/data/complicated/config/patches/postgresql/postgresql-9.1.2-configure-ncurses-fix.patch +0 -12
  181. data/spec/data/complicated/config/patches/ruby/patch-configure +0 -103
  182. data/spec/data/complicated/config/patches/ruby/ruby-aix-configure.patch +0 -10
  183. data/spec/data/complicated/config/patches/ruby/ruby-openssl-1.0.1c.patch +0 -42
  184. data/spec/data/complicated/config/patches/ruby/ruby_aix_1_9_3_448_ssl_EAGAIN.patch +0 -57
  185. data/spec/data/complicated/config/patches/ruby/rvm-cflags.patch +0 -27
  186. data/spec/data/complicated/config/projects/angrychef.rb +0 -32
  187. data/spec/data/complicated/config/projects/chef-windows.rb +0 -32
  188. data/spec/data/complicated/config/projects/chef.rb +0 -32
  189. data/spec/data/complicated/config/projects/chefdk-windows.rb +0 -41
  190. data/spec/data/complicated/config/projects/chefdk.rb +0 -44
  191. data/spec/data/complicated/config/software/appbundler.rb +0 -25
  192. data/spec/data/complicated/config/software/autoconf.rb +0 -35
  193. data/spec/data/complicated/config/software/automake.rb +0 -39
  194. data/spec/data/complicated/config/software/berkshelf.rb +0 -44
  195. data/spec/data/complicated/config/software/bundler.rb +0 -25
  196. data/spec/data/complicated/config/software/bzip2.rb +0 -46
  197. data/spec/data/complicated/config/software/cacerts.rb +0 -44
  198. data/spec/data/complicated/config/software/chef-client-msi.rb +0 -87
  199. data/spec/data/complicated/config/software/chef-gem.rb +0 -26
  200. data/spec/data/complicated/config/software/chef-vault.rb +0 -43
  201. data/spec/data/complicated/config/software/chef-windows.rb +0 -158
  202. data/spec/data/complicated/config/software/chef.rb +0 -170
  203. data/spec/data/complicated/config/software/chefdk.rb +0 -103
  204. data/spec/data/complicated/config/software/couchdb.rb +0 -53
  205. data/spec/data/complicated/config/software/curl.rb +0 -48
  206. data/spec/data/complicated/config/software/erlang.rb +0 -65
  207. data/spec/data/complicated/config/software/expat.rb +0 -21
  208. data/spec/data/complicated/config/software/fcgi.rb +0 -56
  209. data/spec/data/complicated/config/software/fcgiwrap.rb +0 -41
  210. data/spec/data/complicated/config/software/gd.rb +0 -56
  211. data/spec/data/complicated/config/software/gdbm.rb +0 -40
  212. data/spec/data/complicated/config/software/gecode.rb +0 -48
  213. data/spec/data/complicated/config/software/git.rb +0 -40
  214. data/spec/data/complicated/config/software/help2man.rb +0 -30
  215. data/spec/data/complicated/config/software/icu.rb +0 -40
  216. data/spec/data/complicated/config/software/jre.rb +0 -48
  217. data/spec/data/complicated/config/software/keepalived.rb +0 -43
  218. data/spec/data/complicated/config/software/libarchive.rb +0 -50
  219. data/spec/data/complicated/config/software/libedit.rb +0 -69
  220. data/spec/data/complicated/config/software/libffi.rb +0 -71
  221. data/spec/data/complicated/config/software/libgcc.rb +0 -39
  222. data/spec/data/complicated/config/software/libiconv.rb +0 -55
  223. data/spec/data/complicated/config/software/libjpeg.rb +0 -39
  224. data/spec/data/complicated/config/software/libpng.rb +0 -38
  225. data/spec/data/complicated/config/software/libtool.rb +0 -52
  226. data/spec/data/complicated/config/software/libwrap.rb +0 -50
  227. data/spec/data/complicated/config/software/libxml2.rb +0 -51
  228. data/spec/data/complicated/config/software/libxslt.rb +0 -52
  229. data/spec/data/complicated/config/software/libyaml-windows.rb +0 -43
  230. data/spec/data/complicated/config/software/libyaml.rb +0 -62
  231. data/spec/data/complicated/config/software/logrotate.rb +0 -41
  232. data/spec/data/complicated/config/software/makedepend.rb +0 -73
  233. data/spec/data/complicated/config/software/mysql2.rb +0 -42
  234. data/spec/data/complicated/config/software/nagios-plugins.rb +0 -53
  235. data/spec/data/complicated/config/software/nagios.rb +0 -66
  236. data/spec/data/complicated/config/software/ncurses.rb +0 -149
  237. data/spec/data/complicated/config/software/nginx.rb +0 -40
  238. data/spec/data/complicated/config/software/nodejs.rb +0 -44
  239. data/spec/data/complicated/config/software/nokogiri.rb +0 -55
  240. data/spec/data/complicated/config/software/nrpe.rb +0 -61
  241. data/spec/data/complicated/config/software/ohai.rb +0 -64
  242. data/spec/data/complicated/config/software/omnibus-ctl.rb +0 -34
  243. data/spec/data/complicated/config/software/openresty.rb +0 -67
  244. data/spec/data/complicated/config/software/openssl.rb +0 -158
  245. data/spec/data/complicated/config/software/pcre.rb +0 -42
  246. data/spec/data/complicated/config/software/perl-extutils-embed.rb +0 -15
  247. data/spec/data/complicated/config/software/perl-extutils-makemaker.rb +0 -15
  248. data/spec/data/complicated/config/software/perl.rb +0 -48
  249. data/spec/data/complicated/config/software/perl_pg_driver.rb +0 -12
  250. data/spec/data/complicated/config/software/php.rb +0 -41
  251. data/spec/data/complicated/config/software/pip.rb +0 -30
  252. data/spec/data/complicated/config/software/pkg-config.rb +0 -66
  253. data/spec/data/complicated/config/software/popt.rb +0 -47
  254. data/spec/data/complicated/config/software/postgresql.rb +0 -51
  255. data/spec/data/complicated/config/software/preparation.rb +0 -30
  256. data/spec/data/complicated/config/software/pygments.rb +0 -25
  257. data/spec/data/complicated/config/software/python.rb +0 -49
  258. data/spec/data/complicated/config/software/rabbitmq.rb +0 -36
  259. data/spec/data/complicated/config/software/rebar.rb +0 -36
  260. data/spec/data/complicated/config/software/redis.rb +0 -33
  261. data/spec/data/complicated/config/software/rsync.rb +0 -48
  262. data/spec/data/complicated/config/software/ruby-windows-devkit.rb +0 -30
  263. data/spec/data/complicated/config/software/ruby-windows.rb +0 -30
  264. data/spec/data/complicated/config/software/ruby.rb +0 -162
  265. data/spec/data/complicated/config/software/rubygems-customization.rb +0 -57
  266. data/spec/data/complicated/config/software/rubygems.rb +0 -37
  267. data/spec/data/complicated/config/software/runit.rb +0 -118
  268. data/spec/data/complicated/config/software/server-jre.rb +0 -46
  269. data/spec/data/complicated/config/software/setuptools.rb +0 -30
  270. data/spec/data/complicated/config/software/spawn-fcgi.rb +0 -40
  271. data/spec/data/complicated/config/software/sphinx.rb +0 -26
  272. data/spec/data/complicated/config/software/spidermonkey.rb +0 -60
  273. data/spec/data/complicated/config/software/sqitch.rb +0 -24
  274. data/spec/data/complicated/config/software/test-kitchen.rb +0 -39
  275. data/spec/data/complicated/config/software/unicorn.rb +0 -27
  276. data/spec/data/complicated/config/software/util-macros.rb +0 -46
  277. data/spec/data/complicated/config/software/xproto.rb +0 -46
  278. data/spec/data/complicated/config/software/yajl.rb +0 -30
  279. data/spec/data/complicated/config/software/zlib.rb +0 -67
  280. data/spec/data/overrides/bad_line.overrides +0 -3
  281. data/spec/data/overrides/good.overrides +0 -5
  282. data/spec/data/overrides/with_dupes.overrides +0 -4
  283. data/spec/data/projects/chefdk.rb +0 -41
  284. data/spec/data/projects/sample.rb +0 -13
  285. data/spec/data/software/erchef.rb +0 -42
  286. data/spec/data/software/zlib.rb +0 -67
  287. data/spec/fixtures/sample/files/mac_dmg/Resources/background.png +0 -0
  288. data/spec/fixtures/sample/files/mac_dmg/Resources/icon.png +0 -0
  289. data/spec/fixtures/sample/files/mac_pkg/Resources/background.png +0 -0
  290. data/spec/fixtures/sample/files/mac_pkg/Resources/license.html +0 -1
  291. data/spec/fixtures/sample/files/mac_pkg/Resources/welcome.html +0 -9
  292. data/spec/fixtures/sample/files/windows_msi/Resources/assets/LICENSE.rtf +0 -8
  293. data/spec/fixtures/sample/files/windows_msi/Resources/assets/banner_background.bmp +0 -0
  294. data/spec/fixtures/sample/files/windows_msi/Resources/assets/dialog_background.bmp +0 -0
  295. data/spec/fixtures/sample/files/windows_msi/Resources/assets/project.ico +0 -0
  296. data/spec/fixtures/sample/files/windows_msi/Resources/assets/project_16x16.ico +0 -0
  297. data/spec/fixtures/sample/files/windows_msi/Resources/assets/project_32x32.ico +0 -0
  298. data/spec/fixtures/sample/files/windows_msi/Resources/parameters.wxi.erb +0 -9
  299. data/spec/fixtures/sample/files/windows_msi/Resources/source.wxs +0 -74
  300. data/spec/integration/packagers/mac_spec.rb +0 -58
  301. data/spec/integration/packagers/windows_spec.rb +0 -70
  302. data/spec/unit/packagers/mac_pkg_spec.rb +0 -151
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'bundler/gem_tasks'
2
2
 
3
3
  require 'rspec/core/rake_task'
4
- [:unit, :functional, :integration].each do |type|
4
+ [:unit, :functional].each do |type|
5
5
  RSpec::Core::RakeTask.new(type) do |t|
6
6
  t.pattern = "spec/#{type}/**/*_spec.rb"
7
7
  t.rspec_opts = [].tap do |a|
@@ -0,0 +1,59 @@
1
+ Building Omnibus Packages for Debian
2
+ ====================================
3
+ This document details the steps and configurables for building DEB packages with Omnibus.
4
+
5
+
6
+ Building a .deb
7
+ ---------------
8
+ ### Requirements
9
+ Omnibus assumes the existence of the `fakeroot` and `dpkg-deb` command on the build system. The [omnibus cookbook](https://supermarket.getchef.com/cookbooks/omnibus) automatically handles this installation. If you are not using the Omnibus cookbook, you must install these packages manually or using another tool.
10
+
11
+ ### Configurables
12
+ A number of project configuration values are taken into consideration for building Debian packages. These options are further described in the [`Project` documentation](http://rubydoc.info/github/opscode/omnibus/Omnibus/Project).
13
+
14
+ These values are interpolated and evaluated using Omnibus' internal DEB templates. For 99% of users, these templates should be satisfactory. If you encounter an instance where Omnibus' ERB templates do not satisfy a use case, please open an issue.
15
+
16
+ Because of the unlikelihood of their necessity, Omnibus does not generate deb-related assets. If you find yourself in a situation where you need to generate highly-customized DEB assets, run the Omnibus generator command with the `--deb-assets` flag:
17
+
18
+ $ omnibus generate NAME --deb-assets
19
+
20
+ **If this is an existing project, be sure to answer "NO" when asked if you want to overwrite existing files!**
21
+
22
+ With the `--deb-assets` flag, Omnibus will generate the following "stock" resources in `resources/NAME/deb`:
23
+
24
+ - `conffiles.erb` - the list of configuration files
25
+ - `control.erb` - the Debian spec file
26
+ - `md5sums.erb` - the ERB for generating the list of file checksums
27
+
28
+ **You should only generate the DEB assets if you cannot set values using attributes!**
29
+
30
+ ### DSL
31
+ You can further customize the behavior of the packager using the `package` DSL command in your project definition:
32
+
33
+ ```ruby
34
+ # project.rb
35
+ name 'hamlet'
36
+
37
+ package :deb do
38
+ vendor 'Company <company@example.com>'
39
+ license 'Apache 2.0'
40
+ priority 'extra'
41
+ section 'databases'
42
+ end
43
+ ```
44
+
45
+ Some DSL methods available include:
46
+
47
+ | DSL Method | Description |
48
+ | :------------------: | --------------------------------------------|
49
+ | `vendor` | The name of the package producer |
50
+ | `license` | The default license for the package |
51
+ | `priority` | The priority for the package |
52
+ | `section` | The section for this package |
53
+
54
+ If you are unfamilar with any of these terms, you should just accept the defaults. For more information on the purpose of any of these configuration options, please see the DEB spec.
55
+
56
+ For more information, please see the [`Packager::DEB` documentation](http://rubydoc.info/github/opscode/omnibus/Omnibus/Packager/DEB).
57
+
58
+ ### Notes on DEB-signing
59
+ At this time, signing Debian packages is not supported.
@@ -1,45 +1,65 @@
1
- Building Omnibus Packages for Mac OSX
2
- =====================================
3
- This document details the steps and configurables for building omnibus packages
4
- on Mac OSX. Unlike Linux-based systems, the process for building a `.pkg` and
5
- a `.dmg` requires some manual preparation of assets.
1
+ Building Omnibus Packages for Mac OS X
2
+ ======================================
3
+ This document details the steps and configurables for building omnibus packages on Mac OS X. Unlike Linux-based systems, the process for building a `.pkg` (and compressing with `.dmg`) may involve the customization of some assets.
6
4
 
7
5
 
8
6
  Building a .pkg
9
7
  ---------------
10
- In Mac OSX, a `.pkg` is a special file that is read by Installer.app that
11
- contains the set of instructions for installating a piece of software on a
12
- target system.
8
+ In Mac OS X, a `.pkg` is a special file that is read by Installer.app that contains the set of instructions for installating a piece of software on a target system.
13
9
 
14
10
  ### Requirements
15
- The omnibus generator will create some stock files in `files/mac_pkg`:
11
+ By default, Omnibus does not generate pkg-related assets. To generate the pkg assets, run the Omnibus generator command with the `--pkg-assets` flag:
12
+
13
+ $ omnibus generate NAME --pkg-assets
14
+
15
+ **If this is an existing project, be sure to answer "NO" when asked if you want to overwrite existing files!**
16
+
17
+ With the `--pkg-assets` flag, Omnibus will generate the following "stock" resources in `resources/NAME/pkg`:
16
18
 
17
19
  - `background.png` - the background image for the installer. We recommend this
18
20
  image has a light background color (otherwise, the text will be difficult to
19
21
  read).
20
- - `license.html` - the full HTML document for the license
21
- - `welcome.html` - the full HTML document for the welcome screen
22
+ - `distribution.xml.erb` - the XML file for use during the `productbuild` command
23
+ - `license.html.erb` - the full HTML document for the license
24
+ - `welcome.html.erb` - the full HTML document for the welcome screen
25
+
26
+ You should use these stock files and templates as a starting point for building your custom pkg.
27
+
28
+ ### DSL
29
+ By default, Omnibus will try to build a pkg package when executed on a Mac OS X operating system. You can further customize the behavior of the packager using the `package` DSL command in your project definition:
30
+
31
+ ```ruby
32
+ # project.rb
33
+ name 'hamlet'
34
+
35
+ package :pkg do
36
+ identifier 'com.getchef.hamlet'
37
+ signing_identity 'acbd1234'
38
+ end
39
+ ```
22
40
 
23
- You should use these stock files and templates as a starting point for building
24
- your custom pkg.
41
+ Some DSL methods available include:
42
+
43
+ | DSL Method | Description |
44
+ | :----------------: | --------------------------------------------|
45
+ | `identifier` | The `com.whatever` id for the package |
46
+ | `signing_identity` | The key to sign the PKG with |
47
+
48
+ For more information, please see the [`Packager::PKG` documentation](http://rubydoc.info/github/opscode/omnibus/Omnibus/Packager/PKG).
25
49
 
26
50
 
27
51
  Building a .dmg
28
52
  ---------------
29
- In Mac OSX, a `.dmg` is a compressed wrapper around a collection of resources,
30
- often including a `.pkg`. The possibilities for creating and customizing a DMG
31
- are endless, but Omnibus provides a "basic" starter case that will generate a
32
- pretty DMG that contains the `.pkg` file it creates.
53
+ In Mac OSX, a `.dmg` is a compressed wrapper around a collection of resources, often including a `.pkg`. The possibilities for creating and customizing a DMG are endless, but Omnibus provides a"basic starter case that will generate a pretty DMG that contains the `.pkg` file it creates.
33
54
 
34
- The following tunables are available:
55
+ ### Requirements
56
+ By default, Omnibus does not generate dmg-related assets. To generate the dmg assets, run the Omnibus generator with the `--dmg-assets` flag:
35
57
 
36
- - `dmg_window_bounds` - the starting and ending (x,y) coordinates for the opened
37
- DMG
38
- - `dmg_pkg_position` - the (x,y) coordinate for the `.pkg` file inside the
39
- opened DMG window
58
+ $ omnibus generate NAME --dmg-assets
40
59
 
41
- ### Requirements
42
- The omnibus generator will create some stock files in `files/mac_dmg`:
60
+ **If this is an existing project, be sure to answer "NO" when asked if you want to overwrite existing files!**
61
+
62
+ With the `--dmg-assets` flag, Omnibus will generate the following "stock" resources in `resources/NAME/dmg`:
43
63
 
44
64
  - `background.png` - the background image to use for the DMG. We recommend using
45
65
  a high-resolution image that is slightly larger than the final length of your
@@ -47,20 +67,26 @@ window (as determined by the `dmg_window_bounds`)
47
67
  - `icon.png` - a 1024x1024 @ 300 icon to use for the DMG. We will automatically
48
68
  create an icns and scale to smaller sizes
49
69
 
50
- You should use these stock files and templates as a starting point for building
51
- your custom dmg.
70
+ You should use these stock files and templates as a starting point for building your custom dmg.
52
71
 
53
- ### Disabling dmg building
54
- DMG creation is enabled by default, but you can disable DMG creation by setting
55
- the `build_dmg` omnibus configuration option to false:
72
+ ### DSL
73
+ By default, Omnibus will **not** try to build a compressed dmg. You can enable this compression using the `compress` DSL command in your project definition:
56
74
 
57
75
  ```ruby
58
- # omnibus.rb
59
- build_dmg false
76
+ # project.rb
77
+ name 'hamlet'
78
+
79
+ compress :dmg do
80
+ window_bounds '200, 200, 750, 600'
81
+ pkg_position '10, 10'
82
+ end
60
83
  ```
61
84
 
62
- And run as you normally would:
85
+ Some DSL methods available include:
63
86
 
64
- ```bash
65
- $ ./bin/omnibus build project <name>
66
- ```
87
+ | DSL Method | Description |
88
+ | :----------------: | --------------------------------------------|
89
+ | `window_bounds` | The size and location of the DMG window |
90
+ | `pkg_position` | The position of the pkg inside the DMG |
91
+
92
+ For more information, please see the [`Compressor::DMG` documentation](http://rubydoc.info/github/opscode/omnibus/Omnibus/Compressor/DMG).
@@ -0,0 +1,74 @@
1
+ Building Omnibus Packages for RHEL
2
+ ==================================
3
+ This document details the steps and configurables for building RPM packages with Omnibus.
4
+
5
+
6
+ Building a .rpm
7
+ ---------------
8
+ ### Requirements
9
+ Omnibus assumes the existence of the `rpmbuild` command on the build system. The [omnibus cookbook](https://supermarket.getchef.com/cookbooks/omnibus) automatically handles this installation. If you are not using the Omnibus cookbook, you must install the package manually or using another tool.
10
+
11
+ ### Configurables
12
+ The following Project values are taken into consideration when building RPMs:
13
+
14
+ - `build_version`
15
+ - `config_file`
16
+ - `conflicts`
17
+ - `description`
18
+ - `exclude`
19
+ - `extra_package_files`
20
+ - `iteration`
21
+ - `maintainer`
22
+ - `package_user`
23
+ - `package_group`
24
+ - `package_scripts_path`
25
+ - `replaces`
26
+ - `runtime_dependency`
27
+ - `url`
28
+
29
+ These options are further described in the [`Project` documentation](http://rubydoc.info/github/opscode/omnibus/Omnibus/Project).
30
+
31
+ These values are interpolated and evaluated using Omnibus' internal RPM templates. For 99% of users, these templates should be satisfactory. If you encounter an instance where Omnibus' RPM templates do not satisfy a use case, please open an issue.
32
+
33
+ Because of the unlikelihood of their necessity, Omnibus does not generate rpm-related assets. If you find yourself in a situation where you need to generate highly-customized RPM assets, run the Omnibus generator command with the `--rpm-assets` flag:
34
+
35
+ $ omnibus generate NAME --rpm-assets
36
+
37
+ **If this is an existing project, be sure to answer "NO" when asked if you want to overwrite existing files!**
38
+
39
+ With the `--rpm-assets` flag, Omnibus will generate the following "stock" resources in `resources/NAME/rpm`:
40
+
41
+ - `rpmmacros.erb` - the macros file
42
+ - `signing.erb` - a Ruby script for signing RPMs
43
+ - `spec.erb` - the ERB for generating the spec
44
+
45
+ **You should only generate the RPM assets if you cannot set values using attributes!**
46
+
47
+ ### DSL
48
+ You can further customize the behavior of the packager using the `package` DSL command in your project definition:
49
+
50
+ ```ruby
51
+ # project.rb
52
+ name 'hamlet'
53
+
54
+ package :rpm do
55
+ signing_passphrase 'acbd1234'
56
+ end
57
+ ```
58
+
59
+ Some DSL methods available include:
60
+
61
+ | DSL Method | Description |
62
+ | :------------------: | --------------------------------------------|
63
+ | `signing_passphrase` | The passphrase to sign the RPM with |
64
+ | `vendor` | The name of the package producer |
65
+ | `license` | The default license for the package |
66
+ | `priority` | The priority for the package |
67
+ | `catetory` | The catetory for this package |
68
+
69
+ If you are unfamilar with any of these terms, you should just accept the defaults. For more information on the purpose of any of these configuration options, please see the RPM spec.
70
+
71
+ For more information, please see the [`Packager::RPM` documentation](http://rubydoc.info/github/opscode/omnibus/Omnibus/Packager/RPM).
72
+
73
+ ### Notes on RPM-signing
74
+ To sign an RPM, you will need a GPG keypair. You can [create your own signing key](http://www.madboa.com/geek/gpg-quickstart/) or [import an existing one](http://irtfweb.ifa.hawaii.edu/~lockhart/gpg/gpg-cs.html). Omnibus automatically generates an `.rpmmacros` config file for `rpmbuild` that assumes that the real name associated to the GPG key is the same as the name of the project maintainer as specified in your Omnibus config. You can override this by creating your own `.rpmmacros` using the steps above.
@@ -1,98 +1,57 @@
1
1
  Building Omnibus Packages for Windows
2
2
  =====================================
3
- This document describes the requirements and configurables for building
4
- omnibus packages on Windows. Omnibus builds MSI packages on Windows systems.
3
+ This document details the steps and configurables for building omnibus packages on Windows. Unlike Linux-based systems, the process for building an `.msi` may involve the customization of some assets.
5
4
 
6
- Requirements
7
- ------------
8
- In order to build an omnibus package on Windows you need:
9
5
 
10
- * Open Source Windows Installer Toolset: [WIX](http://wixtoolset.org/)
11
- * In order to use built in semantic versioning:
12
- [Git for Windows](http://msysgit.github.io/)
13
-
14
- MSI Source Files
6
+ Building an .msi
15
7
  ----------------
16
- In order to create an MSI package, we will need to have some source files that
17
- can be used by WIX toolset to be able to build the MSI. Omnibus creates some
18
- skeletal MSI source files for you to help you get started.
8
+ In Windows, an `.msi` is a special executable that contains the set of instructions for installating a piece of software on a target system. Please note, Omnibus does not support the creation of `.exe` files.
19
9
 
20
- When you execute `omnibus project <<project_name>>` these files will be created
21
- to be able to build MSIs:
10
+ ### Requirements
11
+ By default, Omnibus does not generate msi-related assets. To generate the msi assets, run the Omnibus generator command with the `--msi-assets` flag:
22
12
 
23
- ```
24
- C:\> omnibus project demo
25
- ...
26
- create omnibus-demo/files/windows_msi/Resources/localization-en-us.wxl.erb
27
- create omnibus-demo/files/windows_msi/Resources/parameters.wxi.erb
28
- create omnibus-demo/files/windows_msi/Resources/source.wxs
29
- create omnibus-demo/files/windows_msi/Resources/assets/LICENSE.rtf
30
- create omnibus-demo/files/windows_msi/Resources/assets/banner_background.bmp
31
- create omnibus-demo/files/windows_msi/Resources/assets/dialog_background.bmp
32
- create omnibus-demo/files/windows_msi/Resources/assets/project.ico
33
- create omnibus-demo/files/windows_msi/Resources/assets/project_16x16.ico
34
- create omnibus-demo/files/windows_msi/Resources/assets/project_32x32.ico
35
- ...
36
- ```
37
- - `localization-en-us.wxl.erb` => File that contains the strings that are being
38
- used in the MSI user interface.
39
- - `parameters.wxi.erb` => File that contains the dynamic information needed for
40
- the MSI e.g. version numbers.
41
- - `assets/LICENSE.rtf` => License text in Rich Text Format that is displayed
42
- during MSI installation.
43
- - `assets/*.bmp` => Bitmaps that are displayed during installation.
44
- - `assets/*.ico` => Icons that are used in the system for your application.
45
-
46
- Omnibus requires `wxl`, `wxs` and `wxi` files to be present on the system in
47
- order to build an MSI. You can also create these files as erb templates and
48
- omnibus will render them before starting building the MSI.
49
-
50
- These files are XML files that are created based on Windows WIX Schema. By
51
- default they will package the files under configured `install_dir` and present
52
- a UI that lets users to choose an installation location for the packaged files.
53
- You can modify these XML files based on the documentation
54
- [here](http://wixtoolset.org/documentation/manual/v3/xsd/).
55
-
56
- Configurables
57
- -------------
58
- You can use `msi_parameters` DSL option in your Omnibus project files to pass
59
- dynamic information to your MSI source templates. You can specify a hash or a
60
- block for this option. When block is specified, it is executed at the time of
61
- rendering and it is expected to return a hash. Here is an example:
13
+ $ omnibus generate NAME --msi-assets
62
14
 
63
- ```ruby
64
- # config/projects/my_project.rb
65
- name 'my_project'
15
+ **If this is an existing project, be sure to answer "NO" when asked if you want to overwrite existing files!**
66
16
 
67
- ...
17
+ With the `--msi-assets` flag, Omnibus will generate the following "stock" resources in `resources/NAME/msi`:
68
18
 
69
- msi_parameters do
70
- # Set the upgrade code dynamically
71
- params = { }
72
- params[:upgrade_code] = determine_upgrade_code()
73
- params
74
- end
75
- ```
19
+ - `localization-en-us.wxl.erb` => File that contains the strings that are being used in the MSI user interface
20
+ - `parameters.wxi.erb` => File that contains the dynamic information needed for the MSI e.g. version numbers
21
+ - `assets/LICENSE.rtf` => License text in Rich Text Format that is displayed during MSI installation
22
+ - `assets/*.bmp` => Bitmaps that are displayed during installation
23
+ - `assets/*.ico` => Icons that are used in the system for your application
24
+
25
+ You should use these stock files and templates as a starting point for building your custom msi.
76
26
 
77
- ```xml
78
- <!-- files/windows_msi/Resources/parameters.wxi.erb -->
27
+ These files are XML files that are created based on Windows WIX Schema. By default they will package the files under configured `install_dir` and present a UI that lets users to choose an installation location for the packaged files. You can modify these XML files based on the [WIX documentation](http://wixtoolset.org/documentation/manual/v3/xsd/).
79
28
 
80
- <?xml version="1.0" encoding="utf-8"?>
81
- <Include>
82
- <!--
83
- Versioning. These have to be changed for upgrades.
84
- -->
85
- <?define VersionNumber="<%= @msi_version %>" ?>
86
- <?define DisplayVersionNumber="<%= @msi_display_version %>" ?>
29
+ ### DSL
30
+ By default, Omnibus will try to build an msi package when executed on a Windows operating system. You can further customize the behavior of the packager using the `package` DSL command in your project definition:
87
31
 
88
- <?define UpgradeCode="<%= msi_parameters[:upgrade_code] %>" ?>
89
- </Include>
32
+ ```ruby
33
+ # project.rb
34
+ name 'hamlet'
35
+
36
+ package :msi do
37
+ upgrade_code '2CD7259C-776D-4DDB-A4C8-6E544E580AA1'
38
+ parameters {
39
+ 'KeyThing' => 'ValueThing'
40
+ }
41
+ end
90
42
  ```
91
43
 
92
- MSI Creation
93
- ------------
94
- To create an MSI you would normally run:
44
+ Note that `upgrade_code` is **required** and will raise an exception if not defined! Once set, this value must persist for all future versions of your package. To generate a GUID in Ruby, run the following command:
95
45
 
46
+ ```bash
47
+ ruby -r securerandom -e "puts SecureRandom.uuid"
96
48
  ```
97
- C:\> omnibus build project <name>
98
- ```
49
+
50
+ Some DSL methods available include:
51
+
52
+ | DSL Method | Description |
53
+ | :----------------: | ------------------------------------------------|
54
+ | **`upgrade_code`** | The unique GUID for this package |
55
+ | `parameters` | And arbirtary list of key-value pairs to render |
56
+
57
+ For more information, please see the [`Packager::MSI` documentation](http://rubydoc.info/github/opscode/omnibus/Omnibus/Packager/MSI).
@@ -4,6 +4,5 @@ Feature: omnibus build
4
4
  * I run `omnibus build bacon`
5
5
  * the output should contain:
6
6
  """
7
- I could not find an Omnibus project named 'bacon'! Valid projects are:
8
- * hamlet
7
+ I could not find a project named `bacon' in any of the project locations:
9
8
  """
@@ -3,7 +3,7 @@ Feature: omnibus clean
3
3
  * I run `omnibus clean hamlet`
4
4
  * the output should contain:
5
5
  """
6
- I could not find an Omnibus project named 'hamlet'!
6
+ I could not find a project named `hamlet' in any of the project locations:
7
7
  """
8
8
  * the exit status should not be 0
9
9
 
@@ -14,6 +14,9 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
+ require 'omnibus/core_extensions'
18
+
19
+ require 'cleanroom'
17
20
  require 'pathname'
18
21
  require 'json'
19
22
 
@@ -32,11 +35,12 @@ module Omnibus
32
35
  autoload :BuildVersion, 'omnibus/build_version'
33
36
  autoload :BuildVersionDSL, 'omnibus/build_version_dsl'
34
37
  autoload :Cleaner, 'omnibus/cleaner'
35
- autoload :Cleanroom, 'omnibus/cleanroom'
38
+ autoload :Compressor, 'omnibus/compressor'
36
39
  autoload :Config, 'omnibus/config'
37
40
  autoload :Digestable, 'omnibus/digestable'
38
41
  autoload :Error, 'omnibus/exceptions'
39
42
  autoload :Fetcher, 'omnibus/fetcher'
43
+ autoload :FileSyncer, 'omnibus/file_syncer'
40
44
  autoload :Generator, 'omnibus/generator'
41
45
  autoload :GitCache, 'omnibus/git_cache'
42
46
  autoload :HealthCheck, 'omnibus/health_check'
@@ -44,25 +48,25 @@ module Omnibus
44
48
  autoload :Library, 'omnibus/library'
45
49
  autoload :Logger, 'omnibus/logger'
46
50
  autoload :Logging, 'omnibus/logging'
51
+ autoload :Metadata, 'omnibus/metadata'
47
52
  autoload :NullArgumentable, 'omnibus/null_argumentable'
48
- autoload :NullBuilder, 'omnibus/null_builder'
49
53
  autoload :Ohai, 'omnibus/ohai'
50
54
  autoload :Package, 'omnibus/package'
55
+ autoload :Packager, 'omnibus/packager'
51
56
  autoload :Project, 'omnibus/project'
52
57
  autoload :Publisher, 'omnibus/publisher'
53
58
  autoload :Reports, 'omnibus/reports'
54
59
  autoload :S3Cache, 'omnibus/s3_cache'
55
60
  autoload :Software, 'omnibus/software'
56
61
  autoload :Sugarable, 'omnibus/sugarable'
62
+ autoload :Templating, 'omnibus/templating'
63
+ autoload :ThreadPool, 'omnibus/thread_pool'
57
64
  autoload :Util, 'omnibus/util'
58
65
 
59
- # @todo Remove this in the next major release
60
- autoload :OHAI, 'omnibus/ohai'
61
-
62
- autoload :GitFetcher, 'omnibus/fetchers/git_fetcher'
63
- autoload :NetFetcher, 'omnibus/fetchers/net_fetcher'
64
- autoload :PathFetcher, 'omnibus/fetchers/path_fetcher'
65
- autoload :S3CacheFetcher, 'omnibus/fetchers/s3_cache_fetcher'
66
+ autoload :GitFetcher, 'omnibus/fetchers/git_fetcher'
67
+ autoload :NetFetcher, 'omnibus/fetchers/net_fetcher'
68
+ autoload :NullFetcher, 'omnibus/fetchers/null_fetcher'
69
+ autoload :PathFetcher, 'omnibus/fetchers/path_fetcher'
66
70
 
67
71
  autoload :ArtifactoryPublisher, 'omnibus/publishers/artifactory_publisher'
68
72
  autoload :NullPublisher, 'omnibus/publishers/null_publisher'
@@ -74,13 +78,6 @@ module Omnibus
74
78
  autoload :Publish, 'omnibus/cli/publish'
75
79
  end
76
80
 
77
- module Packager
78
- autoload :Base, 'omnibus/packagers/base'
79
- autoload :MacDmg, 'omnibus/packagers/mac_dmg'
80
- autoload :MacPkg, 'omnibus/packagers/mac_pkg'
81
- autoload :WindowsMsi, 'omnibus/packagers/windows_msi'
82
- end
83
-
84
81
  class << self
85
82
  #
86
83
  # Reset the current Omnibus configuration. This is primary an internal API
@@ -138,36 +135,34 @@ module Omnibus
138
135
  @ui ||= Thor::Base.shell.new
139
136
  end
140
137
 
141
- # Convenience method for access to the {Config} object.
142
- # Provided for backward compatibility.
143
138
  #
144
- # @return [Config]
145
- #
146
- # @deprecated Just refer to {Config} directly.
147
- def config
148
- Omnibus.logger.deprecated('Omnibus') do
149
- 'Omnibus.config. Please use Config.(thing) instead.'
150
- end
151
-
152
- Config
153
- end
154
-
155
139
  # Load in an Omnibus configuration file. Values will be merged with
156
140
  # and override the defaults defined in {Config}.
157
141
  #
158
142
  # @param [String] file path to a configuration file to load
159
143
  #
160
144
  # @return [void]
145
+ #
161
146
  def load_configuration(file)
162
147
  Config.load(file)
163
148
  end
164
149
 
165
- # Processes the configuration to construct the dependency tree of
166
- # projects and software.
167
150
  #
168
- # @return [void]
169
- def process_configuration
170
- process_dsl_files
151
+ # Locate an executable in the current $PATH.
152
+ #
153
+ # @return [String, nil]
154
+ # the path to the executable, or +nil+ if not present
155
+ #
156
+ def which(executable)
157
+ if File.file?(executable) && File.executable?(executable)
158
+ executable
159
+ elsif ENV['PATH']
160
+ path = ENV['PATH'].split(File::PATH_SEPARATOR).find do |path|
161
+ File.executable?(File.join(path, executable))
162
+ end
163
+
164
+ path && File.expand_path(executable, path)
165
+ end
171
166
  end
172
167
 
173
168
  #
@@ -176,7 +171,9 @@ module Omnibus
176
171
  # @return [Array<:Project>]
177
172
  #
178
173
  def projects
179
- _projects.values
174
+ project_map.map do |name, _|
175
+ Project.load(name)
176
+ end
180
177
  end
181
178
 
182
179
  #
@@ -188,165 +185,122 @@ module Omnibus
188
185
  # @return [Project]
189
186
  #
190
187
  def project(name)
191
- _projects[name.to_s]
188
+ Project.load(name)
192
189
  end
193
190
 
194
191
  #
195
- # The absolute path to the Omnibus project/reository directory.
196
- #
197
- # @deprecated Use {Config.project_root} instead.
192
+ # The source root is the path to the root directory of the `omnibus` gem.
198
193
  #
199
- # @return [String]
194
+ # @return [Pathname]
200
195
  #
201
- def project_root
202
- Omnibus.logger.deprecated('Omnibus') do
203
- 'Omnibus.project_root. Please use Config.project_root instead.'
204
- end
205
-
206
- Config.project_root
196
+ def source_root
197
+ @source_root ||= Pathname.new(File.expand_path('../..', __FILE__))
207
198
  end
208
199
 
209
200
  #
210
- # Backward compat alias.
201
+ # The preferred filepath to a project with the given name on disk.
211
202
  #
212
- # @deprecated Use {Config.project_root} instead.
203
+ # @return [String, nil]
213
204
  #
214
- # @see (Omnibus.project_root)
215
- #
216
- def root
217
- Omnibus.logger.deprecated('Omnibus') do
218
- 'Omnibus.root. Please use Omnibus.project_root instead.'
219
- end
220
-
221
- Config.project_root
205
+ def project_path(name)
206
+ project_map[name.to_s]
222
207
  end
223
208
 
224
209
  #
225
- # The source root is the path to the root directory of the `omnibus` gem.
226
- #
227
- # @return [Pathname]
210
+ # The preferred filepath to a software with the given name on disk.
228
211
  #
229
- def source_root
230
- @source_root ||= Pathname.new(File.expand_path('../..', __FILE__))
231
- end
232
-
233
- # Processes all configured {Omnibus::Project} and
234
- # {Omnibus::Software} DSL files.
212
+ # @return [String, nil]
235
213
  #
236
- # @return [void]
237
- def process_dsl_files
238
- expand_software
214
+ def software_path(name)
215
+ software_map[name.to_s]
239
216
  end
240
217
 
241
218
  #
242
- # The list of directories to search for {Software} files. These paths are
243
- # returned **in order** of specifity.
219
+ # The list of directories to search for the given +path+. These paths are
220
+ # returned **in order** of specificity.
244
221
  #
245
- # @see (Config#project_root)
246
- # @see (Config#software_dir)
247
- # @see (Config#software_gems)
248
- # @see (Config#local_software_dirs)
222
+ # @param [String] path
223
+ # the subpath to search for
249
224
  #
250
225
  # @return [Array<String>]
251
226
  #
252
- def software_dirs
253
- return @software_dirs if @software_dirs
254
-
255
- directories = [
227
+ def possible_paths_for(path)
228
+ possible_paths[path] ||= [
256
229
  paths_from_project_root,
257
230
  paths_from_local_software_dirs,
258
231
  paths_from_software_gems,
259
- ].flatten
260
-
261
- @software_dirs = directories.inject([]) do |array, directory|
262
- softwares_path = File.join(directory, Config.software_dir)
232
+ ].flatten.inject([]) do |array, directory|
233
+ destination = File.join(directory, path)
263
234
 
264
- if File.directory?(softwares_path)
265
- array << softwares_path
266
- else
267
- Omnibus.logger.warn('Omnibus') do
268
- "`#{directory}' does not contain a valid directory structure. " \
269
- "Does it contain a folder at `#{Config.software_dir}'?"
270
- end
235
+ if File.directory?(destination)
236
+ array << destination
271
237
  end
272
238
 
273
239
  array
274
240
  end
241
+ end
275
242
 
276
- @software_dirs
243
+ private
244
+
245
+ #
246
+ # The list of possible paths, cached as a hash for quick lookup.
247
+ #
248
+ # @see {Omnibus.possible_paths_for}
249
+ #
250
+ # @return [Hash]
251
+ #
252
+ def possible_paths
253
+ @possible_paths ||= {}
277
254
  end
278
255
 
279
256
  #
280
- # A hash of all softwares (by name) and their respective path on disk. These
281
- # files are **in order**, meaning the software path is the **first**
282
- # occurrence of the software in the list. If the same software is
283
- # encountered a second time, it will be skipped.
257
+ # Map the given file paths to the basename of their file, with the +.rb+
258
+ # extension removed.
284
259
  #
285
260
  # @example
286
- # { 'preparation' => '/home/omnibus/project/config/software/preparation.rb' }
261
+ # { 'foo' => '/path/to/foo' }
287
262
  #
288
263
  # @return [Hash<String, String>]
289
264
  #
290
- def software_map
291
- return @software_map if @software_map
292
-
293
- @software_map = software_dirs.inject({}) do |hash, directory|
265
+ def basename_map(paths)
266
+ paths.inject({}) do |hash, directory|
294
267
  Dir.glob("#{directory}/*.rb").each do |path|
295
268
  name = File.basename(path, '.rb')
296
-
297
- if hash[name].nil?
298
- Omnibus.logger.debug('Omnibus#software_map') do
299
- "Using software `#{name}' from `#{path}'."
300
- end
301
-
302
- hash[name] = path
303
- else
304
- Omnibus.logger.debug('Omnibus#software_map') do
305
- "Skipping software `#{name}' because it was loaded from an " \
306
- "earlier path."
307
- end
308
- end
269
+ hash[name] ||= path
309
270
  end
310
271
 
311
272
  hash
312
273
  end
313
-
314
- @software_map
315
274
  end
316
275
 
317
- private
318
-
319
276
  #
320
- # @api private
277
+ # A hash of all softwares (by name) and their respective path on disk. These
278
+ # files are **in order**, meaning the software path is the **first**
279
+ # occurrence of the software in the list. If the same software is
280
+ # encountered a second time, it will be skipped.
321
281
  #
322
- # The list of omnibus projects. This is an internal API that maps a
323
- # project's name to the actual project object.
282
+ # @example
283
+ # { 'preparation' => '/home/omnibus/project/config/software/preparation.rb' }
324
284
  #
325
- # @return [Hash<String, Project>]
285
+ # @return [Hash<String, String>]
326
286
  #
327
- def _projects
328
- return @_projects if @_projects
329
-
330
- path = File.expand_path(Config.project_dir, Config.project_root)
331
- @_projects = Dir.glob("#{path}/*.rb").inject({}) do |hash, path|
332
- name = File.basename(path, '.rb')
333
-
334
- if hash[name].nil?
335
- Omnibus.logger.debug('Omnibus#projects') do
336
- "Using project `#{name}' from `#{path}'."
337
- end
338
-
339
- hash[name] = Project.load(path)
340
- else
341
- Omnibus.logger.debug('Omnibus#projects') do
342
- "Skipping project `#{name}' because it was already loaded."
343
- end
344
- end
345
-
346
- hash
347
- end
287
+ def software_map
288
+ @software_map ||= basename_map(possible_paths_for(Config.software_dir))
289
+ end
348
290
 
349
- @_projects
291
+ #
292
+ # A hash of all projects (by name) and their respective path on disk. These
293
+ # files are **in order**, meaning the project path is the **first**
294
+ # occurrence of the project in the list. If the same project is
295
+ # encountered a second time, it will be skipped.
296
+ #
297
+ # @example
298
+ # { 'chefdk' => '/home/omnibus/project/config/projects/chefdk.rb' }
299
+ #
300
+ # @return [Hash<String, String>]
301
+ #
302
+ def project_map
303
+ @project_map ||= basename_map(possible_paths_for(Config.project_dir))
350
304
  end
351
305
 
352
306
  #
@@ -360,7 +314,8 @@ module Omnibus
360
314
  # @return [Array<String>]
361
315
  #
362
316
  def paths_from_project_root
363
- [Config.project_root]
317
+ @paths_from_project_root ||=
318
+ [Config.project_root]
364
319
  end
365
320
 
366
321
  #
@@ -372,19 +327,16 @@ module Omnibus
372
327
  # @return [Array<String>]
373
328
  #
374
329
  def paths_from_local_software_dirs
375
- Array(Config.local_software_dirs).inject([]) do |array, path|
376
- fullpath = File.expand_path(path, Config.project_root)
377
-
378
- if File.directory?(fullpath)
379
- array << fullpath
380
- else
381
- Omnibus.logger.warn('Omnibus') do
382
- "Could not load softwares from path `#{fullpath}'. Does it exist?"
330
+ @paths_from_local_software_dirs ||=
331
+ Array(Config.local_software_dirs).inject([]) do |array, path|
332
+ fullpath = File.expand_path(path, Config.project_root)
333
+
334
+ if File.directory?(fullpath)
335
+ array << fullpath
383
336
  end
384
- end
385
337
 
386
- array
387
- end
338
+ array
339
+ end
388
340
  end
389
341
 
390
342
  #
@@ -398,59 +350,14 @@ module Omnibus
398
350
  # @return [Array<String>]
399
351
  #
400
352
  def paths_from_software_gems
401
- Array(Config.software_gems).inject([]) do |array, name|
402
- if (spec = Gem::Specification.find_all_by_name(name).first)
403
- array << File.expand_path(spec.gem_dir)
404
- else
405
- Omnibus.logger.warn('Omnibus') do
406
- "Could not load softwares from gem `#{name}'. Is it installed?"
353
+ @paths_from_software_gems ||=
354
+ Array(Config.software_gems).inject([]) do |array, name|
355
+ if (spec = Gem::Specification.find_all_by_name(name).first)
356
+ array << File.expand_path(spec.gem_dir)
407
357
  end
408
- end
409
-
410
- array
411
- end
412
- end
413
358
 
414
- #
415
- # Generate {Software} objects for all software DSL files in
416
- # +software_specs+.
417
- #
418
- # @return [void]
419
- #
420
- def expand_software
421
- Omnibus.projects.each do |project|
422
- project.dependencies.each do |dependency|
423
- recursively_load_dependency(dependency, project)
359
+ array
424
360
  end
425
- end
426
- end
427
-
428
- #
429
- # Loads a project's dependencies recursively, ensuring all transitive
430
- # dependencies are also loaded in the correct order.
431
- #
432
- # @param [String] dependency
433
- # the name of the dependency
434
- # @param [Project] project
435
- # the project that loaded the software
436
- #
437
- # @return [void]
438
- #
439
- def recursively_load_dependency(dependency, project)
440
- filepath = software_map[dependency]
441
-
442
- if filepath.nil?
443
- raise MissingProjectDependency.new(dependency, software_dirs)
444
- end
445
-
446
- software = Software.load(project, filepath)
447
-
448
- # load any transitive deps for the component into the library also
449
- software.dependencies.each do |transitive_dependency|
450
- recursively_load_dependency(transitive_dependency, project)
451
- end
452
-
453
- project.library.component_added(software)
454
361
  end
455
362
  end
456
363
  end