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.
@@ -15,13 +14,9 @@
15
14
  # limitations under the License.
16
15
  #
17
16
 
18
- require 'omnibus/exceptions'
19
-
20
17
  module Omnibus
21
18
  # Fetcher implementation for projects in git.
22
19
  class GitFetcher < Fetcher
23
- name :git
24
-
25
20
  attr_reader :source
26
21
  attr_reader :project_dir
27
22
  attr_reader :version
@@ -31,13 +26,14 @@ module Omnibus
31
26
  @source = software.source
32
27
  @version = software.version
33
28
  @project_dir = software.project_dir
29
+ super
34
30
  end
35
31
 
36
32
  def description
37
- <<-E
38
- repo URI: #{@source[:git]}
39
- local location: #{@project_dir}
40
- E
33
+ <<-EOH.gsub(/^ {8}/, '').strip
34
+ repo URI: #{@source[:git]}
35
+ local location: #{@project_dir}
36
+ EOH
41
37
  end
42
38
 
43
39
  def version_guid
@@ -47,11 +43,8 @@ E
47
43
 
48
44
  def clean
49
45
  if existing_git_clone?
50
- log 'cleaning existing build'
51
- clean_cmd = 'git clean -fdx'
52
- shell = Mixlib::ShellOut.new(clean_cmd, live_stream: STDOUT, cwd: project_dir)
53
- shell.run_command
54
- shell.error!
46
+ log.info(log_key) { 'Cleaning existing build' }
47
+ quiet_shellout!('git clean -fdx', cwd: project_dir)
55
48
  end
56
49
  rescue Exception => e
57
50
  ErrorReporter.new(e, self).explain("Failed to clean git repository '#{@source[:git]}'")
@@ -78,37 +71,43 @@ E
78
71
  # Deal with github failing all the time :(
79
72
  time_to_sleep = 5 * (2**retries)
80
73
  retries += 1
81
- log "git clone/fetch failed for #{@source} #{retries} time(s), retrying in #{time_to_sleep}s"
74
+ log.warn(log_key) do
75
+ "git clone/fetch failed for #{@source} #{retries} time(s). " \
76
+ "Retrying in #{time_to_sleep}s..."
77
+ end
82
78
  sleep(time_to_sleep)
83
79
  retry
84
80
  end
85
81
  end
86
82
 
83
+ # Return the target sha to be used during build caching
84
+ # This overrides the cases where software.version is similar to
85
+ # master, 11-stable etc..
86
+ def version_for_cache
87
+ target_revision
88
+ end
89
+
87
90
  private
88
91
 
89
92
  def clone
90
- puts 'cloning the source from git'
91
- clone_cmd = "git clone #{@source[:git]} #{project_dir}"
92
- shell = Mixlib::ShellOut.new(clone_cmd, live_stream: STDOUT)
93
- shell.run_command
94
- shell.error!
93
+ log.info(log_key) { 'Cloning the source from git' }
94
+ quiet_shellout!("git clone #{@source[:git]} #{project_dir}")
95
95
  end
96
96
 
97
97
  def checkout
98
98
  sha_ref = target_revision
99
-
100
- checkout_cmd = "git checkout #{sha_ref}"
101
- shell = Mixlib::ShellOut.new(checkout_cmd, live_stream: STDOUT, cwd: project_dir)
102
- shell.run_command
103
- shell.error!
99
+ quiet_shellout!("git checkout #{sha_ref}", cwd: project_dir)
104
100
  end
105
101
 
106
102
  def fetch_updates
107
- puts "fetching updates and resetting to revision #{target_revision}"
108
- fetch_cmd = "git fetch origin && git fetch origin --tags && git reset --hard #{target_revision}"
109
- shell = Mixlib::ShellOut.new(fetch_cmd, live_stream: STDOUT, cwd: project_dir)
110
- shell.run_command
111
- shell.error!
103
+ log.info(log_key) do
104
+ "Fetching updates and resetting to revision '#{target_revision}'"
105
+ end
106
+
107
+ fetch_cmd = "git fetch origin && " \
108
+ "git fetch origin --tags && " \
109
+ "git reset --hard #{target_revision}"
110
+ quiet_shellout!(fetch_cmd, cwd: project_dir)
112
111
  end
