omnibus 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +17 -1
  3. data/.travis.yml +11 -3
  4. data/CHANGELOG.md +39 -1
  5. data/Gemfile +0 -4
  6. data/README.md +10 -8
  7. data/Rakefile +18 -7
  8. data/bin/omnibus +3 -3
  9. data/docs/Building on Windows.md +98 -0
  10. data/features/commands/_deprecated.feature +46 -0
  11. data/features/commands/build.feature +9 -0
  12. data/features/commands/clean.feature +21 -0
  13. data/features/commands/list.feature +16 -0
  14. data/features/commands/new.feature +8 -0
  15. data/features/commands/version.feature +12 -0
  16. data/features/step_definitions/generator_steps.rb +28 -0
  17. data/features/support/env.rb +13 -0
  18. data/lib/omnibus.rb +319 -240
  19. data/lib/omnibus/artifact.rb +16 -0
  20. data/lib/omnibus/build_version.rb +39 -20
  21. data/lib/omnibus/build_version_dsl.rb +136 -0
  22. data/lib/omnibus/builder.rb +28 -23
  23. data/lib/omnibus/cleaner.rb +72 -0
  24. data/lib/omnibus/cli.rb +115 -11
  25. data/lib/omnibus/cli/base.rb +82 -81
  26. data/lib/omnibus/cli/cache.rb +80 -32
  27. data/lib/omnibus/cli/deprecated.rb +79 -0
  28. data/lib/omnibus/cli/release.rb +17 -21
  29. data/lib/omnibus/config.rb +38 -13
  30. data/lib/omnibus/exceptions.rb +70 -18
  31. data/lib/omnibus/fetcher.rb +18 -11
  32. data/lib/omnibus/fetchers/git_fetcher.rb +48 -53
  33. data/lib/omnibus/fetchers/net_fetcher.rb +29 -27
  34. data/lib/omnibus/fetchers/path_fetcher.rb +9 -12
  35. data/lib/omnibus/fetchers/s3_cache_fetcher.rb +5 -8
  36. data/lib/omnibus/generator.rb +131 -0
  37. data/lib/omnibus/{templates → generator_files}/.kitchen.local.yml.erb +0 -0
  38. data/lib/omnibus/{templates → generator_files}/.kitchen.yml.erb +0 -0
  39. data/lib/omnibus/{templates → generator_files}/Berksfile.erb +0 -0
  40. data/lib/omnibus/{templates → generator_files}/Gemfile.erb +2 -2
  41. data/lib/omnibus/{templates → generator_files}/README.md.erb +6 -7
  42. data/lib/omnibus/{templates → generator_files}/Vagrantfile.erb +0 -0
  43. data/lib/omnibus/{templates → generator_files}/gitignore.erb +0 -0
  44. data/lib/omnibus/{templates → generator_files}/mac_dmg/background.png +0 -0
  45. data/lib/omnibus/{templates → generator_files}/mac_dmg/icon.png +0 -0
  46. data/lib/omnibus/{templates → generator_files}/mac_pkg/background.png +0 -0
  47. data/lib/omnibus/{templates → generator_files}/mac_pkg/license.html.erb +0 -0
  48. data/lib/omnibus/{templates → generator_files}/mac_pkg/welcome.html.erb +0 -0
  49. data/lib/omnibus/{templates → generator_files}/omnibus.rb.example.erb +0 -0
  50. data/lib/omnibus/{templates → generator_files}/package_scripts/makeselfinst.erb +0 -0
  51. data/lib/omnibus/{templates → generator_files}/package_scripts/postinst.erb +0 -0
  52. data/lib/omnibus/{templates → generator_files}/package_scripts/postrm.erb +0 -0
  53. data/lib/omnibus/{templates → generator_files}/package_scripts/preinst.erb +0 -0
  54. data/lib/omnibus/{templates → generator_files}/package_scripts/prerm.erb +0 -0
  55. data/lib/omnibus/{templates → generator_files}/project.rb.erb +0 -1
  56. data/lib/omnibus/{templates → generator_files}/software/c-example.rb.erb +0 -0
  57. data/lib/omnibus/{templates → generator_files}/software/erlang-example.rb.erb +0 -0
  58. data/lib/omnibus/{templates → generator_files}/software/ruby-example.rb.erb +0 -0
  59. data/lib/omnibus/generator_files/windows_msi/assets/LICENSE.rtf +8 -0
  60. data/lib/omnibus/generator_files/windows_msi/assets/banner_background.bmp +0 -0
  61. data/lib/omnibus/generator_files/windows_msi/assets/dialog_background.bmp +0 -0
  62. data/lib/omnibus/generator_files/windows_msi/assets/project.ico +0 -0
  63. data/lib/omnibus/generator_files/windows_msi/assets/project_16x16.ico +0 -0
  64. data/lib/omnibus/generator_files/windows_msi/assets/project_32x32.ico +0 -0
  65. data/lib/omnibus/generator_files/windows_msi/localization-en-us.wxl.erb +20 -0
  66. data/lib/omnibus/generator_files/windows_msi/parameters.wxi.erb +9 -0
  67. data/lib/omnibus/generator_files/windows_msi/source.wxs.erb +74 -0
  68. data/lib/omnibus/health_check.rb +80 -40
  69. data/lib/omnibus/install_path_cache.rb +11 -12
  70. data/lib/omnibus/library.rb +30 -3
  71. data/lib/omnibus/logger.rb +47 -0
  72. data/lib/omnibus/logging.rb +60 -0
  73. data/lib/omnibus/null_builder.rb +23 -0
  74. data/lib/omnibus/ohai.rb +70 -0
  75. data/lib/omnibus/overrides.rb +69 -48
  76. data/lib/omnibus/package_release.rb +7 -14
  77. data/lib/omnibus/packagers/base.rb +66 -13
  78. data/lib/omnibus/packagers/mac_dmg.rb +23 -3
  79. data/lib/omnibus/packagers/mac_pkg.rb +20 -10
  80. data/lib/omnibus/packagers/windows_msi.rb +109 -0
  81. data/lib/omnibus/project.rb +136 -79
  82. data/lib/omnibus/reports.rb +1 -2
  83. data/lib/omnibus/{s3_cacher.rb → s3_cache.rb} +15 -37
  84. data/lib/omnibus/software.rb +77 -27
  85. data/lib/omnibus/software_s3_urls.rb +50 -0
  86. data/lib/omnibus/sugar.rb +1 -3
  87. data/lib/omnibus/util.rb +45 -18
  88. data/lib/omnibus/version.rb +2 -3
  89. data/omnibus.gemspec +5 -3
  90. data/spec/data/complicated/config/patches/bzip2/makefile_take_env_vars.patch +15 -0
  91. data/spec/data/complicated/config/patches/couchdb/patch_for_couchjs_stack.patch +19 -0
  92. data/spec/data/complicated/config/patches/gd/gd-2.0.33-configure-libpng.patch +100 -0
  93. data/spec/data/complicated/config/patches/keepalived/keepalived-1.2.9_opscode_centos_5.patch +15 -0
  94. data/spec/data/complicated/config/patches/libedit/freebsd-vi-fix.patch +24 -0
  95. data/spec/data/complicated/config/patches/libiconv/libiconv-1.14_srclib_stdio.in.h-remove-gets-declarations.patch +29 -0
  96. data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-makefile-dest-fix.patch +35 -0
  97. data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-malloc-fix.patch +13 -0
  98. data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-shared_lib_plus_plus-1.patch +1035 -0
  99. data/spec/data/complicated/config/patches/logrotate/logrotate_basedir_override.patch +12 -0
  100. data/spec/data/complicated/config/patches/ncurses/ncurses-5.9-solaris-xopen_source_extended-detection.patch +11 -0
  101. data/spec/data/complicated/config/patches/ncurses/ncurses-clang.patch +42 -0
  102. data/spec/data/complicated/config/patches/ncurses/patch-aa +23 -0
  103. data/spec/data/complicated/config/patches/ncurses/patch-ab +44 -0
  104. data/spec/data/complicated/config/patches/ncurses/patch-ac +40 -0
  105. data/spec/data/complicated/config/patches/ncurses/patch-ad +12 -0
  106. data/spec/data/complicated/config/patches/ncurses/patch-aix-configure +23 -0
  107. data/spec/data/complicated/config/patches/ncurses/patch-cxx_cursesf.h +22 -0
  108. data/spec/data/complicated/config/patches/ncurses/patch-cxx_cursesm.h +22 -0
  109. data/spec/data/complicated/config/patches/nrpe/fix_for_runit.patch +64 -0
  110. data/spec/data/complicated/config/patches/openssl/openssl-1.0.1f-do-not-build-docs.patch +101 -0
  111. data/spec/data/complicated/config/patches/postgresql/postgresql-9.1.2-configure-ncurses-fix.patch +12 -0
  112. data/spec/data/complicated/config/patches/ruby/patch-configure +103 -0
  113. data/spec/data/complicated/config/patches/ruby/ruby-aix-configure.patch +10 -0
  114. data/spec/data/complicated/config/patches/ruby/ruby-openssl-1.0.1c.patch +42 -0
  115. data/spec/data/complicated/config/patches/ruby/ruby_aix_1_9_3_448_ssl_EAGAIN.patch +57 -0
  116. data/spec/data/complicated/config/patches/ruby/rvm-cflags.patch +27 -0
  117. data/spec/data/complicated/config/projects/angrychef.rb +32 -0
  118. data/spec/data/complicated/config/projects/chef-windows.rb +32 -0
  119. data/spec/data/complicated/config/projects/chef.rb +32 -0
  120. data/spec/data/complicated/config/projects/chefdk-windows.rb +41 -0
  121. data/spec/data/complicated/config/projects/chefdk.rb +44 -0
  122. data/spec/data/complicated/config/software/appbundler.rb +25 -0
  123. data/spec/data/complicated/config/software/autoconf.rb +35 -0
  124. data/spec/data/complicated/config/software/automake.rb +39 -0
  125. data/spec/data/complicated/config/software/berkshelf.rb +44 -0
  126. data/{lib/omnibus/fetchers.rb → spec/data/complicated/config/software/bundler.rb} +8 -5
  127. data/spec/data/complicated/config/software/bzip2.rb +46 -0
  128. data/spec/data/complicated/config/software/cacerts.rb +44 -0
  129. data/spec/data/complicated/config/software/chef-client-msi.rb +88 -0
  130. data/spec/data/complicated/config/software/chef-gem.rb +26 -0
  131. data/spec/data/complicated/config/software/chef-vault.rb +43 -0
  132. data/spec/data/complicated/config/software/chef-windows.rb +158 -0
  133. data/spec/data/complicated/config/software/chef.rb +170 -0
  134. data/spec/data/complicated/config/software/chefdk.rb +103 -0
  135. data/spec/data/complicated/config/software/couchdb.rb +53 -0
  136. data/spec/data/complicated/config/software/curl.rb +48 -0
  137. data/spec/data/complicated/config/software/erlang.rb +65 -0
  138. data/spec/data/complicated/config/software/expat.rb +21 -0
  139. data/spec/data/complicated/config/software/fcgi.rb +56 -0
  140. data/spec/data/complicated/config/software/fcgiwrap.rb +41 -0
  141. data/spec/data/complicated/config/software/gd.rb +56 -0
  142. data/spec/data/complicated/config/software/gdbm.rb +40 -0
  143. data/spec/data/complicated/config/software/gecode.rb +48 -0
  144. data/spec/data/complicated/config/software/git.rb +40 -0
  145. data/spec/data/complicated/config/software/help2man.rb +30 -0
  146. data/spec/data/complicated/config/software/icu.rb +40 -0
  147. data/spec/data/complicated/config/software/jre.rb +48 -0
  148. data/spec/data/complicated/config/software/keepalived.rb +43 -0
  149. data/spec/data/complicated/config/software/libarchive.rb +50 -0
  150. data/spec/data/complicated/config/software/libedit.rb +69 -0
  151. data/spec/data/complicated/config/software/libffi.rb +71 -0
  152. data/spec/data/complicated/config/software/libgcc.rb +39 -0
  153. data/spec/data/complicated/config/software/libiconv.rb +66 -0
  154. data/spec/data/complicated/config/software/libjpeg.rb +39 -0
  155. data/spec/data/complicated/config/software/libpng.rb +38 -0
  156. data/spec/data/complicated/config/software/libtool.rb +52 -0
  157. data/spec/data/complicated/config/software/libwrap.rb +50 -0
  158. data/spec/data/complicated/config/software/libxml2.rb +51 -0
  159. data/spec/data/complicated/config/software/libxslt.rb +52 -0
  160. data/spec/data/complicated/config/software/libyaml-windows.rb +43 -0
  161. data/spec/data/complicated/config/software/libyaml.rb +62 -0
  162. data/spec/data/complicated/config/software/logrotate.rb +41 -0
  163. data/spec/data/complicated/config/software/makedepend.rb +73 -0
  164. data/spec/data/complicated/config/software/mysql2.rb +42 -0
  165. data/spec/data/complicated/config/software/nagios-plugins.rb +53 -0
  166. data/spec/data/complicated/config/software/nagios.rb +66 -0
  167. data/spec/data/complicated/config/software/ncurses.rb +149 -0
  168. data/spec/data/complicated/config/software/nginx.rb +40 -0
  169. data/spec/data/complicated/config/software/nodejs.rb +44 -0
  170. data/spec/data/complicated/config/software/nokogiri.rb +55 -0
  171. data/spec/data/complicated/config/software/nrpe.rb +61 -0
  172. data/spec/data/complicated/config/software/ohai.rb +64 -0
  173. data/spec/data/complicated/config/software/omnibus-ctl.rb +34 -0
  174. data/spec/data/complicated/config/software/openresty.rb +67 -0
  175. data/spec/data/complicated/config/software/openssl.rb +158 -0
  176. data/spec/data/complicated/config/software/pcre.rb +42 -0
  177. data/spec/data/complicated/config/software/perl-extutils-embed.rb +15 -0
  178. data/spec/data/complicated/config/software/perl-extutils-makemaker.rb +15 -0
  179. data/spec/data/complicated/config/software/perl.rb +48 -0
  180. data/spec/data/complicated/config/software/perl_pg_driver.rb +12 -0
  181. data/spec/data/complicated/config/software/php.rb +41 -0
  182. data/spec/data/complicated/config/software/pip.rb +30 -0
  183. data/spec/data/complicated/config/software/pkg-config.rb +66 -0
  184. data/spec/data/complicated/config/software/popt.rb +47 -0
  185. data/spec/data/complicated/config/software/postgresql.rb +51 -0
  186. data/spec/data/complicated/config/software/preparation.rb +30 -0
  187. data/spec/data/complicated/config/software/pygments.rb +25 -0
  188. data/spec/data/complicated/config/software/python.rb +49 -0
  189. data/spec/data/complicated/config/software/rabbitmq.rb +36 -0
  190. data/spec/data/complicated/config/software/rebar.rb +36 -0
  191. data/spec/data/complicated/config/software/redis.rb +33 -0
  192. data/spec/data/complicated/config/software/rsync.rb +48 -0
  193. data/spec/data/complicated/config/software/ruby-windows-devkit.rb +30 -0
  194. data/spec/data/complicated/config/software/ruby-windows.rb +30 -0
  195. data/spec/data/complicated/config/software/ruby.rb +162 -0
  196. data/spec/data/complicated/config/software/rubygems-customization.rb +57 -0
  197. data/spec/data/complicated/config/software/rubygems.rb +37 -0
  198. data/spec/data/complicated/config/software/runit.rb +118 -0
  199. data/spec/data/complicated/config/software/server-jre.rb +46 -0
  200. data/spec/data/complicated/config/software/setuptools.rb +30 -0
  201. data/spec/data/complicated/config/software/spawn-fcgi.rb +40 -0
  202. data/spec/data/complicated/config/software/sphinx.rb +26 -0
  203. data/spec/data/complicated/config/software/spidermonkey.rb +60 -0
  204. data/spec/data/complicated/config/software/sqitch.rb +24 -0
  205. data/spec/data/complicated/config/software/test-kitchen.rb +39 -0
  206. data/spec/data/complicated/config/software/unicorn.rb +27 -0
  207. data/spec/data/complicated/config/software/util-macros.rb +46 -0
  208. data/spec/data/complicated/config/software/version-manifest.rb +32 -0
  209. data/spec/data/complicated/config/software/xproto.rb +46 -0
  210. data/spec/data/complicated/config/software/yajl.rb +30 -0
  211. data/spec/data/complicated/config/software/zlib.rb +67 -0
  212. data/spec/data/projects/chefdk.rb +4 -4
  213. data/spec/data/projects/sample.rb +3 -0
  214. data/spec/data/software/erchef.rb +1 -1
  215. data/spec/fixtures/sample/files/windows_msi/Resources/assets/LICENSE.rtf +8 -0
  216. data/spec/fixtures/sample/files/windows_msi/Resources/assets/banner_background.bmp +0 -0
  217. data/spec/fixtures/sample/files/windows_msi/Resources/assets/dialog_background.bmp +0 -0
  218. data/spec/fixtures/sample/files/windows_msi/Resources/assets/project.ico +0 -0
  219. data/spec/fixtures/sample/files/windows_msi/Resources/assets/project_16x16.ico +0 -0
  220. data/spec/fixtures/sample/files/windows_msi/Resources/assets/project_32x32.ico +0 -0
  221. data/spec/fixtures/sample/files/windows_msi/Resources/localization-en-us.wxl +20 -0
  222. data/spec/fixtures/sample/files/windows_msi/Resources/parameters.wxi.erb +9 -0
  223. data/spec/fixtures/sample/files/windows_msi/Resources/source.wxs +74 -0
  224. data/spec/functional/packagers/mac_spec.rb +3 -20
  225. data/spec/functional/packagers/windows_spec.rb +69 -0
  226. data/spec/spec_helper.rb +79 -1
  227. data/spec/unit/artifact_spec.rb +0 -18
  228. data/spec/unit/build_version_dsl_spec.rb +136 -0
  229. data/spec/unit/build_version_spec.rb +185 -198
  230. data/spec/unit/config_spec.rb +18 -1
  231. data/spec/unit/fetchers/git_fetcher_spec.rb +55 -80
  232. data/spec/unit/fetchers/net_fetcher_spec.rb +11 -21
  233. data/spec/unit/install_path_cache_spec.rb +164 -136
  234. data/spec/unit/library_spec.rb +125 -5
  235. data/spec/unit/omnibus_spec.rb +25 -9
  236. data/spec/unit/overrides_spec.rb +2 -14
  237. data/spec/unit/package_release_spec.rb +0 -18
  238. data/spec/unit/packagers/base_spec.rb +84 -21
  239. data/spec/unit/packagers/mac_pkg_spec.rb +34 -24
  240. data/spec/unit/project_spec.rb +100 -102
  241. data/spec/unit/s3_cacher_spec.rb +0 -18
  242. data/spec/unit/software_spec.rb +152 -6
  243. data/spec/{sugar_spec.rb → unit/sugar_spec.rb} +0 -3
  244. metadata +365 -38
  245. data/lib/omnibus/cli/application.rb +0 -147
  246. data/lib/omnibus/cli/build.rb +0 -64
