omnibus 3.1.1 → 3.2.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +71 -0
  3. data/Gemfile +0 -7
  4. data/README.md +108 -36
  5. data/Rakefile +1 -5
  6. data/docs/omnibus-build-cache.md +5 -5
  7. data/features/commands/_deprecated.feature +21 -3
  8. data/features/step_definitions/generator_steps.rb +7 -7
  9. data/lib/omnibus.rb +232 -171
  10. data/lib/omnibus/build_version.rb +2 -2
  11. data/lib/omnibus/builder.rb +38 -19
  12. data/lib/omnibus/cleaner.rb +5 -5
  13. data/lib/omnibus/cleanroom.rb +141 -0
  14. data/lib/omnibus/cli.rb +6 -9
  15. data/lib/omnibus/cli/base.rb +2 -1
  16. data/lib/omnibus/cli/cache.rb +15 -21
  17. data/lib/omnibus/cli/deprecated.rb +40 -4
  18. data/lib/omnibus/cli/publish.rb +61 -0
  19. data/lib/omnibus/config.rb +350 -189
  20. data/lib/omnibus/digestable.rb +131 -0
  21. data/lib/omnibus/exceptions.rb +163 -83
  22. data/lib/omnibus/fetcher.rb +1 -1
  23. data/lib/omnibus/fetchers/net_fetcher.rb +19 -13
  24. data/lib/omnibus/fetchers/path_fetcher.rb +8 -1
  25. data/lib/omnibus/fetchers/s3_cache_fetcher.rb +16 -7
  26. data/lib/omnibus/generator.rb +2 -2
  27. data/lib/omnibus/generator_files/Gemfile.erb +4 -1
  28. data/lib/omnibus/generator_files/README.md.erb +10 -0
  29. data/lib/omnibus/generator_files/{omnibus.rb.example.erb → omnibus.rb.erb} +20 -11
  30. data/lib/omnibus/generator_files/package_scripts/makeselfinst.erb +1 -1
  31. data/lib/omnibus/generator_files/project.rb.erb +2 -2
  32. data/lib/omnibus/generator_files/windows_msi/localization-en-us.wxl.erb +3 -3
  33. data/lib/omnibus/git_cache.rb +192 -0
  34. data/lib/omnibus/health_check.rb +171 -116
  35. data/lib/omnibus/library.rb +4 -2
  36. data/lib/omnibus/logger.rb +60 -1
  37. data/lib/omnibus/null_argumentable.rb +51 -0
  38. data/lib/omnibus/ohai.rb +29 -8
  39. data/lib/omnibus/package.rb +240 -0
  40. data/lib/omnibus/packagers/base.rb +21 -42
  41. data/lib/omnibus/packagers/mac_dmg.rb +5 -5
  42. data/lib/omnibus/packagers/mac_pkg.rb +20 -19
  43. data/lib/omnibus/packagers/windows_msi.rb +7 -7
  44. data/lib/omnibus/project.rb +969 -486
  45. data/lib/omnibus/publisher.rb +76 -0
  46. data/lib/omnibus/publishers/artifactory_publisher.rb +168 -0
  47. data/lib/omnibus/publishers/null_publisher.rb +23 -0
  48. data/lib/omnibus/publishers/s3_publisher.rb +99 -0
  49. data/lib/omnibus/s3_cache.rb +150 -63
  50. data/lib/omnibus/software.rb +749 -321
  51. data/lib/omnibus/{sugar.rb → sugarable.rb} +11 -6
  52. data/lib/omnibus/version.rb +1 -1
  53. data/omnibus.gemspec +8 -8
  54. data/spec/data/complicated/config/projects/angrychef.rb +1 -1
  55. data/spec/data/complicated/config/projects/chef-windows.rb +1 -1
  56. data/spec/data/complicated/config/projects/chef.rb +1 -1
  57. data/spec/data/complicated/config/projects/chefdk-windows.rb +1 -1
  58. data/spec/data/complicated/config/projects/chefdk.rb +1 -1
  59. data/spec/data/complicated/config/software/cacerts.rb +1 -1
  60. data/spec/data/complicated/config/software/chef-client-msi.rb +1 -1
  61. data/spec/data/complicated/config/software/libgcc.rb +1 -1
  62. data/spec/data/complicated/config/software/libiconv.rb +0 -11
  63. data/spec/data/complicated/config/software/libpng.rb +2 -2
  64. data/spec/data/complicated/config/software/openssl.rb +1 -1
  65. data/spec/data/complicated/config/software/ruby.rb +1 -1
  66. data/spec/data/complicated/config/software/runit.rb +4 -4
  67. data/spec/data/projects/chefdk.rb +1 -1
  68. data/spec/data/projects/sample.rb +1 -1
  69. data/spec/data/software/erchef.rb +3 -1
  70. data/spec/functional/packagers/mac_spec.rb +25 -24
  71. data/spec/functional/packagers/windows_spec.rb +21 -20
  72. data/spec/spec_helper.rb +43 -4
  73. data/spec/unit/build_version_spec.rb +14 -16
  74. data/spec/unit/cleanroom_spec.rb +63 -0
  75. data/spec/unit/config_spec.rb +36 -30
  76. data/spec/unit/digestable_spec.rb +38 -0
  77. data/spec/unit/fetchers/net_fetcher_spec.rb +98 -87
  78. data/spec/unit/{install_path_cache_spec.rb → git_cache_spec.rb} +67 -56
  79. data/spec/unit/health_check_spec.rb +73 -0
  80. data/spec/unit/library_spec.rb +166 -159
  81. data/spec/unit/ohai_spec.rb +19 -0
  82. data/spec/unit/omnibus_spec.rb +43 -41
  83. data/spec/unit/package_spec.rb +178 -0
  84. data/spec/unit/packagers/base_spec.rb +17 -47
  85. data/spec/unit/packagers/mac_pkg_spec.rb +104 -126
  86. data/spec/unit/project_spec.rb +176 -25
  87. data/spec/unit/publisher_spec.rb +49 -0
  88. data/spec/unit/publishers/artifactory_publisher_spec.rb +80 -0
  89. data/spec/unit/publishers/s3_publisher_spec.rb +120 -0
  90. data/spec/unit/s3_cacher_spec.rb +84 -19
  91. data/spec/unit/software_spec.rb +397 -170
  92. data/spec/unit/sugarable_spec.rb +43 -0
  93. metadata +62 -50
  94. data/Guardfile +0 -10
  95. data/lib/omnibus/artifact.rb +0 -165
  96. data/lib/omnibus/cli/release.rb +0 -40
  97. data/lib/omnibus/generator_files/Vagrantfile.erb +0 -75
  98. data/lib/omnibus/install_path_cache.rb +0 -105
  99. data/lib/omnibus/overrides.rb +0 -88
  100. data/lib/omnibus/package_release.rb +0 -154
  101. data/lib/omnibus/software_s3_urls.rb +0 -50
  102. data/spec/unit/artifact_spec.rb +0 -91
  103. data/spec/unit/overrides_spec.rb +0 -102
  104. data/spec/unit/package_release_spec.rb +0 -180
  105. data/spec/unit/sugar_spec.rb +0 -17