113
112
 
114
113
  def existing_git_clone?
@@ -120,24 +119,20 @@ E
120
119
  end
121
120
 
122
121
  def current_revision
123
- @current_rev ||= begin
124
- rev_cmd = 'git rev-parse HEAD'
125
- shell = Mixlib::ShellOut.new(rev_cmd, live_stream: STDOUT, cwd: project_dir)
126
- shell.run_command
127
- shell.error!
128
- output = shell.stdout
122
+ return @current_rev if @current_rev
129
123
 
130
- sha_hash?(output) ? output : nil
131
- end
124
+ cmd = quiet_shellout!('git rev-parse HEAD', cwd: project_dir)
125
+ stdout = cmd.stdout
126
+
127
+ @current_rev = sha_hash?(stdout) ? stdout : nil
128
+ @current_rev
132
129
  end
133
130
 
134
131
  def target_revision
135
- @target_rev ||= begin
136
- if sha_hash?(version)
137
- version
138
- else
139
- revision_from_remote_reference(version)
140
- end
132
+ @target_rev ||= if sha_hash?(version)
133
+ version
134
+ else
135
+ revision_from_remote_reference(version)
141
136
  end
142
137
  end
143
138
 
@@ -153,14 +148,11 @@ E
153
148
  # allows us to return the SHA of the tagged commit for annotated
154
149
  # tags. We take care to only return exact matches in
155
150
  # process_remote_list.
156
- cmd = "git ls-remote origin #{ref}*"
157
- shell = Mixlib::ShellOut.new(cmd, live_stream: STDOUT, cwd: project_dir)
158
- shell.run_command
159
- shell.error!
160
- commit_ref = process_remote_list(shell.stdout, ref)
151
+ cmd = quiet_shellout!("git ls-remote origin #{ref}*", cwd: project_dir)
152
+ commit_ref = process_remote_list(cmd.stdout, ref)
161
153
 
162
154
  unless commit_ref
163
- fail UnresolvableGitReference.new("Could not resolve `#{ref}' to a SHA.")
155
+ raise UnresolvableGitReference.new("Could not resolve `#{ref}' to a SHA.")
164
156
  end
165
157
  commit_ref
166
158
  rescue UnresolvableGitReference => e # skip retries
@@ -174,12 +166,15 @@ E
174
166
  rescue Exception => e
175
167
  if retries >= 3
176
168
  ErrorReporter.new(e, self).explain("Failed to find any commits for the ref '#{ref}'")
177
- fail
169
+ raise
178
170
  else
179
171
  # Deal with github failing all the time :(
180
172
  time_to_sleep = 5 * (2**retries)
181
173
  retries += 1
182
- log "git ls-remote failed for #{@source} #{retries} time(s), retrying in #{time_to_sleep}s"
174
+ log.warn(log_key) do
175
+ "git ls-remote failed for #{@source} #{retries} time(s). " \
176
+ "Retrying in #{time_to_sleep}s..."
177
+ end
183
178
  sleep(time_to_sleep)
184
179
  retry
185
180
  end
@@ -1,6 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
3
- # License:: Apache License, Version 2.0
2
+ # Copyright 2012-2014 Chef Software, Inc.
4
3
  #
5
4
  # Licensed under the Apache License, Version 2.0 (the "License");
6
5
  # you may not use this file except in compliance with the License.
@@ -24,8 +23,6 @@ module Omnibus
24
23
 
25
24
  # Fetcher Implementation for HTTP and FTP hosted tarballs
26
25
  class NetFetcher < Fetcher
27
- name :net
28
-
29
26
  attr_reader :name
30
27
  attr_reader :project_file
31
28
  attr_reader :source
@@ -41,14 +38,15 @@ module Omnibus
41
38
  @source_uri = software.source_uri
42
39
  @source_dir = software.source_dir
43
40
  @project_dir = software.project_dir
41
+ super
44
42
  end
45
43
 
46
44
  def description
47
- <<-E
48
- source URI: #{source_uri}
49
- checksum: #{@checksum}
50
- local location: #{@project_file}
51
- E
45
+ <<-EOH.gsub(/^ {8}/, '').strip
46
+ source URI: #{source_uri}
47
+ checksum: #{@checksum}
48
+ local location: #{@project_file}
49
+ EOH
52
50
  end