@@ -1,6 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
3
- # License:: Apache License, Version 2.0
2
+ # Copyright 2012-2014 Chef Software, Inc.
4
3
  #
5
4
  # Licensed under the Apache License, Version 2.0 (the "License");
6
5
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
3
- # License:: Apache License, Version 2.0
2
+ # Copyright 2012-2014 Chef Software, Inc.
4
3
  #
5
4
  # Licensed under the Apache License, Version 2.0 (the "License");
6
5
  # you may not use this file except in compliance with the License.
@@ -17,37 +16,15 @@
17
16
 
18
17
  require 'fileutils'
19
18
  require 'uber-s3'
20
- require 'omnibus/fetchers'
21
19
 
22
20
  module Omnibus
23
- module SoftwareS3URLs
24
- class InsufficientSpecification < ArgumentError
25
- end
26
-
27
- def config
28
- Omnibus.config
29
- end
30
-
31
- def url_for(software)
32
- "http://#{config.s3_bucket}.s3.amazonaws.com/#{key_for_package(software)}"
33
- end
34
-
35
- private
36
-
37
- def key_for_package(package)
38
- package.name || fail(InsufficientSpecification, "Software must have a name to cache it in S3 (#{package.inspect})")
39
- package.version || fail(InsufficientSpecification, "Software must set a version to cache it in S3 (#{package.inspect})")
40
- package.checksum || fail(InsufficientSpecification, "Software must specify a checksum (md5) to cache it in S3 (#{package.inspect})")
41
- "#{package.name}-#{package.version}-#{package.checksum}"
42
- end
43
- end
44
-
45
21
  class S3Cache