@@ -1,96 +1,83 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Omnibus
4
- describe InstallPathCache do
4
+ describe GitCache do
5
5
  before do
6
- # Stub to prevent a real Ohai run for faster specs
7
- Ohai.stub(:platform).and_return('linux')
6
+ allow(IO).to receive(:read).and_call_original
8
7
  end
9
8
 
10
- let(:install_path) { '/opt/chef' }
11
-
12
9
  let(:project) do
13
- raw_project = <<-EOH
14
- name "demo"
15
- install_path "/opt/demo"
16
- build_version "1.0.0"
17
- maintainer 'Chef Software, Inc'
18
- homepage 'http://getchef.com'
19
- dependency 'preparation'
20
- dependency 'snoopy'
21
- dependency 'zlib'
22
- EOH
23
- project = Omnibus::Project.new(raw_project, 'demo.rb')
24
- project
25
- end
10
+ allow(IO).to receive(:read)
11
+ .with('/path/to/demo.rb')
12
+ .and_return <<-EOH.gsub(/^ {10}/, '')
13
+ name 'demo'
14
+ install_dir '/opt/demo'
15
+
16
+ build_version '1.0.0'
17
+
18
+ maintainer 'Chef Software, Inc'
19
+ homepage 'http://getchef.com'
20
+
21
+ dependency 'preparation'
22
+ dependency 'snoopy'
23
+ dependency 'zlib'
24
+ EOH
26
25
 
27
- let(:fake_software_config_file) do
28
- File.join(Omnibus::RSpec::SPEC_DATA, 'software', 'zlib.rb')
26
+ Project.load('/path/to/demo.rb')
29
27
  end
