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
@@ -61,20 +61,20 @@ module Omnibus
61
61
  # @return [Array<String>]
62
62
  #
63
63
  def packages
64
- @packages ||= Dir.glob(@pattern).map { |path| Package.new(path) }
64
+ @packages ||= FileSyncer.glob(@pattern).map { |path| Package.new(path) }
65
65
  end
66
66
 
67
67
  #
68
68
  # @abstract
69
69
  #
70
- # @param [Proc] block
70
+ # @param [Proc] _block
71
71
  # if given, the block will yield the currently uploading "thing"
72
72
  #
73
73
  # @return [Array<String>]
74
74
  # the list of uploaded packages
75
75
  #
76
76
  def publish(&_block)
77
- raise AbstractMethod.new("#{self.class.name}#publish")
77
+ raise NotImplementedError
78
78
  end
79
79
 
80
80
  private
@@ -64,18 +64,21 @@ module Omnibus
64
64
  #
65
65
  def populate
66
66
  missing.each do |software|
67
- fetch(software)
67
+ without_caching do
68
+ software.fetch
69
+ end
68
70
 
69
- key = key_for(software)
70
- content = IO.read(software.project_file)
71
+ key = key_for(software)
72
+ fetcher = software.fetcher
73
+ content = IO.read(fetcher.downloaded_file)
71
74
 
72
75
  log.info(log_key) do
73
- "Caching '#{software.project_file}' to '#{Config.s3_bucket}/#{key}'"
76
+ "Caching '#{fetcher.downloaded_file}' to '#{Config.s3_bucket}/#{key}'"
74
77
  end
75
78
 
76
79
  client.store(key, content,
77
80
  access: :public_read,
78
- content_md5: software.checksum
81
+ content_md5: software.fetcher.checksum
79
82
  )
80
83
  end
81
84
 
@@ -89,7 +92,9 @@ module Omnibus
89
92
  #
90
93
  def fetch_missing
91
94
  missing.each do |software|
92
- fetch(software)
95
+ without_caching do
96
+ software.fetch
97
+ end
93
98
  end
94
99
  end
95
100
 
@@ -115,11 +120,11 @@ module Omnibus
115
120
  raise InsufficientSpecification.new(:version, software)
116
121
  end
117
122
 
118
- unless software.checksum
119
- raise InsufficientSpecification.new(:checksum, software)
123
+ unless software.fetcher.checksum
124
+ raise InsufficientSpecification.new('source md5 checksum', software)
120
125
  end
121
126
 
122
- "#{software.name}-#{software.version}-#{software.checksum}"
127
+ "#{software.name}-#{software.version}-#{software.fetcher.checksum}"
123
128
  end
124
129
 
125
130
  private
@@ -161,7 +166,7 @@ module Omnibus
161
166
  def softwares
162
167
  Omnibus.projects.inject({}) do |hash, project|
163
168
  project.library.each do |software|
164
- if software.source && software.source.key?(:url)
169
+ if software.fetcher.is_a?(NetFetcher)
165
170
  hash[software.name] = software
166
171
  end
167
172
  end
@@ -170,27 +175,13 @@ module Omnibus
170
175
  end.values.sort
171
176
  end
172
177
 
173
- #
174
- # Fetch the remote software definition onto disk.
175
- #
176
- # @param [Software] software
177
- # the software to fetch
178
- #
179
- # @return [true]
180
- #
181
- def fetch(software)
182
- log.info(log_key) { "Fetching #{software.name}" }
183
- fetcher = Fetcher.without_caching_for(software)
184
-
185
- if fetcher.fetch_required?
186
- log.debug(log_key) { 'Updating cache' }
187
- fetcher.download
188
- fetcher.verify_checksum!
189
- else
190
- log.debug(log_key) { 'Cached copy up to date, skipping.' }
191
- end
178
+ def without_caching(&block)
179
+ original = Config.use_s3_caching
180
+ Config.use_s3_caching(false)
192
181
 
193
- true
182
+ yield
183
+ ensure
184
+ Config.use_s3_caching(original)
194
185
  end
195
186
  end
196
187
  end
@@ -18,23 +18,48 @@ require 'fileutils'
18
18
  require 'uri'