22
+ include Logging
46
23
  include SoftwareS3URLs
47
24
 
48
25
  def initialize
49
26
  unless config.s3_bucket && config.s3_access_key && config.s3_secret_key
50
- fail InvalidS3Configuration.new(config.s3_bucket, config.s3_access_key, config.s3_secret_key)
27
+ raise InvalidS3Configuration.new(config.s3_bucket, config.s3_access_key, config.s3_secret_key)
51
28
  end
52
29
  @client = UberS3.new(
53
30
  access_key: config.s3_access_key,
@@ -57,10 +34,6 @@ module Omnibus
57
34
  )
58
35
  end
59
36
 
60
- def log(msg)
61
- puts "[S3 Cacher] #{msg}"
62
- end
63
-
64
37
  def config
65
38
  Omnibus.config
66
39
  end
@@ -92,7 +65,10 @@ module Omnibus
92
65
  key = key_for_package(software)
93
66
  content = IO.read(software.project_file)
94
67
 
95
- log "Uploading #{software.project_file} as #{config.s3_bucket}/#{key}"
68
+ log.info(log_key) do
69
+ "Uploading #{software.project_file} as #{config.s3_bucket}/#{key}"
70
+ end
71
+
96
72
  @client.store(key, content, access: :public_read, content_md5: software.checksum)
