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,4 @@
1
1
  require 'spec_helper'
2
- require 'omnibus/library'
3
- require 'omnibus/project'
4
2
 
5
3
  describe Omnibus::Library do
6
4
  let(:project) { Omnibus::Project.load(project_path('chefdk')) }
@@ -8,6 +6,15 @@ describe Omnibus::Library do
8
6
  let(:erchef) { Omnibus::Software.load(software_path('erchef'), project) }
9
7
  let(:zlib) { Omnibus::Software.load(software_path('zlib'), project) }
10
8
 
9
+ def gen_software(name, deps)
10
+ software = Omnibus::Software.new('', "#{name}.rb", 'chef-server')
11
+ software.name(name.to_s)
12
+ deps.each do |dep|
13
+ software.dependency(dep)
14
+ end
15
+ software
16
+ end
17
+
11
18
  describe '#component_added' do
12
19
  it 'adds the software to the component list' do
13
20
  library.component_added(erchef)
@@ -31,6 +38,7 @@ maintainer 'Chef Software, Inc'
31
38
  homepage 'http://getchef.com'
32
39
  dependency 'preparation'
33
40
  dependency 'erchef'
41
+ dependency 'postgresql'
34
42
  dependency 'chef'
35
43
  EOH
36
44
  Omnibus::Project.new(raw_project, 'chef-server.rb')
@@ -40,6 +48,7 @@ EOH
40
48
  library = Omnibus::Library.new(project)
41
49
  library.component_added(preparation)
42
50
  library.component_added(erlang)
51
+ library.component_added(postgresql) # as a skitch trans dep
43
52
  library.component_added(skitch)
44
53
  library.component_added(erchef)
45
54
  library.component_added(ruby)
@@ -47,7 +56,7 @@ EOH
47
56
  library
48
57
  end
49
58
 
50
- project_deps = [:preparation, :erchef, :chef]
59
+ project_deps = [:preparation, :erchef, :postgresql, :chef]
51
60
  erchef_deps = [:erlang, :skitch]
52
61
  chef_deps = [:ruby]
53
62
 
@@ -55,12 +64,123 @@ EOH
55
64
  let(dep) do
56
65
  software = Omnibus::Software.new('', "#{dep}.rb", 'chef-server')
57
66
  software.name(dep.to_s)
67
+ software.dependency('postgresql') if dep == :skitch
58
68
  software
59
69
  end
60
70
  end
61
71
 