19
19
 
20
20
  module Omnibus
21
- # Omnibus software DSL reader
22
21
  class Software
23
22
  class << self
24
23
  #
25
24
  # @param [Project] project
26
25
  # the project that loaded this software definition
27
- # @param [String] filepath
26
+ # @param [String] name
28
27
  # the path to the software definition to load from disk
29
- # @param [hash] overrides
30
- # a list of software overrides
31
28
  #
32
29
  # @return [Software]
33
30
  #
34
- def load(project, filepath, overrides = {})
35
- instance = new(project, overrides, filepath)
36
- instance.evaluate_file(filepath)
37
- instance
31
+ def load(project, name)
32
+ loaded_softwares[name] ||= begin
33
+ filepath = Omnibus.software_path(name)
34
+
35
+ if filepath.nil?
36
+ raise MissingSoftware.new(name)
37
+ else
38
+ log.internal(log_key) do
39
+ "Loading software `#{name}' from `#{filepath}'."
40
+ end
41
+ end
42
+
43
+ instance = new(project, filepath)
44
+ instance.evaluate_file(filepath)
45
+ instance.load_dependencies
46
+
47
+ # Add the loaded compontent to the library
48
+ project.library.component_added(instance)
49
+
50
+ instance
51
+ end
52
+ end
53
+
54
+ private
55
+
56
+ #
57
+ # The list of softwares loaded thus far.
58
+ #
59
+ # @return [Hash<String, Software>]
60
+ #
61
+ def loaded_softwares
62
+ @loaded_softwares ||= {}
38
63
  end
39
64
  end
40
65
 
@@ -47,17 +72,14 @@ module Omnibus
47
72
  #
48
73
  # Create a new software object.
49
74
  #
50
- # @param [String] NullBuilder.new(self)
51
75
  # @param [Project] project
52
76
  # the Omnibus project that instantiated this software definition
53
- # @param [Hash] repo_overrides
54
- # @see Omnibus::Overrides
55
77
  # @param [String] filepath
56
78
  # the path to where this software definition lives on disk
57
79
  #
58
80
  # @return [Software]
59
81
  #
60
- def initialize(project, repo_overrides = {}, filepath = nil)
82
+ def initialize(project, filepath = nil)
61
83
  unless project.is_a?(Project)
62
84
  raise ArgumentError,
63
85
  "`project' must be a kind of `Omnibus::Project', but was `#{project.class.inspect}'!"
@@ -68,8 +90,7 @@ module Omnibus
68
90
  @project = project
69
91
 
70
92
  # Overrides
71
- @overrides = NULL
72
- @repo_overrides = repo_overrides
93
+ @overrides = NULL
73
94
  end
74
95
 
75
96
  #
@@ -97,26 +118,11 @@ module Omnibus
97
118
  end
98
119
  expose :project
99
120
 
100
- #
101
- # Retrieves the overriden version.
102
- #
103
- # @deprecated Use {#version} or test with {#overridden?} instead.
104
- #
105
- # @return [Hash]
106
- #
107
- def override_version
108
- log.deprecated(log_key) do
109
- 'Software#override_version. Please use #version or ' \
110
- 'test with #overridden?'
111
- end
112
-
113
- overrides[:version]
114
- end
115
- expose :override_version
116
-
117
121
  #
118
122
  # **[Required]** Sets or retreives the name of the software.
119
123
  #
124
+ # @raise [MissingRequiredAttribute]
125
+ #
120
126
  # @example
121
127
  # name 'libxslt'
122
128
  #
@@ -127,7 +133,7 @@ module Omnibus
127
133
  #
128
134
  def name(val = NULL)
129
135
  if null?(val)
130
- @name || raise(MissingSoftwareConfiguration.new(name, 'name', 'libxslt'))
136
+ @name || raise(MissingRequiredAttribute.new(self, :name, 'libxslt'))
131
137
  else
132
138
  @name = val
133
139
  end
@@ -226,7 +232,7 @@ module Omnibus
226
232
  "be a kind of `Hash', but was `#{val.class.inspect}'")
227
233
  end
228
234
 