97
73
  end
98
74
  end
@@ -110,22 +86,24 @@ module Omnibus
110
86
  end
111
87
 
112
88
  def fetch(software)
113
- log "Fetching #{software.name}"
89
+ log.info(log_key) { "Fetching #{software.name}" }
114
90
  fetcher = Fetcher.without_caching_for(software)
115
91
  if fetcher.fetch_required?
92
+ log.debug(log_key) { 'Updating cache' }
116
93
  fetcher.download
117
94
  fetcher.verify_checksum!
118
95
  else
119
- log 'Cached copy up to date, skipping.'
96
+ log.debug(log_key) { 'Cached copy up to date, skipping.' }
120
97
  end
121
98
  end
122
99
 
123
100
  def bucket
124
101
  @bucket ||= begin
125
- b = UberS3::Bucket.new(@client, @client.bucket)
126
- # creating the bucket is idempotent, make sure it's created:
127
- @client.connection.put('/')
128
- b
102
+ if @client.exists?('/')
103
+ @client.bucket
104
+ else
105
+ @client.connection.put('/')
106
+ end
129
107
  end
130
108
  end
131
109
  end
@@ -1,6 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2012 Opscode, Inc.
3
- # License:: Apache License, Version 2.0
2
+ # Copyright 2012 Chef Software, Inc.
4
3
  #