30
28
 
29
+ let(:install_dir) { project.install_dir }
30
+
31
+ let(:zlib_config) { File.join(RSpec::SPEC_DATA, 'software', 'zlib.rb') }
32
+
31
33
  let(:zlib) do
32
- software = Omnibus::Software.new('', fake_software_config_file, project)
34
+ software = Software.new(project, {}, zlib_config)
33
35
  software.name('zlib')
34
36
  software.default_version('1.7.2')
35
37
  software
36
38
  end
37
39
 
38
40
  let(:snoopy) do
39
- software = Omnibus::Software.new('', 'snoopy.rb', project)
41
+ software = Software.new(project, {}, 'snoopy.rb')
40
42
  software.name('snoopy')
41
43
  software.default_version('1.0.0')
42
44
  software
43
45
  end
44
46
 
45
47
  let(:preparation) do
46
- software = Omnibus::Software.new('', 'preparation.rb', project)
48
+ software = Software.new(project, {}, 'preparation.rb')
47
49
  software.name('preparation')
48
50
  software.default_version('1.0.0')
49
51
  software
50
52
  end
51
53
 
52
- let(:cache_path) { "/var/cache/omnibus/cache/install_path#{install_path}" }
54
+ let(:cache_path) { File.join('/var/cache/omnibus/cache/git_cache', install_dir) }
53
55
 
54
56
  let(:ipc) do
55
57
  project.library.component_added(preparation)
56
58
  project.library.component_added(snoopy)
57
59
  project.library.component_added(zlib)
58
- Omnibus::InstallPathCache.new(install_path, zlib)
60
+ described_class.new(zlib)
59
61
  end
60
62
 
61
63
  describe '#cache_path' do
62
64
  it 'returns the install path appended to the install_cache path' do
63
- expect(ipc.cache_path).to eq('/var/cache/omnibus/cache/install_path/opt/chef')
64
- end
65
- end
66
-
67
- describe '#cache_path_exists?' do
68
- it 'checks for existence' do
69
- expect(File).to receive(:directory?).with(ipc.cache_path)
70
- ipc.cache_path_exists?
65
+ expect(ipc.cache_path).to eq(cache_path)
71
66
  end
72
67
  end
73
68
 
74
69
  describe '#tag' do
75
- # 13b3f7f2653e40b9d5b393659210775ac5b56f7e0009f82f85b83f5132409362
76
- #
77
- # Is the sha256sum of:
78
- # cat spec/data/software/zlib.rb > t
79
- # echo -n 'preparation-1.0.0-snoopy-1.0.0' >> t
80
- # sha256sum t
81
- it 'returns a tag with the softwares name, version, and hash of deps name+version' do
82
- expect(ipc.tag).to eql('zlib-1.7.2-13b3f7f2653e40b9d5b393659210775ac5b56f7e0009f82f85b83f5132409362')
70
+ it 'returns the correct tag' do
71
+ expect(ipc.tag).to eql('zlib-329d861e3928a74938f1ff9ff2672ea4e1c0b6ac3b7f32e66fd61064f516f751')
83
72
  end
84
73
 
85
74
  describe 'with no deps' do
86
75
  let(:ipc) do
87
- Omnibus::InstallPathCache.new(install_path, zlib)
76
+ described_class.new(zlib)
88
77
  end
89
78
 
90
- it 'uses the shasum of the software config file' do
91
- # gsha256sum spec/data/software/zlib.rb
92
- # 363e6cc2475fcdd6e18b2dc10f6022d1cab498b9961e8225d8a309d18ed3c94b spec/data/software/zlib.rb
93
- expect(ipc.tag).to eql('zlib-1.7.2-363e6cc2475fcdd6e18b2dc10f6022d1cab498b9961e8225d8a309d18ed3c94b')
79
+ it 'returns the correct tag' do
80
+ expect(ipc.tag).to eql('zlib-4093b06ca5b22654b650a207736136964a1e8a362548a058702adbf501955189')
94
81
  end
95
82
  end
96
83
  end
@@ -134,25 +121,49 @@ module Omnibus
134
121
  ipc.incremental
135
122
  end
136
123
 
137
- it 'adds all the changes to git' do
124
+ it 'adds all the changes to git removing git directories' do
125
+ expect(ipc).to receive(:remove_git_dirs)
138
126
  expect(ipc).to receive(:shellout!)