229
- extra_keys = val.keys - [:git, :path, :url, :md5, :cookie, :warning]
235
+ extra_keys = val.keys - [:git, :path, :url, :md5, :cookie, :warning, :unsafe]
230
236
  unless extra_keys.empty?
231
237
  raise InvalidValue.new(:source,
232
238
  "only include valid keys. Invalid keys: #{extra_keys.inspect}")
@@ -274,33 +280,22 @@ module Omnibus
274
280
  # source path: '/local/path/to/software-1.2.3'
275
281
  # end
276
282
  #
277
- # @deprecated passing only a string without a block to set the version is
278
- # deprecated. Please use {#default_version} instead.
279
- #
280
283
  # @param [String] val
281
284
  # the version of the software
282
- #
283
285
  # @param [Proc] block
284
286
  # the block to run if the version we are building matches the argument
285
287
  #
286
288
  # @return [String, Proc]
287
289
  #
288
- def version(val = NULL)
290
+ def version(val = NULL, &block)
289
291
  if block_given?
290
292
  if val.equal?(NULL)
291
293
  raise InvalidValue.new(:version,
292
294
  'pass a block when given a version argument')
293
295
  else
294
296
  if val == apply_overrides(:version)
295
- yield
296
- end
297
- end
298
- else
299
- unless val.equal?(NULL)
300
- log.deprecated(log_key) do
301
- 'Software#version. Please use #default_version instead.'
297
+ block.call
302
298
  end
303
- @version = val
304
299
  end
305
300
  end
306
301
 
@@ -333,14 +328,14 @@ module Omnibus
333
328
  # @example
334
329
  # relative_path 'example-1.2.3'
335
330
  #
336
- # @param [String] relative_path
331
+ # @param [String] val
337
332
  # the relative path inside the tarball
338
333
  #
339
334
  # @return [String]
340
335
  #
341
336
  def relative_path(val = NULL)
342
337
  if null?(val)
343
- @relative_path ||= name
338
+ @relative_path || name
344
339
  else
345
340
  @relative_path = val
346
341
  end
@@ -380,56 +375,6 @@ module Omnibus
380
375
  end
381
376
  expose :install_dir
382
377
 
383
- #
384
- # The path where this software is installed on disk.
385
- #
386
- # @deprecated Use {#install_dir} instead
387
- #
388
- # @return (see #install_dir)
389
- #
390
- def install_path
391
- log.deprecated(log_key) do
392
- 'install_path (DSL). Please use install_dir instead.'
393
- end
394
-
395
- install_dir
396
- end
397
- expose :install_path
398
-
399
- #
400
- # Returns the platform of the machine on which Omnibus is running, as
401
- # determined by Ohai.
402
- #
403
- # @deprecated Use +Ohai['platform']+ instead.
404
- #
405
- # @return [String]
406
- #
407
- def platform
408
- log.deprecated(log_key) do
409
- "Software#platform. Please use Ohai['platform'] instead."
410
- end
411
-
412
- Ohai['platform']
413
- end
414
- expose :platform
415
-
416
- #
417
- # Return the architecture of the machine, as determined by Ohai.
418
- #
419
- # @deprecated Will not be replaced.
420
- #
421
- # @return [String]
422
- # Either "sparc" or "intel", as appropriate
423
- #
424
- def architecture
425
- log.deprecated(log_key) do
426
- "Software#architecture. Please use Ohai['kernel']['machine'] instead."
427
- end
428
-
429
- Ohai['kernel']['machine'] =~ /sun/ ? 'sparc' : 'intel'
430
- end
431
- expose :architecture
432
-
433
378
  #
434
379
  # Define a series of {Builder} DSL commands that are executed to build the
435
380
  # software.
@@ -448,31 +393,36 @@ module Omnibus
448
393
  expose :build
449
394
 
450
395
  #
451
- # The path on disk to the downloaded asset. This method requires the
452
- # presence of a +source_uri+.
396
+ # The path to the downloaded file from a NetFetcher.
453
397
  #
454
- # @todo This is really a property of the {NetFetcher} and should be
455
- # implemented on that class.
398
+ # @deprecated There is no replacement for this DSL method
456
399
  #