5
4
  # Licensed under the Apache License, Version 2.0 (the "License");
6
5
  # you may not use this file except in compliance with the License.
@@ -16,21 +15,18 @@
16
15
  #
17
16
 
18
17
  require 'digest/md5'
19
- require 'mixlib/shellout'
20
18
  require 'net/ftp'
21
19
  require 'net/http'
22
20
  require 'net/https'
23
21
  require 'uri'
24
22
 
25
- require 'omnibus/fetcher'
26
- require 'omnibus/builder'
27
- require 'omnibus/config'
28
-
29
23
  require 'fileutils'
30
24
 
31
25
  module Omnibus
32
26
  # Omnibus software DSL reader
33
27
  class Software
28
+ include Logging
29
+
34
30
  NULL_ARG = Object.new
35
31
  UNINITIALIZED = Object.new
36
32
 
@@ -90,7 +86,11 @@ module Omnibus
90
86
 
91
87
  @dependencies = []
92
88
  @whitelist_files = []
93
- instance_eval(io, filename, 0)
89
+ instance_eval(io, filename)
90
+ end
91
+
92
+ def <=>(other)
93
+ self.name <=> other.name
94
94
  end
95
95
 
96
96
  # Retrieves the override_version
@@ -100,7 +100,11 @@ module Omnibus
100
100
  # @todo: can't we just use #version here or are we testing this against nil? somewhere and