62
- it 'returns an array of software descriptions, with all non top level deps first' do
63
- expect(library.build_order).to eql([preparation, erlang, skitch, ruby, erchef, chef])
72
+ it 'returns an array of software descriptions, with all top level deps first, assuming they are not themselves transitive deps' do
73
+ library.build_order.map { |m| m.name.to_s }
74
+ expect(library.build_order).to eql([preparation, erlang, postgresql, skitch, ruby, erchef, chef])
75
+ end
76
+
77
+ context 'with a complex dep tree' do
78
+ # rubocop:disable all
79
+ [
80
+ ['preparation', []],
81
+ ['erchef', ['erlang', 'skitch']],
82
+ ['postgresql', []],
83
+ ['erlang', []],
84
+ ['skitch', ['postgresql']],
85
+ ['chef', ['ruby', 'bundler', 'ohai']],
86
+ ['ohai', ['ruby']],
87
+ ['bundler', ['ruby']],
88
+ ['ruby', []],
89
+ ['chefdk', ['ruby', 'bundler']],
90
+ ].each do |item|
91
+ name = item[0]
92
+ deps = item[1]
93
+ let(name) do
94
+ gen_software(name, deps)
95
+ end
96
+ end
97
+
98
+ let(:project) do
99
+ raw_project = <<-EOH
100
+ name "chef-dk"
101
+ install_path "/opt/chefdk"
102
+ build_version "1.0.0"
103
+ maintainer 'Chef Software, Inc'
104
+ homepage 'http://getchef.com'
105
+ dependency 'preparation'
106
+ dependency 'erchef'
107
+ dependency 'postgresql'
108
+ dependency 'ruby'
109
+ dependency 'chef'
110
+ dependency 'chefdk'
111
+ EOH
112
+ Omnibus::Project.new(raw_project, 'chefdk.rb')
113
+ end
114
+
115
+ let(:library) do
116
+ # This is the LOAD ORDER
117
+ library = Omnibus::Library.new(project)
118
+ library.component_added(preparation) # via project
119
+ library.component_added(erlang) # via erchef
120
+ library.component_added(postgresql) # via skitch
121
+ library.component_added(skitch) # via erchef
122
+ library.component_added(erchef) # erchef
123
+ library.component_added(ruby) # via project
124
+ library.component_added(bundler) # via chef
125
+ library.component_added(ohai) # via chef
126
+ library.component_added(chef) # via project
127
+ library.component_added(chefdk) # via project
128
+ library
129
+ end
130
+
131
+ it 'returns an array of software descriptions, with all top level deps first, assuming they are not themselves transitive deps' do
132
+ expect(library.build_order).to eql(
133
+ [
134
+ preparation, # first
135
+ erlang, # via erchef project
136
+ postgresql, # via skitch transitive
137
+ skitch, # via erchef project
138
+ ruby, # via bundler transitive
139
+ bundler, # via chef
140
+ ohai, # via chef
141
+ erchef, # project dep
142
+ chef, # project dep
143
+ chefdk, # project dep
144
+ ])
145
+ end
146
+ end
147
+
148
+ context 'with real data' do
149
+ before do
150
+ Omnibus.stub(:project_root).and_return(complicated_path)
151
+
152
+ # Ohai stuff
153
+ stub_const('File::ALT_SEPARATOR', '\\')
154
+ stub_ohai(platform: 'windows')
155
+
156
+ Omnibus.process_dsl_files
157
+ end
158
+
159
+ after { Omnibus.reset! }
160
+
161
+ let(:chefdk_windows) do
162
+ Omnibus.projects.find { |p| p.name.to_s == 'chefdk-windows' }
163
+ end
164
+
165
+ it 'has the right build order for chefdk-windows on windows' do
166
+ names = chefdk_windows.library.build_order.map { |m| m.name.to_s }
167
+ expect(names).to eql([
168
+ 'preparation', # via project dep
169
+ 'ruby-windows', # via libyaml-windows trans dep
170
+ 'libyaml-windows', # via ruby-windows trans
171
+ 'ruby-windows-devkit', # via trans dep from chef-windows
172
+ 'bundler', # via trans dep from chef-windows
173
+ 'cacerts', # via chef-windows
174
+ 'chef-windows', # via transitive dep from chefdk
175
+ 'nokogiri', # via test-kitchen
176
+ 'test-kitchen', # via chefdk
177
+ 'appbundler', # via chefdk
178
+ 'berkshelf', # via chefdk
179
+ 'chef-vault', # via chefdk
180
+ 'chefdk', # via project dep
181
+ 'chef-client-msi', # via top level dep
182
+ ])
183
+ end
64
184
  end
65
185
  end
66
186
 
@@ -3,15 +3,8 @@ require 'spec_helper'
3
3
 
4
4
  describe Omnibus do
5
5
  # evil class variables
6
- before :each do
7
- Omnibus.class_eval { @omnibus_software_root = nil }
8
- Omnibus.class_eval { @software_dirs = nil }
9
- end
10
-
11
- after :each do
12
- Omnibus.class_eval { @omnibus_software_root = nil }
13
- Omnibus.class_eval { @software_dirs = nil }
14
- end
6
+ before { Omnibus.reset! }
7
+ after { Omnibus.reset! }
15
8
 
16
9
  describe '::omnibus_software_root' do