139
- .with("git --git-dir=#{cache_path} --work-tree=#{install_path} add -A -f")
127
+ .with("git --git-dir=#{cache_path} --work-tree=#{install_dir} add -A -f")
140
128
  ipc.incremental
141
129
  end
142
130
 
143
131
  it 'commits the backup for the software' do
144
132
  expect(ipc).to receive(:shellout!)
145
- .with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} commit -q -m "Backup of #{ipc.tag}"))
133
+ .with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_dir} commit -q -m "Backup of #{ipc.tag}"))
146
134
  ipc.incremental
147
135
  end
148
136
 
149
137
  it 'tags the software backup' do
150
138
  expect(ipc).to receive(:shellout!)
151
- .with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} tag -f "#{ipc.tag}"))
139
+ .with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_dir} tag -f "#{ipc.tag}"))
152
140
  ipc.incremental
153
141
  end
154
142
  end
155
143
 
144
+ describe '#remove_git_dirs' do
145
+ let(:git_files) { ['git/HEAD', 'git/description', 'git/hooks', 'git/info', 'git/objects', 'git/refs' ] }
146
+ it 'removes bare git directories' do
147
+ allow(Dir).to receive(:glob).and_return(['git/config'])
148
+ git_files.each do |git_file|
149
+ expect(File).to receive(:exist?).with(git_file).and_return(true)
150
+ end
151
+ allow(File).to receive(:dirname).and_return('git')
152
+ expect(FileUtils).to receive(:rm_rf).with('git')
153
+
154
+ ipc.remove_git_dirs
155
+ end
156
+
157
+ it 'does ignores non git directories' do
158
+ allow(Dir).to receive(:glob).and_return(['not_git/config'])
159
+ expect(File).to receive(:exist?).with('not_git/HEAD').and_return(false)
160
+ allow(File).to receive(:dirname).and_return('not_git')
161
+ expect(FileUtils).not_to receive(:rm_rf).with('not_git')
162
+
163
+ ipc.remove_git_dirs
164
+ end
165
+ end
166
+
156
167
  describe '#restore' do
157
168
  let(:git_tag_output) { "#{ipc.tag}\n" }
158
169
 
@@ -165,10 +176,10 @@ module Omnibus
165
176
 
166
177
  before(:each) do
167
178
  allow(ipc).to receive(:shellout)
168
- .with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} tag -l "#{ipc.tag}"))
179
+ .with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_dir} tag -l "#{ipc.tag}"))
169
180
  .and_return(tag_cmd)
170
181
  allow(ipc).to receive(:shellout!)
171
- .with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} checkout -f "#{ipc.tag}"))
182
+ .with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_dir} checkout -f "#{ipc.tag}"))
172
183
  allow(ipc).to receive(:create_cache_path)
173
184
  end
174
185
 
@@ -179,10 +190,10 @@ module Omnibus
179
190
 
180
191
  it 'checks for a tag with the software and version, and if it finds it, checks it out' do
181
192
  expect(ipc).to receive(:shellout)
182
- .with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} tag -l "#{ipc.tag}"))
193
+ .with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_dir} tag -l "#{ipc.tag}"))
183
194
  .and_return(tag_cmd)
184
195
  expect(ipc).to receive(:shellout!)
185
- .with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} checkout -f "#{ipc.tag}"))
196
+ .with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_dir} checkout -f "#{ipc.tag}"))
186
197
  ipc.restore
187
198
  end
188
199
 
@@ -191,10 +202,10 @@ module Omnibus
191
202
 
192
203
  it 'does nothing' do
193
204
  expect(ipc).to receive(:shellout)
194
- .with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} tag -l "#{ipc.tag}"))
205
+ .with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_dir} tag -l "#{ipc.tag}"))
195
206
  .and_return(tag_cmd)
196
207
  expect(ipc).to_not receive(:shellout!)
197
- .with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} checkout -f "#{ipc.tag}"))
208
+ .with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_dir} checkout -f "#{ipc.tag}"))
198
209
  ipc.restore
199
210
  end