101
101
  # not using #overridden?
102
102
  def override_version
103
- $stderr.puts 'The #override_version is DEPRECATED, please use #version or test with #overridden?'
103
+ log.deprecated(log_key) do
104
+ 'Software#override_version. Please use #version or ' \
105
+ 'test with #overridden?'
106
+ end
107
+
104
108
  overrides[:version]
105
109
  end
106
110
 
@@ -126,7 +130,7 @@ module Omnibus
126
130
  # @return [String]
127
131
  def name(val = NULL_ARG)
128
132
  @name = val unless val.equal?(NULL_ARG)
129
- @name || fail(MissingSoftwareConfiguration.new(name, 'name', 'libxslt'))
133
+ @name || raise(MissingSoftwareConfiguration.new(name, 'name', 'libxslt'))
130
134
  end
131
135
 
132
136
  # Sets the description of the software
@@ -188,7 +192,10 @@ module Omnibus
188
192
  #
189
193
  # @todo: remove this in favor of default_version
190
194
  def given_version
191
- $stderr.puts "Getting the default version via #given_version is DEPRECATED, please use 'default_version'"
195
+ log.deprecated(log_key) do
196
+ 'Software#given_version. Please use #default_version instead.'
197
+ end
198
+
192
199
  default_version
193
200
  end
194
201
 
@@ -214,7 +221,7 @@ module Omnibus
214
221
  def version(val = NULL_ARG)
215
222
  if block_given?
216
223
  if val.equal?(NULL_ARG)
217
- fail 'block needs a version argument to apply against'
224
+ raise 'block needs a version argument to apply against'
218
225
  else
219
226
  if val == apply_overrides(:version)
220
227
  yield
@@ -222,7 +229,9 @@ module Omnibus
222
229
  end
223
230
  else
224
231
  unless val.equal?(NULL_ARG)
225
- $stderr.puts "Setting the version via 'version' is DEPRECATED, please use 'default_version'"
232
+ log.deprecated(log_key) do
233
+ 'Software#version. Please use #default_version instead.'
234
+ end
226
235
  @version = val
227
236
  end
228
237
  end
@@ -257,6 +266,15 @@ module Omnibus
257
266
  @project.build_version
258
267
  end
259
268
 
269
+ # Returns the version to be used in cache.
270
+ def version_for_cache
271
+ if fetcher
272
+ fetcher.version_for_cache || version
273
+ else
274
+ version
275
+ end
276
+ end
277
+
260
278
  # @todo Judging by existing usage, this should sensibly default to
261
279
  # the name of the software, since that's what it effectively does down in #project_dir
262
280
  def relative_path(val)
@@ -270,7 +288,7 @@ module Omnibus
270
288
  # implementation
271
289
  # @todo Why the caching of the URI?
272
290
  def source_uri
273
- @source_uri ||= URI(@source[:url])
291
+ @source_uri ||= URI(source[:url])
274
292
  end
275
293
 
276
294
  # @param val [Boolean]
@@ -295,7 +313,7 @@ module Omnibus
295
313
  # across two classes, one of which is a specific interface
296
314
  # implementation
297
315
  def checksum
298
- @source[:md5]
316
+ source[:md5]
299
317
  end
300
318
 
301
319
  # @todo Should this ever be legitimately used in the DSL? It
@@ -335,8 +353,8 @@ module Omnibus
335
353
  # @todo It seems like this isn't used, and if it were, it should
336
354
  # probably be part of Opscode::Builder instead
337
355
  def max_build_jobs