17
10
  it 'reads the software_gem out of Omnibus::Config.software_gem' do
@@ -56,4 +49,27 @@ describe Omnibus do
56
49
  end
57
50
  end
58
51
  end
52
+
53
+ describe '#process_dsl_files' do
54
+ before do
55
+ Omnibus.stub(:project_root).and_return(complicated_path)
56
+ stub_ohai(platform: 'linux')
57
+ end
58
+
59
+ after { Omnibus.reset! }
60
+
61
+ it 'populates the 5 projects' do
62
+ Omnibus.process_dsl_files
63
+
64
+ expect(Omnibus.projects.size).to eq(5)
65
+
66
+ names = Omnibus.projects.map(&:name)
67
+ expect(names).to include('angrychef')
68
+ expect(names).to include('chef-windows')
69
+ expect(names).to include('chef')
70
+ expect(names).to include('chefdk-windows')
71
+ expect(names).to include('chefdk')
72
+ end
73
+
74
+ end
59
75
  end
@@ -1,4 +1,3 @@
1
- require 'omnibus/overrides'
2
1
  require 'spec_helper'
3
2
 
4
3
  describe Omnibus::Overrides do
@@ -41,20 +40,9 @@ describe Omnibus::Overrides do
41
40
  end # parse_file
42
41
 
43
42
  describe '#resolve_override_file' do
44
- before :each do
45
- @original = ENV['OMNIBUS_OVERRIDE_FILE']
46
- ENV['OMNIBUS_OVERRIDE_FILE'] = env_override_file
47
- end
48
-
49
- after :each do
50
- ENV['OMNIBUS_OVERRIDE_FILE'] = @original
51
- end
52
-
53
43
  subject { Omnibus::Overrides.resolve_override_file }
54
44
 
55
45
  context 'with no environment variable set' do
56
- let(:env_override_file) { nil }
57
-
58
46
  before :each do
59
47
  stub_const('Omnibus::Overrides::DEFAULT_OVERRIDE_FILE_NAME', new_default_file)
60
48
  end
@@ -72,6 +60,8 @@ describe Omnibus::Overrides do
72
60
  end # no environment variable
73
61
 
74
62
  context 'with OMNIBUS_OVERRIDE_FILE environment variable set' do
63
+ before { stub_env('OMNIBUS_OVERRIDE_FILE', env_override_file) }
64
+
75
65
  context 'to an existing file' do
76
66
  let(:path) { overrides_path('good') }
77
67
  let(:env_override_file) { path }
@@ -91,8 +81,6 @@ describe Omnibus::Overrides do
91
81
  stub_const('Omnibus::Overrides::DEFAULT_OVERRIDE_FILE_NAME', new_default_file)
92
82
 
93
83
  expect(File.exist?(Omnibus::Overrides::DEFAULT_OVERRIDE_FILE_NAME)).to be_true
94
- expect(ENV['OMNIBUS_OVERRIDE_FILE']).to_not be_nil
95
-
96
84
  expect(subject).to be_nil
97
85
  end
98
86
  end
@@ -1,21 +1,3 @@
1
- #
2
- # Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
- require 'omnibus/package_release'
19
1
  require 'spec_helper'
20
2
 
21
3
  describe Omnibus::PackageRelease do
@@ -1,19 +1,4 @@
1
- #
2
- # Copyright:: Copyright (c) 2014 Chef Software, Inc.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
1
+ require 'stringio'
17
2
 
18
3
  module Omnibus
19
4
  describe Packager::Base do
@@ -28,6 +13,8 @@ module Omnibus
28
13
  files_path: 'files',
29
14
  package_dir: 'pkg',
30
15
  package_tmp: 'pkg-tmp',
16
+ resources_path: nil,
17
+ friendly_name: 'HAMLET',
31
18
  )
32
19
  end
33
20
 