457
- def downloaded_file
458
- @downloaded_file ||= begin
459
- raise MissingSoftwareSourceURI.new(self) unless source_uri
400
+ def project_file
401
+ if fetcher && fetcher.is_a?(NetFetcher)
402
+ log.deprecated(log_key) do
403
+ "project_file (DSL). This is a property of the NetFetcher and will " \
404
+ "not be publically exposed in the next major release. In general, " \
405
+ "you should not be using this method in your software definitions " \
406
+ "as it is an internal implementation detail of the NetFetcher. If " \
407
+ "you disagree with this statement, you should open an issue on the " \
408
+ "Omnibus repository on GitHub an explain your use case. For now, " \
409
+ "I will return the path to the downloaded file on disk, but please " \
410
+ "rethink the problem you are trying to solve :)."
411
+ end
460
412
 
461
- filename = source_uri.path.split('/').last
462
- "#{Config.cache_dir}/#{filename}"
463
- end
464
- end
465
- expose :downloaded_file
413
+ fetcher.downloaded_file
414
+ else
415
+ log.warn(log_key) do
416
+ "Cannot retrieve a `project_file' for software `#{name}'. This " \
417
+ "attribute is actually an internal representation that is unique " \
418
+ "to the NetFetcher class and requires the use of a `source' " \
419
+ "attribute that is declared using a `:url' key. For backwards-" \
420
+ "compatability, I will return `nil', but this is most likely not " \
421
+ "your desired behavior."
422
+ end
466
423
 
467
- #
468
- # @deprecated Use {#downloaded_file} instead
469
- #
470
- def project_file
471
- log.deprecated(log_key) do
472
- "project_file (DSL). Please use `downloaded_file' instead."
424
+ nil
473
425
  end
474
-
475
- downloaded_file
476
426
  end
477
427
  expose :project_file
478
428
 
@@ -483,8 +433,8 @@ module Omnibus
483
433
  # Supported options:
484
434
  # :aix => :use_gcc force using gcc/g++ compilers on aix
485
435
  #
486
- # @params [Hash] env
487
- # @params [Hash] opts
436
+ # @param [Hash] env
437
+ # @param [Hash] opts
488
438
  #
489
439
  # @return [Hash]
490
440
  #
@@ -568,7 +518,7 @@ module Omnibus
568
518
  # project's embedded/bin directory prepended. The correct path separator
569
519
  # for the platform is used to join the paths.
570
520
  #
571
- # @params [Hash] env
521
+ # @param [Hash] env
572
522
  #
573
523
  # @return [Hash]
574
524
  #
@@ -597,88 +547,17 @@ module Omnibus
597
547
  expose :prepend_path
598
548
 
599
549
  #
600
- # The source directory.
601
- #
602
- # @deprecated Use {Config.source_dir} instead
603
- #
604
- # @return [String]
605
- #
606
- def source_dir
607
- log.deprecated(log_key) do
608
- 'source_dir (DSL). Please use Config.source_dir instead.'
609
- end
610
-
611
- Config.source_dir
612
- end
613
- expose :source_dir
614
-
615
- #
616
- # The cache directory.
617
- #
618
- # @deprecated Use {Config.cache_dir} instead
619
- #
620
- # @return [String]
621
- #
622
- def cache_dir
623
- log.deprecated(log_key) do
624
- 'cache_dir (DSL). Please use Config.cache_dir instead.'
625
- end
626
-
627
- Config.cache_dir
628
- end
629
- expose :cache_dir
630
-
631
- #
632
- # Convenience method for accessing the global Omnibus configuration object.
633
- #
634
- # @deprecated Use {Config} instead
635
- #
636
- # @return Config
637
- #
638
- # @see Config
639
- #
640
- def config
641
- log.deprecated(log_key) do
642
- 'config (DSL). Please use Config.(thing) instead (capital C).'
643
- end
644
-
645
- Config
646
- end
647
- expose :config
648
-
649
- #
650
- # The list of software dependencies for this software. These is the software
651
- # that comprises your software, and is distinct from runtime dependencies.
652
- #
653
- # @deprecated Use {#dependency} instead (as a setter; the getter will stay)
654
- #
655
- # @todo Remove the "setter" part of this method and unexpose it as part of
656
- # the DSL in the next major release
550
+ # A proxy method to the underlying Ohai system.
657
551
  #