338
- if OHAI.cpu && OHAI.cpu[:total] && OHAI.cpu[:total].to_s =~ /^\d+$/
339
- OHAI.cpu[:total].to_i + 1
356
+ if Ohai.cpu && Ohai.cpu[:total] && Ohai.cpu[:total].to_s =~ /^\d+$/
357
+ Ohai.cpu[:total].to_i + 1
340
358
  else
341
359
  3
342
360
  end
@@ -408,20 +426,20 @@ module Omnibus
408
426
  #
409
427
  # @return [String]
410
428
  def platform
411
- OHAI.platform
429
+ Ohai.platform
412
430
  end
413
431
 
414
432
  # Return the architecture of the machine, as determined by Ohai.
415
433
  # @return [String] Either "sparc" or "intel", as appropriate
416
434
  # @todo Is this used? Doesn't appear to be...
417
435
  def architecture
418
- OHAI.kernel['machine'] =~ /sun/ ? 'sparc' : 'intel'
436
+ Ohai.kernel['machine'] =~ /sun/ ? 'sparc' : 'intel'
419
437
  end
420
438
 
421
439
  # Actually build the software package
422
440
  def build_me
423
441
  # Fetch the source
424
- fetcher = fetch_me
442
+ @fetcher = fetch_me
425
443
 
426
444
  # Build if we need to
427
445
  if always_build?
@@ -433,6 +451,8 @@ module Omnibus
433
451
  execute_build(fetcher)
434
452
  end
435
453
  end
454
+
455
+ project.build_version_dsl.resolve(self)
436
456
  true
437
457
  end
438
458
 
@@ -454,6 +474,30 @@ module Omnibus
454
474
  fetcher
455
475
  end
456
476
 
477
+ # A PATH variable format string representing the current PATH with the
478
+ # project's embedded/bin directory prepended. The correct path separator
479
+ # for the platform is used to join the paths.
480
+ #
481
+ # @return [String]
482
+ def path_with_embedded
483
+ prepend_path("#{install_dir}/bin", "#{install_dir}/embedded/bin")
484
+ end
485
+
486
+ # A PATH variable format string representing the current PATH with the
487
+ # given path prepended. The correct path separator
488
+ # for the platform is used to join the paths.
489
+ #
490
+ # @param paths [String]
491
+ # @param paths [Array<String>]
492
+ # @return [String]
493
+ def prepend_path(*paths)
494
+ path_values = Array(paths)
495
+ path_values << ENV['PATH']
496
+
497
+ separator = File::PATH_SEPARATOR || ':'
498
+ path_values.join(separator)
499
+ end
500
+
457
501
  private
458
502
 
459
503
  # Apply overrides in the @overrides hash that mask instance variables
@@ -470,19 +514,21 @@ module Omnibus
470
514
  end
471
515
  end
472
516
 
473
- # @todo What?!
474
- # @todo It seems that this is not used... remove it
475
- # @deprecated Use something else (?)
476
- def command(*args)
477
- fail 'Method Moved.'
517
+ # @todo Remove this in the next major release
518
+ def command(*)
519
+ log.deprecated(log_key) do
520
+ 'Software#command. Please use something else.'
521
+ end
522
+
523
+ raise 'Method Moved.'
478
524
  end
479
525
 
480
526
  def execute_build(fetcher)
481
527
  fetcher.clean
482
528
  @builder.build
483
- puts "[software:#{name}] caching build"
529
+ log.info(log_key) { 'Caching build' }
484
530
  Omnibus::InstallPathCache.new(install_dir, self).incremental
485
- puts "[software:#{name}] has dirtied the cache"
531
+ log.info(log_key) { 'Dirtied the cache!' }
486
532
  project.dirty_cache = true
487
533
  end
488
534
 
@@ -491,5 +537,9 @@ module Omnibus
491
537
  f.print ''
492
538
  end
493
539
  end
540
+
541
+ def log_key
542
+ @log_key ||= "#{super}: #{name}"
543
+ end
494
544
  end
495
545
  end
@@ -0,0 +1,50 @@
1
+ #
2
+ # Copyright 2013-2014 Chef Software, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ module Omnibus
18
+ module SoftwareS3URLs
19
+ class InsufficientSpecification < ArgumentError
20
+ def initialize(key, package)
21
+ @key, @package = key, package
22
+ end
23
+
24
+ def to_s
25
+ "Software must specify a #{@key} to cache it in S3 (#{@package})!"
26
+ end
27
+ end
28
+
29
+ def config
30
+ Omnibus.config
31
+ end
32
+
33
+ def url_for(software)
34
+ "http://#{config.s3_bucket}.s3.amazonaws.com/#{key_for_package(software)}"
35
+ end
36
+
37
+ private
38
+
39
+ def key_for_package(package)
40
+ return @key_for_package if @key_for_package
41
+
42
+ package.name || raise(InsufficientSpecification.new(:name, package))
43
+ package.version || raise(InsufficientSpecification.new(:version, package))
44
+ package.checksum || raise(InsufficientSpecification.new(:checksum, package))
45
+
46
+ @key_for_package = "#{package.name}-#{package.version}-#{package.checksum}"
47
+ @key_for_package
48
+ end
49
+ end
50
+ end
@@ -28,8 +28,6 @@ require 'chef/sugar/ruby'
28
28
  require 'chef/sugar/shell'