200
211
  end
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ module Omnibus
4
+ describe HealthCheck do
5
+ let(:project) do
6
+ double(Project,
7
+ name: 'chefdk',
8
+ install_dir: '/opt/chefdk',
9
+ library: double(Library,
10
+ components: [],
11
+ ),
12
+ )
13
+ end
14
+
15
+ subject { described_class.new(project) }
16
+
17
+ context 'on linux' do
18
+ before { stub_ohai(platform: 'ubuntu', version: '12.04') }
19
+
20
+ let(:bad_healthcheck) do
21
+ double('Mixlib::Shellout',
22
+ stdout: <<-EOH.gsub(/^ {12}/, '')
23
+ /bin/ls:
24
+ linux-vdso.so.1 => (0x00007fff583ff000)
25
+ libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007fad8592a000)
26
+ librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fad85722000)
27
+ libacl.so.1 => /lib/x86_64-linux-gnu/libacl.so.1 (0x00007fad85518000)
28
+ libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fad8518d000)
29
+ libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fad84f89000)
30
+ /lib64/ld-linux-x86-64.so.2 (0x00007fad85b51000)
31
+ libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fad84d6c000)
32
+ libattr.so.1 => /lib/x86_64-linux-gnu/libattr.so.1 (0x00007fad84b67000)
33
+ /bin/cat:
34
+ linux-vdso.so.1 => (0x00007fffa4dcf000)
35
+ libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4a858cd000)
36
+ /lib64/ld-linux-x86-64.so.2 (0x00007f4a85c5f000)
37
+ EOH
38
+ )
39
+ end
40
+
41
+ let(:good_healthcheck) do
42
+ double('Mixlib::Shellout',
43
+ stdout: <<-EOH.gsub(/^ {12}/, '')
44
+ /bin/echo:
45
+ linux-vdso.so.1 => (0x00007fff8a6ee000)
46
+ libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f70f58c0000)
47
+ /lib64/ld-linux-x86-64.so.2 (0x00007f70f5c52000)
48
+ /bin/cat:
49
+ linux-vdso.so.1 => (0x00007fff095b3000)
50
+ libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe868ec0000)
51
+ /lib64/ld-linux-x86-64.so.2 (0x00007fe869252000)
52
+ EOH
53
+ )
54
+ end
55
+
56
+ it 'raises an exception when there are external dependencies' do
57
+ allow(subject).to receive(:shellout)
58
+ .with("find #{project.install_dir}/ -type f | xargs ldd")
59
+ .and_return(bad_healthcheck)
60
+
61
+ expect { subject.run! }.to raise_error(HealthCheckFailed)
62
+ end
63
+
64
+ it 'does not raise an exception when the healthcheck passes' do
65
+ allow(subject).to receive(:shellout)
66
+ .with("find #{project.install_dir}/ -type f | xargs ldd")
67
+ .and_return(good_healthcheck)
68
+
69
+ expect { subject.run! }.to_not raise_error
70
+ end
71
+ end
72
+ end
73
+ end
@@ -1,187 +1,194 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Omnibus::Library do
4
- let(:project) { Omnibus::Project.load(project_path('chefdk')) }
5
- let(:library) { Omnibus::Library.new(project) }
6
- let(:erchef) { Omnibus::Software.load(software_path('erchef'), project) }
7
- let(:zlib) { Omnibus::Software.load(software_path('zlib'), project) }
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
-
18
- describe '#component_added' do
19
- it 'adds the software to the component list' do
20
- library.component_added(erchef)
21
- expect(library.components).to eql([erchef])
22
- end
23
-
24
- it 'does not add a component more than once' do
25
- library.component_added(erchef)
26
- library.component_added(erchef)
27
- expect(library.components).to eql([erchef])
28
- end
29
- end
30
-
31
- describe '#build_order' do
32
- let(:project) do
33
- raw_project = <<-EOH
34
- name "chef-server"
35
- install_path "/opt/chef-server"
36
- build_version "1.0.0"
37
- maintainer 'Chef Software, Inc'
38
- homepage 'http://getchef.com'
39
- dependency 'preparation'
40
- dependency 'erchef'
41
- dependency 'postgresql'
42
- dependency 'chef'
43
- EOH
44
- Omnibus::Project.new(raw_project, 'chef-server.rb')
45
- end
3
+ module Omnibus
4
+ describe Library do
5
+ #
6
+ # Helper method for generating a fake software definition.
7
+ #
8
+ def generate_software(name, version, dependencies = [])
9
+ software = Software.new(project, {}, "#{name}.rb")
10
+ software.name(name.to_s)
11
+ software.version(version)
12
+
13
+ dependencies.each do |dependency|
14
+ software.dependency(dependency)
15
+ end
46
16
 