53
51
 
54
52
  def version_guid
@@ -61,7 +59,8 @@ E
61
59
 
62
60
  def clean
63
61
  if File.exist?(project_dir)
64
- log "cleaning existing build from #{project_dir}"
62
+ log.info(log_key) { "Cleaning existing build from #{project_dir}" }
63
+
65
64
  FileUtils.rm_rf(project_dir)
66
65
  end
67
66
  extract
@@ -72,13 +71,13 @@ E
72
71
  download
73
72
  verify_checksum!
74
73
  else
75
- log 'Cached copy of source tarball up to date'
74
+ log.debug(log_key) { 'Cached copy of source tarball up to date' }
76
75
  end
77
76
  end
78
77
 
79
78
  def get_with_redirect(url, headers, limit = 10)
80
- fail ArgumentError, 'HTTP redirect too deep' if limit == 0
81
- log "getting from #{url} with #{limit} redirects left"
79
+ raise ArgumentError, 'HTTP redirect too deep' if limit == 0
80
+ log.info(log_key) { "Getting from #{url} with #{limit} redirects left" }
82
81
 
83
82
  url = URI.parse(url) unless url.kind_of?(URI)
84
83
 
@@ -132,8 +131,8 @@ E
132
131
  def download
133
132
  tries = 5
134
133
  begin
135
- log "\033[1;31m#{source[:warning]}\033[0m" if source.key?(:warning)
136
- log "fetching #{project_file} from #{source_uri}"
134
+ log.warn(log_key) { source[:warning] } if source.key?(:warning)
135
+ log.info(log_key) { "Fetching #{project_file} from #{source_uri}" }
137
136
 
138
137
  case source_uri.scheme
139
138
  when /https?/
@@ -152,12 +151,12 @@ E
152
151
  ftp.close
153
152
  end
154
153
  else
155
- fail UnsupportedURIScheme, "Don't know how to download from #{source_uri}"
154
+ raise UnsupportedURIScheme, "Don't know how to download from #{source_uri}"
156
155
  end
157
156
  rescue Exception
158
157
  tries -= 1
159
158
  if tries != 0
160
- log 'retrying failed download...'
159
+ log.debug(log_key) { "Retrying failed download (#{tries})..." }
161
160
  retry
162
161
  else
163
162
  raise
@@ -171,25 +170,26 @@ E
171
170
  def verify_checksum!
172
171
  actual_md5 = Digest::MD5.file(project_file)
173
172
  unless actual_md5 == @checksum
174
- log "Invalid MD5 for #{@name}"
175
- log "Expected: #{@checksum}"
176
- log "Actual: #{actual_md5}"
177
- fail InvalidSourceFile, "Checksum of downloaded file #{project_file} doesn't match expected"
173
+ log.warn(log_key) { "Invalid MD5 for #{@name}" }
174
+ log.warn(log_key) { "Expected: #{@checksum}" }
175
+ log.warn(log_key) { "Actual: #{actual_md5}" }
176
+ raise InvalidSourceFile, "Checksum of downloaded file #{project_file} doesn't match expected"
178
177
  end
179
178
  end
180
179
 
181
180
  def extract
182
- log "extracting the source in #{project_file} to #{source_dir}"
181
+ log.info(log_key) do
182
+ "Extracting the source in '#{project_file}' to '#{source_dir}'"
183
+ end
184
+
183
185
  cmd = extract_cmd
184
186
  case cmd
185
187
  when Proc
186
188
  cmd.call
187
189
  when String
188
- shell = Mixlib::ShellOut.new(cmd, live_stream: STDOUT)
189
- shell.run_command
190
- shell.error!
190
+ quiet_shellout!(cmd)
191
191
  else
192
- fail "Don't know how to extract command for #{cmd.class} class"
192
+ raise "Don't know how to extract command for #{cmd.class} class"
193
193
  end
194
194
  rescue Exception => e
195
195
  ErrorReporter.new(e, self).explain("Failed to unpack archive at #{project_file} (#{e.class}: #{e.message.strip})")
@@ -210,7 +210,9 @@ E
210
210
  else
211
211
  # if we don't recognize the extension, simply copy over the file
212
212
  proc do