29
29
  require 'chef/sugar/vagrant'
30
30
 
31
- require 'omnibus/project'
32
-
33
31
  module Omnibus
34
32
  class Project
35
33
  private
@@ -39,7 +37,7 @@ module Omnibus
39
37
  # Omnibus project as if it were Chef. Otherwise, we would need to rewrite
40
38
  # all the DSL methods.
41
39
  def node
42
- OHAI
40
+ Ohai
43
41
  end
44
42
  end
45
43
  end
@@ -1,7 +1,5 @@
1
1
  #
2
- # Author:: Seth Chisamore (<schisamo@getchef.com>)
3
- # Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
4
- # License:: Apache License, Version 2.0
2
+ # Copyright 2013-2014 Chef Software, Inc.
5
3
  #
6
4
  # Licensed under the Apache License, Version 2.0 (the "License");
7
5
  # you may not use this file except in compliance with the License.
@@ -25,33 +23,28 @@ module Omnibus
25
23
  module Util
26
24
  # Shells out and runs +command+.
27
25
  #
28
- # @overload shellout(command, opts={})
26
+ # @overload shellout(command, options = {})
29
27
  # @param command [String]
30
- # @param opts [Hash] the options passed to the initializer of the
28
+ # @param options [Hash] the options passed to the initializer of the
31
29
  # +Mixlib::ShellOut+ instance.
32
- # @overload shellout(command_fragments, opts={})
30
+ # @overload shellout(command_fragments, options = {})
33
31
  # @param command [Array<String>] command argv as individual strings
34
- # @param opts [Hash] the options passed to the initializer of the
32
+ # @param options [Hash] the options passed to the initializer of the
35
33
  # +Mixlib::ShellOut+ instance.
36
34
  # @return [Mixlib::ShellOut] the underlying +Mixlib::ShellOut+ instance
37
35
  # which which has +stdout+, +stderr+, +status+, and +exitstatus+
38
36
  # populated with results of the command.
39
37
  #
40
- def shellout(*command_fragments)
41
- STDOUT.sync = true
42
-
43
- opts = if command_fragments.last.kind_of?(Hash)
44
- command_fragments.pop
45
- else
46
- {}
47
- end
38
+ def shellout(*args)
39
+ options = args.last.kind_of?(Hash) ? args.pop : {}
48
40
 
49
41
  default_options = {
50
42
  live_stream: STDOUT,
51
43
  timeout: 7200, # 2 hours
52
44
  environment: {},
53
45
  }
54
- cmd = Mixlib::ShellOut.new(*command_fragments, default_options.merge(opts))
46
+
47
+ cmd = Mixlib::ShellOut.new(*args, default_options.merge(options))
55
48
  cmd.run_command
56
49
  cmd
57
50
  end
@@ -64,10 +57,44 @@ module Omnibus
64
57
  # @raise [Mixlib::ShellOut::ShellCommandFailed] if +exitstatus+ is not in
65
58
  # the list of +valid_exit_codes+.
66
59
  #
67
- def shellout!(*command_fragments)
68
- cmd = shellout(*command_fragments)
60
+ def shellout!(*args)
61
+ cmd = shellout(*args)
69
62
  cmd.error!
70
63
  cmd
71
64
  end
65
+
66
+ #
67
+ # Run a command in subshell, suppressing any output.
68
+ #
69
+ # @see (Util#shellout)
70
+ #
71
+ def quiet_shellout(*args)
72
+ options = args.last.kind_of?(Hash) ? args.pop : {}
73
+ options[:live_stream] = nil
74
+ args << options
75
+ shellout(*args)
76
+ end
77
+
78
+ #
79
+ # Run a command, suppressing any output, but raising an error if the
80
+ # command fails.
81
+ #
82
+ # @see (Util#shellout!)
83
+ #
84
+ def quiet_shellout!(*args)
85
+ options = args.last.kind_of?(Hash) ? args.pop : {}
86
+ options[:live_stream] = nil
87
+ args << options
88
+ shellout!(*args)
89
+ end
90
+
91
+ # Replaces path separators with alternative ones when needed.
92
+ #
93
+ # @param path [String]
94
+ # @return [String] given path with applied changes.
95
+ #
96
+ def windows_safe_path!(path)
97
+ path.gsub!(File::SEPARATOR, File::ALT_SEPARATOR) if File::ALT_SEPARATOR
98
+ end
72
99
  end
73
100
  end