47
- let(:library) do
48
- library = Omnibus::Library.new(project)
49
- library.component_added(preparation)
50
- library.component_added(erlang)
51
- library.component_added(postgresql) # as a skitch trans dep
52
- library.component_added(skitch)
53
- library.component_added(erchef)
54
- library.component_added(ruby)
55
- library.component_added(chef)
56
- library
17
+ software
57
18
  end
58
19
 
59
- project_deps = [:preparation, :erchef, :postgresql, :chef]
60
- erchef_deps = [:erlang, :skitch]
61
- chef_deps = [:ruby]
62
-
63
- [project_deps, erchef_deps, chef_deps].flatten.each do |dep|
64
- let(dep) do
65
- software = Omnibus::Software.new('', "#{dep}.rb", 'chef-server')
66
- software.name(dep.to_s)
67
- software.dependency('postgresql') if dep == :skitch
68
- software
20
+ let(:project) { Project.load(project_path('chefdk')) }
21
+ let(:library) { Library.new(project) }
22
+
23
+ let(:bundler) { generate_software('bundler', '1.5.4') }
24
+ let(:curl) { generate_software('curl', '1.5.4', %w(openssl zlib)) }
25
+ let(:chef) { generate_software('chef', '1.0.0', %w(bundler ohai ruby)) }
26
+ let(:erchef) { generate_software('erchef', '4b19a96d57bff9bbf4764d7323b92a0944009b9e', %w(curl erlang rsync)) }
27
+ let(:erlang) { generate_software('erlang', 'R15B03-1', %w(openssl zlib)) }
28
+ let(:libgcc) { generate_software('libgcc', '0.0.0') }
29
+ let(:ncurses) { generate_software('ncurses', '5.9', %w(libgcc)) }
30
+ let(:ohai) { generate_software('ohai', 'master', %w(ruby rubygems yajl)) }
31
+ let(:openssl) { generate_software('openssl', '1.0.1g', %w(zlib)) }
32
+ let(:postgresql) { generate_software('postgresql', '9.2.8', %w(zlib openssl)) }
33
+ let(:preparation) { generate_software('preparation', '1.0.0') }
34
+ let(:rsync) { generate_software('rsync', '3.0.9') }
35
+ let(:ruby) { generate_software('ruby', '1.9.3-p481', %w(zlib ncurses)) }
36
+ let(:rubygems) { generate_software('rubygems', '1.8.24', %w(ruby)) }
37
+ let(:skitch) { generate_software('skitch', '4.4.1', %w(postgresql)) }
38
+ let(:yajl) { generate_software('yajl', '1.1.0', %w(rubygems)) }
39
+ let(:zlib) { generate_software('zlib', '1.2.6', %w(libgcc)) }
40
+
41
+ describe '#component_added' do
42
+ it 'adds the software to the component list' do
43
+ library.component_added(erchef)
44
+ expect(library.components).to eql([erchef])
69
45
  end
70
- end
71
46
 
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
47
+ it 'does not add a component more than once' do
48
+ library.component_added(erchef)
49
+ library.component_added(erchef)
50
+ expect(library.components).to eql([erchef])
96
51
  end
52
+ end
97
53
 
54
+ describe '#build_order' do
98
55
  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')
56
+ allow(IO).to receive(:read)
57
+ .with('/chef-server.rb')
58
+ .and_return <<-EOH.gsub(/^ {12}/, '')
59
+ name 'chef-server'
60
+ maintainer 'Chef Software, Inc'
61
+ homepage 'http://getchef.com'
62
+ build_version '1.0.0'
63
+
64
+ install_dir '/opt/chef-server'
65
+
66
+ dependency 'preparation'
67
+ dependency 'erchef'
68
+ dependency 'postgresql'
69
+ dependency 'chef'
70
+ EOH
71
+
72
+ Project.load('/chef-server.rb')
113
73
  end
114
74
 
115
75
  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
76
+ library = Library.new(project)
77
+ library.component_added(preparation)
78
+ library.component_added(erlang)
79
+ library.component_added(postgresql) # as a skitch trans dep
80
+ library.component_added(skitch)
81
+ library.component_added(erchef)
82
+ library.component_added(ruby)
83
+ library.component_added(chef)
128
84
  library
129
85
  end
130
86
 
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
- ])
87
+ it 'returns an array of software descriptions, with all top level deps first' do
88
+ expect(library.build_order).to eq([
89
+ preparation,
90
+ erlang,
91
+ postgresql,
92
+ skitch,
93
+ ruby,
94
+ erchef,
95
+ chef,
96
+ ])
145
97
  end