213
- log "#{project_file} not an archive. Copying to #{project_dir}"
213
+ log.debug(log_key) do
214
+ "'#{project_file}' is not an archive. Copying to '#{project_dir}'..."
215
+ end
214
216
  # WARNING: hack hack hack, no project dir yet
215
217
  FileUtils.mkdir_p(project_dir)
216
218
  FileUtils.cp(project_file, project_dir)
@@ -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.
@@ -18,33 +17,31 @@
18
17
  module Omnibus
19
18
  # Fetcher implementation for projects on the filesystem
20
19
  class PathFetcher < Fetcher
21
- name :path
22
-
23
20
  def initialize(software)
24
21
  @name = software.name
25
22
  @source = software.source
26
23
  @project_dir = software.project_dir
27
24
  @version = software.version
25
+ super
28
26
  end
29
27
 
30
28
  def description
31
- <<-E
32
- source path: #{@source[:path]}
33
- local location: #{@project_dir}
34
- E
29
+ <<-EOH.gsub(/^ {8}/, '').strip
30
+ source path: #{@source[:path]}
31
+ local location: #{@project_dir}
32
+ EOH
35
33
  end
36
34
 
37
35
  def rsync
38
- if OHAI.platform == 'windows'
36
+ if Ohai.platform == 'windows'
39
37
  # Robocopy's return code is 1 if it succesfully copies over the
40
38
  # files and 0 if the files are already existing at the destination
41
39
  sync_cmd = "robocopy #{@source[:path]}\\ #{@project_dir}\\ /MIR /S"
42
- shell = Mixlib::ShellOut.new(sync_cmd, returns: [0, 1])
40
+ quiet_shellout!(sync_cmd, returns: [0, 1])
43
41
  else
44
42
  sync_cmd = "rsync --delete -a #{@source[:path]}/ #{@project_dir}/"
45
- shell = Mixlib::ShellOut.new(sync_cmd)
43
+ quiet_shellout!(sync_cmd)
46
44
  end
47
- shell.run_command
48
45
  end
49
46
 
50
47
  def clean
@@ -1,6 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
3
- # License:: Apache License, Version 2.0
2
+ # Copyright 2013-2014 Chef Software, Inc.
4
3
  #
5
4
  # Licensed under the Apache License, Version 2.0 (the "License");
6
5
  # you may not use this file except in compliance with the License.
@@ -15,22 +14,20 @@
15
14
  # limitations under the License.
16
15
  #
17
16
 
18
- require 'omnibus/fetcher'
19
- require 'omnibus/s3_cacher'
20
-
21
17
  module Omnibus
22
18
  class S3CacheFetcher < NetFetcher
23
19
  include SoftwareS3URLs
24
20
 
25
- name :s3cache
26
-
27
21
  def initialize(software)
28
22
  @software = software
29
23
  super
30
24
  end
31
25
 
32
26
  def fetch
33
- log "S3 Cache enabled, #{name} will be fetched from S3 cache"
27
+ log.info(log_key) do
28
+ "S3 Cache enabled, '#{name}' will be fetched from S3 cache"
29
+ end
30
+
34
31
  super
35
32
  end
36
33
 