658
- # @see #dependency
659
- #
660
- # @param [Array<String>]
552
+ # @example
553
+ # ohai['platform_family']
661
554
  #
662
- # @return [Array<String>]
555
+ # @return [Ohai]
663
556
  #
664
- def dependencies(*args)
665
- @dependencies ||= []
666
-
667
- # Handle the case where an array or list of args were given
668
- flattened_args = Array(args).flatten
669
-
670
- if flattened_args.empty?
671
- @dependencies
672
- else
673
- log.deprecated(log_key) do
674
- "dependencies (DSL). Please specify each dependency on its own " \
675
- "line like `dependency '#{flattened_args.first}'`."
676
- end
677
-
678
- @dependencies = flattened_args
679
- end
557
+ def ohai
558
+ Ohai
680
559
  end
681
- expose :dependencies
560
+ expose :ohai
682
561
 
683
562
  #
684
563
  # @!endgroup
@@ -691,6 +570,19 @@ module Omnibus
691
570
  # be the "public API" for a software.
692
571
  # --------------------------------------------------
693
572
 
573
+ #
574
+ # Recursively load all the dependencies for this software.
575
+ #
576
+ # @return [true]
577
+ #
578
+ def load_dependencies
579
+ dependencies.each do |dependency|
580
+ software = Software.load(project, dependency)
581
+ end
582
+
583
+ true
584
+ end
585
+
694
586
  #
695
587
  # The builder object for this software definition.
696
588
  #
@@ -709,11 +601,6 @@ module Omnibus
709
601
  # true if the software was fetched, false if it was cached
710
602
  #
711
603
  def fetch
712
- # Create the directories we need
713
- [build_dir, Config.source_dir, Config.cache_dir, project_dir].each do |dir|
714
- FileUtils.mkdir_p(dir)
715
- end
716
-
717
604
  if fetcher.fetch_required?
718
605
  fetcher.fetch
719
606
  true
@@ -722,6 +609,20 @@ module Omnibus
722
609
  end
723
610
  end
724
611
 
612
+ #
613
+ # The list of software dependencies for this software. These is the software
614
+ # that comprises your software, and is distinct from runtime dependencies.
615
+ #
616
+ # @see #dependency
617
+ #
618
+ # @param [Array<String>]
619
+ #
620
+ # @return [Array<String>]
621
+ #
622
+ def dependencies
623
+ @dependencies ||= []
624
+ end
625
+
725
626
  #
726
627
  # The list of files to ignore in the healthcheck.
727
628
  #
@@ -751,9 +652,6 @@ module Omnibus
751
652
  # lazily initialized because we need the 'name' to be parsed first
752
653
  @overrides = {}
753
654
  @overrides = project.overrides[name.to_sym].dup if project.overrides[name.to_sym]
754
- if @repo_overrides[name]
755
- @overrides[:version] = @repo_overrides[name]
756
- end
757
655
  end
758
656
 
759
657
  @overrides
@@ -774,24 +672,9 @@ module Omnibus
774
672
  # @!endgroup
775
673
  # --------------------------------------------------
776
674
 
777
- #
778
- # Retieve the {#default_version} of the software.
779
- #
780
- # @deprecated Use {#default_version} instead.
781
- #
782
- # @return [String]
783
- #
784
- def given_version
785
- log.deprecated(log_key) do
786
- 'Software#given_version. Please use #default_version instead.'
787
- end
788
-
789
- default_version
790
- end
791
-
792
675
  # @todo see comments on {Omnibus::Fetcher#without_caching_for}
793
676
  def version_guid
794
- Fetcher.for(self).version_guid
677
+ fetcher.version_guid
795
678
  end
796
679
 
797
680
  # Returns the version to be used in cache.
@@ -811,42 +694,42 @@ module Omnibus
811
694
  end
812
695
  end
813
696
 