146
- end
147
98
 
148
- context 'with real data' do
149
- before do
150
- Omnibus.stub(:project_root).and_return(complicated_path)
99
+ context 'with a complex dep tree' do
100
+ let(:chefdk) { generate_software('chefdk', '1.0.0.alpha', %w(bundler ruby)) }
101
+
102
+ let(:project) do
103
+ allow(IO).to receive(:read)
104
+ .with('/chefdk.rb')
105
+ .and_return <<-EOH.gsub(/^ {12}/, '')
106
+ name 'chef-dk'
107
+ maintainer 'Chef Software, Inc'
108
+ homepage 'http://getchef.com'
109
+ build_version '1.0.0'
110
+
111
+ install_dir '/opt/chefdk'
112
+
113
+ dependency 'preparation'
114
+ dependency 'erchef'
115
+ dependency 'postgresql'
116
+ dependency 'ruby'
117
+ dependency 'chef'
118
+ dependency 'chefdk'
119
+ EOH
120
+
121
+ Project.load('/chefdk.rb')
122
+ end
151
123
 
152
- # Ohai stuff
153
- stub_const('File::ALT_SEPARATOR', '\\')
154
- stub_ohai(platform: 'windows')
124
+ let(:library) do
125
+ # This is the LOAD ORDER
126
+ library = Library.new(project)
127
+ library.component_added(preparation) # via project
128
+ library.component_added(erlang) # via erchef
129
+ library.component_added(postgresql) # via skitch
130
+ library.component_added(skitch) # via erchef
131
+ library.component_added(erchef) # erchef
132
+ library.component_added(ruby) # via project
133
+ library.component_added(bundler) # via chef
134
+ library.component_added(ohai) # via chef
135
+ library.component_added(chef) # via project
136
+ library.component_added(chefdk) # via project
137
+ library
138
+ end
155
139
 
156
- Omnibus.process_dsl_files
140
+ it 'returns an array of software descriptions, with all top level deps first, assuming they are not themselves transitive deps' do
141
+ expect(library.build_order).to eql(
142
+ [
143
+ preparation, # first
144
+ erlang, # via erchef project
145
+ postgresql, # via skitch transitive
146
+ skitch, # via erchef project
147
+ ruby, # via bundler transitive
148
+ bundler, # via chef
149
+ ohai, # via chef
150
+ erchef, # project dep
151
+ chef, # project dep
152
+ chefdk, # project dep
153
+ ])
154
+ end
157
155
  end
158
156
 
159
- after { Omnibus.reset! }
157
+ context 'with real data' do
158
+ before do
159
+ Config.project_root(complicated_path)
160
160
 
161
- let(:chefdk_windows) do
162
- Omnibus.projects.find { |p| p.name.to_s == 'chefdk-windows' }
163
- end
161
+ # Ohai stuff
162
+ stub_const('File::ALT_SEPARATOR', '\\')
163
+ stub_ohai(platform: 'windows', version: '2012')
164
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
- ])
165
+ Omnibus.process_dsl_files
166
+ end
167
+
168
+ let(:chefdk_windows) do
169
+ Omnibus.projects.find { |p| p.name.to_s == 'chefdk-windows' }
170
+ end
171
+
172
+ it 'has the right build order for chefdk-windows on windows' do
173
+ names = chefdk_windows.library.build_order.map { |m| m.name.to_s }
174
+ expect(names).to eql([
175
+ 'preparation', # via project dep
176
+ 'ruby-windows', # via libyaml-windows trans dep
177
+ 'libyaml-windows', # via ruby-windows trans
178
+ 'ruby-windows-devkit', # via trans dep from chef-windows
179
+ 'bundler', # via trans dep from chef-windows
180
+ 'cacerts', # via chef-windows
181
+ 'chef-windows', # via transitive dep from chefdk
182
+ 'nokogiri', # via test-kitchen
183
+ 'test-kitchen', # via chefdk
184
+ 'appbundler', # via chefdk
185
+ 'berkshelf', # via chefdk
186
+ 'chef-vault', # via chefdk
187
+ 'chefdk', # via project dep
188
+ 'chef-client-msi', # via top level dep
189
+ ])
190
+ end
183
191
  end
184
192
  end
185
193
  end
186
-
187
194
  end