@@ -41,6 +28,10 @@ module Omnibus
41
28
  expect(subject.name).to eq(project.name)
42
29
  end
43
30
 
31
+ it 'delegates #friendly_name to @project' do
32
+ expect(subject.friendly_name).to eq(project.friendly_name)
33
+ end
34
+
44
35
  it 'delegates #version to @project' do
45
36
  expect(subject.version).to eq(project.build_version)
46
37
  end
@@ -154,6 +145,61 @@ module Omnibus
154
145
  end
155
146
  end
156
147
 
148
+ describe '#copy_directory' do
149
+ before do
150
+ FileUtils.stub(:cp_r)
151
+ Dir.stub(:[]).and_return(['baz/file'])
152
+ end
153
+
154
+ it 'copies the directory' do
155
+ expect(FileUtils).to receive(:cp_r).with(['baz/file'], 'bar')
156
+ subject.copy_directory('baz', 'bar')
157
+ end
158
+ end
159
+
160
+ describe '#render_template' do
161
+ it 'return when source is not an erb template' do
162
+ expect(File).not_to receive(:open)
163
+ subject.render_template('source.txt')
164
+ end
165
+
166
+ shared_examples_for 'render_template' do
167
+ let(:output) { StringIO.new }
168
+
169
+ before do
170
+ input = StringIO.new
171
+ input.write('<%= friendly_name %>')
172
+ input.rewind
173
+
174
+ File.stub(:open).with(source_path).and_yield(input)
175
+ File.stub(:open).with(expected_destination_path, 'w').and_yield(output)
176
+
177
+ expect(subject).to receive(:remove_file).with(source_path)
178
+ end
179
+
180
+ it 'should render correctly' do
181
+ subject.render_template(source_path, destination_path)
182
+ expect(output.string).to eq('HAMLET')
183
+ end
184
+ end
185
+
186
+ context 'when destination is specified' do
187
+ let(:source_path) { 'source.txt.erb' }
188
+ let(:destination_path) { 'destination.txt' }
189
+ let(:expected_destination_path) { destination_path }
190
+
191
+ include_examples 'render_template'
192
+ end
193
+
194
+ context 'when destination is not specified' do
195
+ let(:source_path) { 'source.txt.erb' }
196
+ let(:destination_path) { nil }
197
+ let(:expected_destination_path) { 'source.txt' }
198
+
199
+ include_examples 'render_template'
200
+ end
201
+ end
202
+
157
203
  describe '#remove_file' do
158
204
  before { FileUtils.stub(:rm_f) }
159
205
 
@@ -189,8 +235,8 @@ module Omnibus
189
235
  end
190
236
 
191
237
  it 'calls the methods in order' do
192
- expect(described_class).to receive(:validate).ordered
193
238
  expect(described_class).to receive(:setup).ordered
239
+ expect(described_class).to receive(:validate).ordered
194
240
  expect(described_class).to receive(:build).ordered
195
241
  expect(described_class).to receive(:clean).ordered
196
242
  subject.run!
@@ -204,17 +250,34 @@ module Omnibus
204
250
  end
205
251
  end
206
252
 
253
+ describe '#staging_resources_path' do
254
+ it 'is base/Resources under package temp' do
255
+ name = "#{project.package_tmp}/base/Resources"
256
+ expect(subject.send(:staging_resources_path)).to eq(File.expand_path(name))
257
+ end
258
+ end
259
+
207
260
  describe '#resource' do
208
261
  it 'prefixes to the resources_path' do
209
- path = 'files/base/Resources/icon.png'
262
+ path = 'pkg-tmp/base/Resources/icon.png'
210
263
  expect(subject.send(:resource, 'icon.png')).to eq(File.expand_path(path))
211
264
  end
212
265
  end
213
266
 
214
267
  describe '#resoures_path' do