814
- # @todo Code smell... this only has meaning if the software was
815
- # defined with a :uri, and this is only used in
816
- # {Omnibus::NetFetcher}. This responsibility is distributed
817
- # across two classes, one of which is a specific interface
818
- # implementation
819
- # @todo Why the caching of the URI?
820
- def source_uri
821
- @source_uri ||= URI(source[:url])
822
- end
823
-
824
- # @todo Code smell... this only has meaning if the software was
825
- # defined with a :uri, and this is only used in
826
- # {Omnibus::NetFetcher}. This responsibility is distributed
827
- # across two classes, one of which is a specific interface
828
- # implementation
829
- def checksum
830
- source[:md5]
831
- end
832
-
833
- # The fetcher for this software.
697
+ #
698
+ # The fetcher for this software, based off of the +source+ attribute.
699
+ #
700
+ # - +:url+ - {NetFetcher}
701
+ # - +:git+ - {GitFetcher}
702
+ # - +:path+ - {PathFetcher}
834
703
  #
835
704
  # @return [Fetcher]
705
+ #
836
706
  def fetcher
837
- @fetcher ||= Fetcher.for(self)
707
+ @fetcher ||= if source
708
+ if source[:url]
709
+ NetFetcher.new(self)
710
+ elsif source[:git]
711
+ GitFetcher.new(self)
712
+ elsif source[:path]
713
+ PathFetcher.new(self)
714
+ end
715
+ else
716
+ NullFetcher.new(self)
717
+ end
838
718
  end
839
719
 
840
720
  # Actually build the software package
841
721
  def build_me
842
722
  # Build if we need to
843
723
  if always_build?
844
- execute_build(fetcher)
724
+ log.info(log_key) { "Forcing build because `always_build' was given" }
725
+ execute_build
845
726
  else
846
727
  if GitCache.new(self).restore
728
+ log.info(log_key) { "Restored from cache" }
847
729
  true
848
730
  else
849
- execute_build(fetcher)
731
+ log.info(log_key) { "Could not restore from cache, building..." }
732
+ execute_build
850
733
  end
851
734
  end
852
735
 
@@ -890,12 +773,6 @@ module Omnibus
890
773
  @shasum ||= begin
891
774
  digest = Digest::SHA256.new
892
775
 
893
- log.debug(log_key) { "project (SHA): #{project.shasum.inspect}" }
894
- log.debug(log_key) { "builder (SHA): #{builder.shasum.inspect}" }
895
- log.debug(log_key) { "name: #{name.inspect}" }
896
- log.debug(log_key) { "version_for_cache: #{version_for_cache.inspect}" }
897
- log.debug(log_key) { "overrides: #{overrides.inspect}" }
898
-
899
776
  update_with_string(digest, project.shasum)
900
777
  update_with_string(digest, builder.shasum)
901
778
  update_with_string(digest, name)
@@ -903,18 +780,12 @@ module Omnibus
903
780
  update_with_string(digest, JSON.fast_generate(overrides))
904
781
 
905
782
  if filepath && File.exist?(filepath)
906
- log.debug(log_key) { "filepath: #{filepath.inspect}" }
907
783
  update_with_file_contents(digest, filepath)
908
784
  else
909
- log.debug(log_key) { "filepath: <DYNAMIC>" }
910
785
  update_with_string(digest, '<DYNAMIC>')
911
786
  end
912
787
 
913
- shasum = digest.hexdigest
914
-
915
- log.debug(log_key) { "shasum: #{shasum.inspect}" }
916
-
917
- shasum
788
+ digest.hexdigest
918
789
  end
919
790
  end
920
791
 
@@ -967,23 +838,13 @@ module Omnibus
967
838
  end
968
839
  end
969
840
 
970
- # @todo Remove this in the next major release
971
- def command(*)
972
- log.deprecated(log_key) do
973
- 'Software#command. Please use something else.'
974
- end
975
-
976
- raise 'Method Moved.'
977
- end
978
-
979
- def execute_build(fetcher)
841
+ def execute_build
980
842
  fetcher.clean
981
843
  builder.build
982
844
 
983
845
  if Config.use_git_caching
984
- log.info(log_key) { 'Caching build' }
985
846
  GitCache.new(self).incremental
986
- log.info(log_key) { 'Dirtied the cache!' }
847
+ log.info(log_key) { 'Dirtied the cache' }
987
848
  end
988
849
 
989
850
  project.dirty!