@@ -0,0 +1,131 @@
1
+ #
2
+ # Copyright 2014 Chef Software, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'thor'
18
+
19
+ module Omnibus
20
+ class Generator < Thor::Group
21
+ include Thor::Actions
22
+
23
+ namespace :new
24
+
25
+ argument :name,
26
+ banner: 'NAME',
27
+ desc: 'The name of the Omnibus project',
28
+ type: :string,
29
+ required: true
30
+
31
+ class_option :path,
32
+ banner: 'PATH',
33
+ aliases: '-p',
34
+ desc: 'The path to create the Omnibus project',
35
+ type: :string,
36
+ default: '.'
37
+
38
+ class << self
39
+ #
40
+ # Set the source root for Thor.
41
+ #
42
+ def source_root
43
+ File.expand_path('../generator_files', __FILE__)
44
+ end
45
+ end
46
+
47
+ def create_project_files
48
+ template('Gemfile.erb', "#{target}/Gemfile", template_options)
49
+ template('gitignore.erb', "#{target}/.gitignore", template_options)
50
+ template('README.md.erb', "#{target}/README.md", template_options)
51
+ template('omnibus.rb.example.erb', "#{target}/omnibus.rb.example", template_options)
52
+ end
53
+
54
+ def create_project_definition
55
+ template('project.rb.erb', "#{target}/config/projects/#{name}.rb", template_options)
56
+ end
57
+
58
+ def create_example_software_definitions
59
+ template('software/c-example.rb.erb', "#{target}/config/software/c-example.rb", template_options)
60
+ template('software/erlang-example.rb.erb', "#{target}/config/software/erlang-example.rb", template_options)
61
+ template('software/ruby-example.rb.erb', "#{target}/config/software/ruby-example.rb", template_options)
62
+ end
63
+
64
+ def create_kitchen_files
65
+ template('.kitchen.local.yml.erb', "#{target}/.kitchen.local.yml", template_options)
66
+ template('.kitchen.yml.erb', "#{target}/.kitchen.yml", template_options)
67
+ template('Berksfile.erb', "#{target}/Berksfile", template_options)
68
+ end
69
+
70
+ def create_package_scripts
71
+ %w(makeselfinst preinst prerm postinst postrm).each do |package_script|
72
+ script_path = "#{target}/package-scripts/#{name}/#{package_script}"
73
+ template("package_scripts/#{package_script}.erb", script_path, template_options)
74
+
75
+ # #nsure the package script is executable
76
+ chmod(script_path, 0755)
77
+ end
78
+ end
79
+
80
+ def create_pkg_assets
81
+ template('mac_pkg/license.html.erb', "#{target}/files/mac_pkg/Resources/license.html", template_options)
82
+ template('mac_pkg/welcome.html.erb', "#{target}/files/mac_pkg/Resources/welcome.html", template_options)
83
+ copy_file('mac_pkg/background.png', "#{target}/files/mac_pkg/Resources/background.png")
84
+ end
85
+
86
+ def create_dmg_assets
87
+ copy_file('mac_dmg/background.png', "#{target}/files/mac_dmg/Resources/background.png")
88
+ copy_file('mac_dmg/icon.png', "#{target}/files/mac_dmg/Resources/icon.png")
89
+ end
90
+
91
+ def create_windows_assets
92
+ # These ERB files are actually rendered as ERB files on the target system
93
+ # because the parameters are resolved at the build time for localization
94
+ # and parameters files.
95
+ copy_file('windows_msi/localization-en-us.wxl.erb', "#{target}/files/windows_msi/Resources/localization-en-us.wxl.erb")
96
+ copy_file('windows_msi/parameters.wxi.erb', "#{target}/files/windows_msi/Resources/parameters.wxi.erb")
97
+
98
+ template('windows_msi/source.wxs.erb', "#{target}/files/windows_msi/Resources/source.wxs", template_options)
99
+
100
+ copy_file('windows_msi/assets/LICENSE.rtf', "#{target}/files/windows_msi/Resources/assets/LICENSE.rtf")
101
+ copy_file('windows_msi/assets/banner_background.bmp', "#{target}/files/windows_msi/Resources/assets/banner_background.bmp")
102
+ copy_file('windows_msi/assets/dialog_background.bmp', "#{target}/files/windows_msi/Resources/assets/dialog_background.bmp")
103
+ copy_file('windows_msi/assets/project.ico', "#{target}/files/windows_msi/Resources/assets/project.ico")
104
+ copy_file('windows_msi/assets/project_16x16.ico', "#{target}/files/windows_msi/Resources/assets/project_16x16.ico")
105
+ copy_file('windows_msi/assets/project_32x32.ico', "#{target}/files/windows_msi/Resources/assets/project_32x32.ico")
106
+ end
107
+
108
+ private
109
+
110
+ #
111
+ # The target path to create the Omnibus project.
112
+ #
113
+ # @return [String]
114
+ #
115
+ def target
116
+ @target ||= File.join(File.expand_path(@options[:path]), "omnibus-#{name}")
117
+ end
118
+
119
+ #
120
+ # The list of options to pass to the template generators.
121
+ #
122
+ # @return [Hash]
123
+ #
124
+ def template_options
125
+ @template_options ||= {
126
+ name: name,
127
+ install_path: "/opt/#{name}",
128
+ }
129
+ end
130
+ end
131
+ end