215
- it 'is the files_path, underscored_name, and Resources' do
216
- path = "#{project.files_path}/base/Resources"
217
- expect(subject.send(:resources_path)).to eq(File.expand_path(path))
268
+ context 'when project does not define resources_path' do
269
+ it 'is the files_path, underscored_name, and Resources' do
270
+ path = "#{project.files_path}/base/Resources"
271
+ expect(subject.send(:resources_path)).to eq(File.expand_path(path))
272
+ end
273
+ end
274
+
275
+ context 'when project defines resources_path' do
276
+ before { project.stub(:resources_path).and_return('project/specific') }
277
+ it 'is the project resources_path, underscored_name, and Resources' do
278
+ path = 'project/specific/base/Resources'
279
+ expect(subject.send(:resources_path)).to eq(File.expand_path(path))
280
+ end
218
281
  end
219
282
  end
220
283
  end
@@ -1,20 +1,3 @@
1
- #
2
- # Copyright:: Copyright (c) 2014 Chef Software, Inc.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
1
  require 'stringio'
19
2
  require 'spec_helper'
20
3
 
@@ -62,6 +45,13 @@ EOH
62
45
 
63
46
  let(:expected_distribution_path) { '/var/cache/omnibus/pkg-tmp/mac_pkg/Distribution' }
64
47
 
48
+ let(:pkg_signing_config) do
49
+ {
50
+ sign_pkg: false,
51
+ signing_identity: nil,
52
+ }
53
+ end
54
+
65
55
  let(:project) do
66
56
  double Omnibus::Project,
67
57
  name: project_name,
@@ -73,7 +63,9 @@ EOH
73
63
  files_path: files_path,
74
64
  package_dir: package_dir,
75
65
  package_tmp: package_tmp,
76
- mac_pkg_identifier: mac_pkg_identifier
66
+ mac_pkg_identifier: mac_pkg_identifier,
67
+ config: pkg_signing_config,
68
+ friendly_name: 'Myproject'
77
69
  end
78
70
 
79
71
  let(:packager) do
@@ -142,12 +134,30 @@ EOH
142
134
 
143
135
  describe 'building the product package' do
144
136
  it 'generates the distribution and runs productbuild' do
145
- expect(packager).to receive(:execute).with <<-EOH.gsub(/^ {8}/, '')
146
- productbuild \\
147
- --distribution "/var/cache/omnibus/pkg-tmp/mac_pkg/Distribution" \\
148
- --resources "/omnibus/project/root/files/mac_pkg/Resources" \\
149
- "/home/someuser/omnibus-myproject/pkg/myproject-23.4.2-4.pkg"
150
- EOH
137
+ expect(packager).to receive(:execute).with ['productbuild',
138
+ %Q(--distribution "/var/cache/omnibus/pkg-tmp/mac_pkg/Distribution"),
139
+ %Q(--resources "/var/cache/omnibus/pkg-tmp/mac_pkg/Resources"),
140
+ '/home/someuser/omnibus-myproject/pkg/myproject-23.4.2-4.pkg',
141
+ ].join(' ')
142
+ packager.build_product_pkg
143
+ end
144
+ end
145
+
146
+ context 'when pkg signing is enabled' do
147
+ let(:pkg_signing_config) do
148
+ {
149
+ sign_pkg: true,
150
+ signing_identity: 'My Special Identity',
151
+ }
152
+ end
153
+
154
+ it 'includes the signing parameters in the product build command' do
155
+ expect(packager).to receive(:execute).with ['productbuild',
156
+ %Q(--distribution "/var/cache/omnibus/pkg-tmp/mac_pkg/Distribution"),
157
+ %Q(--resources "/var/cache/omnibus/pkg-tmp/mac_pkg/Resources"),
158
+ %Q(--sign "My Special Identity"),
159
+ '/home/someuser/omnibus-myproject/pkg/myproject-23.4.2-4.pkg',
160
+ ].join(' ')
151
161
  packager.build_product_pkg
152
162
  end
153
163
  end