vanagon 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +130 -23
  3. data/bin/build +0 -4
  4. data/bin/build_host_info +21 -0
  5. data/bin/inspect +25 -0
  6. data/lib/vanagon/driver.rb +17 -8
  7. data/lib/vanagon/engine/base.rb +11 -2
  8. data/lib/vanagon/engine/docker.rb +21 -6
  9. data/lib/vanagon/engine/ec2.rb +75 -0
  10. data/lib/vanagon/engine/hardware.rb +20 -3
  11. data/lib/vanagon/engine/local.rb +18 -3
  12. data/lib/vanagon/engine/pooler.rb +22 -7
  13. data/lib/vanagon/extensions/hashable.rb +41 -0
  14. data/lib/vanagon/extensions/ostruct/json.rb +12 -0
  15. data/lib/vanagon/extensions/set/json.rb +12 -0
  16. data/lib/vanagon/extensions/string.rb +1 -1
  17. data/lib/vanagon/platform.rb +2 -0
  18. data/lib/vanagon/platform/dsl.rb +63 -0
  19. data/lib/vanagon/platform/osx.rb +6 -0
  20. data/lib/vanagon/project/dsl.rb +1 -1
  21. data/lib/vanagon/utilities.rb +10 -4
  22. data/resources/osx/uninstaller.tool.erb +24 -0
  23. data/resources/rpm/project.spec.erb +6 -0
  24. data/spec/lib/vanagon/driver_spec.rb +88 -0
  25. data/spec/lib/vanagon/engine/docker_spec.rb +6 -0
  26. data/spec/lib/vanagon/engine/ec2_spec.rb +33 -0
  27. data/spec/lib/vanagon/engine/hardware_spec.rb +4 -0
  28. data/spec/lib/vanagon/engine/local_spec.rb +5 -0
  29. data/spec/lib/vanagon/engine/pooler_spec.rb +5 -0
  30. data/spec/lib/vanagon/extensions/ostruct/json_spec.rb +16 -0
  31. data/spec/lib/vanagon/extensions/set/json_spec.rb +17 -0
  32. data/spec/lib/vanagon/extensions/string_spec.rb +30 -0
  33. data/spec/lib/vanagon/utilities_spec.rb +1 -1
  34. metadata +22 -6
  35. data/resources/windows/wix/componentgroup.wxs.erb +0 -33
  36. data/resources/windows/wix/project.wxs.erb +0 -34
  37. data/resources/windows/wix/registryEntries.wxs.erb +0 -47
@@ -2,6 +2,10 @@
2
2
 
3
3
  # Turn off the brp-python-bytecompile script
4
4
  %global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g')
5
+ # Disable brp-strip-static-archive, which on EL platforms causes
6
+ # cross-compiled static libs to end up with "no machine" as their
7
+ # architure, breaking builds:
8
+ %global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-strip-static-archive[[:space:]].*$!!g')
5
9
  #
6
10
 
7
11
  Name: <%= @name %>
@@ -119,6 +123,7 @@ done
119
123
 
120
124
 
121
125
  %pre
126
+ <%- unless @platform.is_aix? || (@platform.is_el? && @platform.os_version.to_i == 4) -%>
122
127
  # Save state so we know later if this is an upgrade or an install
123
128
  mkdir -p %{_localstatedir}/lib/rpm-state/%{name}
124
129
  if [ "$1" -eq 1 ] ; then
@@ -127,6 +132,7 @@ fi
127
132
  if [ "$1" -gt 1 ] ; then
128
133
  touch %{_localstatedir}/lib/rpm-state/%{name}/upgrade
129
134
  fi
135
+ <%- end -%>
130
136
 
131
137
  <%- if @user -%>
132
138
  # Add our user and group
@@ -0,0 +1,88 @@
1
+ require 'vanagon/driver'
2
+ require 'vanagon/project'
3
+ require 'vanagon/platform'
4
+
5
+ describe 'Vanagon::Driver' do
6
+ let (:project) { double(:project, :settings => {} ) }
7
+
8
+ let (:redhat) do
9
+ eval_platform('el-7-x86_64', <<-END)
10
+ platform 'el-7-x86_64' do |plat|
11
+ plat.vmpooler_template 'centos-7-x86_64'
12
+ end
13
+ END
14
+ end
15
+
16
+ def eval_platform(name, definition)
17
+ plat = Vanagon::Platform::DSL.new(name)
18
+ plat.instance_eval(definition)
19
+ plat._platform
20
+ end
21
+
22
+ def create_driver(platform, options = {})
23
+ allow(Vanagon::Project).to receive(:load_project).and_return(project)
24
+ allow(Vanagon::Platform).to receive(:load_platform).and_return(platform)
25
+
26
+ Vanagon::Driver.new(platform, project, options)
27
+ end
28
+
29
+ describe 'when resolving build host info' do
30
+ it 'returns the vmpooler_template using the pooler engine' do
31
+ info = create_driver(redhat).build_host_info
32
+
33
+ expect(info).to match({ 'name' => 'centos-7-x86_64',
34
+ 'engine' => 'pooler' })
35
+ end
36
+
37
+ it 'returns the vmpooler template with an explicit engine' do
38
+ info = create_driver(redhat, :engine => 'pooler').build_host_info
39
+
40
+ expect(info).to match({ 'name' => 'centos-7-x86_64',
41
+ 'engine' => 'pooler' })
42
+ end
43
+
44
+ it 'returns the first build_host using the hardware engine' do
45
+ platform = eval_platform('aix-7.1-ppc', <<-END)
46
+ platform 'aix-7.1-ppc' do |plat|
47
+ plat.build_host ["pe-aix-71-01", "pe-aix-71-02"]
48
+ end
49
+ END
50
+
51
+ info = create_driver(platform).build_host_info
52
+
53
+ expect(info).to match({ 'name' => 'pe-aix-71-01',
54
+ 'engine' => 'hardware' })
55
+ end
56
+
57
+ it 'returns the docker_image using the docker engine' do
58
+ platform = eval_platform('el-7-x86_64', <<-END)
59
+ platform 'el-7-x86_64' do |plat|
60
+ plat.docker_image 'centos7'
61
+ end
62
+ END
63
+
64
+ expect(Vanagon::Utilities).to receive(:find_program_on_path).with('docker').and_return('/usr/bin/docker')
65
+ info = create_driver(platform, :engine => 'docker').build_host_info
66
+
67
+ expect(info).to match({ 'name' => 'centos7',
68
+ 'engine' => 'docker' })
69
+ end
70
+
71
+ it 'returns "local machine" using the local engine' do
72
+ info = create_driver(redhat, :engine => 'local').build_host_info
73
+
74
+ expect(info).to match({ 'name' => 'local machine',
75
+ 'engine' => 'local' })
76
+ end
77
+
78
+ it 'raises when using the base engine' do
79
+ driver = create_driver(redhat, :engine => 'base')
80
+
81
+ expect {
82
+ driver.build_host_info
83
+ }.to raise_error(Vanagon::Error,
84
+ /build_host_name has not been implemented for your engine/)
85
+ end
86
+ end
87
+ end
88
+
@@ -1,4 +1,5 @@
1
1
  require 'vanagon/engine/docker'
2
+ require 'vanagon/platform'
2
3
 
3
4
  describe 'Vanagon::Engine::Docker' do
4
5
  let (:platform_with_docker_image) {
@@ -37,4 +38,9 @@ describe 'Vanagon::Engine::Docker' do
37
38
  expect(Vanagon::Engine::Docker.new(platform_with_docker_image).validate_platform).to be(true)
38
39
  end
39
40
  end
41
+
42
+ it 'returns "docker" name' do
43
+ expect(Vanagon::Utilities).to receive(:find_program_on_path).with('docker').and_return('/usr/bin/docker')
44
+ expect(Vanagon::Engine::Docker.new(platform_with_docker_image).name).to eq('docker')
45
+ end
40
46
  end
@@ -0,0 +1,33 @@
1
+ begin
2
+ require 'aws-sdk'
3
+ rescue LoadError
4
+ $stderr.puts "Unable to load AWS SDK; skipping optional EC2 engine spec tests"
5
+ end
6
+
7
+ if defined? ::Aws
8
+ require 'vanagon/engine/ec2'
9
+ require 'vanagon/platform'
10
+
11
+ describe 'Vanagon::Engine::Ec2' do
12
+ let(:platform_ec2) do
13
+ plat = Vanagon::Platform::DSL.new('el-7-x86_64')
14
+ plat.instance_eval(<<-END)
15
+ platform 'el-7-x86_64' do |plat|
16
+ plat.aws_ami 'ami'
17
+ plat.target_user 'root'
18
+ plat.aws_subnet_id 'subnet_id'
19
+ plat.aws_user_data 'user_data'
20
+ plat.aws_region 'us-west-1'
21
+ plat.aws_key_name 'vanagon'
22
+ plat.aws_instance_type 't1.micro'
23
+ plat.ssh_port '22'
24
+ end
25
+ END
26
+ plat._platform
27
+ end
28
+
29
+ it 'returns "ec2" name' do
30
+ expect(Vanagon::Engine::Ec2.new(platform_ec2).name).to eq('ec2')
31
+ end
32
+ end
33
+ end
@@ -49,4 +49,8 @@ describe 'Vanagon::Engine::Hardware' do
49
49
  expect(Vanagon::Engine::Hardware.new(platform, nil).validate_platform).to be(true)
50
50
  end
51
51
  end
52
+
53
+ it 'returns "hardware" name' do
54
+ expect(Vanagon::Engine::Hardware.new(platform, nil).name).to eq('hardware')
55
+ end
52
56
  end
@@ -1,4 +1,5 @@
1
1
  require 'vanagon/engine/local'
2
+ require 'vanagon/platform'
2
3
 
3
4
  describe 'Vanagon::Engine::Local' do
4
5
  let (:platform) {
@@ -24,4 +25,8 @@ describe 'Vanagon::Engine::Local' do
24
25
  expect(engine.dispatch('true', true)).to eq('')
25
26
  end
26
27
  end
28
+
29
+ it 'returns "local" name' do
30
+ expect(Vanagon::Engine::Local.new(platform).name).to eq('local')
31
+ end
27
32
  end
@@ -1,4 +1,5 @@
1
1
  require 'vanagon/engine/pooler'
2
+ require 'vanagon/platform'
2
3
 
3
4
  describe 'Vanagon::Engine::Pooler' do
4
5
  let (:platform) { double(Vanagon::Platform, :target_user => 'root') }
@@ -53,4 +54,8 @@ describe 'Vanagon::Engine::Pooler' do
53
54
  expect(Vanagon::Engine::Pooler.new(platform_with_vcloud_name).validate_platform).to be(true)
54
55
  end
55
56
  end
57
+
58
+ it 'returns "pooler" name' do
59
+ expect(Vanagon::Engine::Pooler.new(platform_with_vcloud_name).name).to eq('pooler')
60
+ end
56
61
  end
@@ -0,0 +1,16 @@
1
+ require 'vanagon/extensions/ostruct/json'
2
+
3
+ describe "OpenStruct" do
4
+ describe "with JSON mixins" do
5
+ let(:test_ostruct) { OpenStruct.new(size: "big", shape: "spherical", name: "rover") }
6
+ let(:json_ostruct) { %({"size":"big","shape":"spherical","name":"rover"}) }
7
+
8
+ it "responds to #to_json" do
9
+ expect(OpenStruct.new.respond_to?(:to_json)).to eq(true)
10
+ end
11
+
12
+ it "can be converted to a valid JSON object" do
13
+ expect(JSON.parse(test_ostruct.to_json)).to eq(JSON.parse(json_ostruct))
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ require 'vanagon/extensions/set/json'
2
+
3
+ describe "Set" do
4
+ describe "with JSON mixins" do
5
+ let(:test_set) { Set['a', 'a', 'b', 'c'] }
6
+ let(:json_set) { %(["a","b","c"]) }
7
+
8
+ it "responds to #to_json" do
9
+ expect(Set.new.respond_to?(:to_json)).to eq(true)
10
+ end
11
+
12
+ it "can be converted to a valid JSON object" do
13
+ expect(JSON.parse(test_set.to_json)).to eq(JSON.parse(json_set))
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,30 @@
1
+ require 'vanagon/extensions/string'
2
+
3
+ describe "String" do
4
+ it "responds to #undent" do
5
+ expect(String.new.respond_to?(:undent)).to eq(true)
6
+ end
7
+ end
8
+
9
+ describe "Vanagon::Extensions::String" do
10
+ let (:basic_indented_string) { "\s\sa string" }
11
+ let (:basic_string) { "a string" }
12
+ let (:fancy_indented_string) { "\s\sleading line\n\s\s\s\s\s\strailing line\n\s\s\s\slast line" }
13
+ let (:fancy_string) { "leading line\n trailing line\n last line" }
14
+ let (:tab_indented_string) { "\t\t\ttab string" }
15
+ let (:tab_string) { "tab string" }
16
+
17
+ describe "#undent" do
18
+ it "trims trivial leading whitespace" do
19
+ expect(basic_indented_string.undent).to eq(basic_string)
20
+ end
21
+
22
+ it "trims more complex whitespace" do
23
+ expect(fancy_indented_string.undent).to eq(fancy_string)
24
+ end
25
+
26
+ it "trims leading tabs" do
27
+ expect(tab_indented_string.undent).to eq(tab_string)
28
+ end
29
+ end
30
+ end
@@ -146,7 +146,7 @@ describe "Vanagon::Utilities" do
146
146
 
147
147
  it 'raises a Vanagon::Error if the command fails n times' do
148
148
  expect(Vanagon::Utilities).to receive(:remote_ssh_command).with(host, command, port).exactly(tries).times.and_raise(RuntimeError)
149
- expect{ Vanagon::Utilities.retry_with_timeout(tries, timeout) { Vanagon::Utilities.remote_ssh_command(host, command, port) } }.to raise_error(Vanagon::Error)
149
+ expect{ Vanagon::Utilities.retry_with_timeout(tries, timeout) { Vanagon::Utilities.remote_ssh_command(host, command, port) } }.to raise_error(RuntimeError)
150
150
  end
151
151
 
152
152
  it 'returns true if the command succeeds within n times' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vanagon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-27 00:00:00.000000000 Z
11
+ date: 2016-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -54,19 +54,23 @@ dependencies:
54
54
  version: '0'
55
55
  description: Vanagon is a tool to build a single package out of a project, which can
56
56
  itself contain one or more components.
57
- email: info@puppetlabs.com
57
+ email: info@puppet.com
58
58
  executables:
59
59
  - build
60
+ - inspect
60
61
  - ship
61
62
  - repo
62
63
  - devkit
64
+ - build_host_info
63
65
  extensions: []
64
66
  extra_rdoc_files: []
65
67
  files:
66
68
  - LICENSE
67
69
  - README.md
68
70
  - bin/build
71
+ - bin/build_host_info
69
72
  - bin/devkit
73
+ - bin/inspect
70
74
  - bin/repo
71
75
  - bin/ship
72
76
  - lib/makefile.rb
@@ -84,10 +88,14 @@ files:
84
88
  - lib/vanagon/driver.rb
85
89
  - lib/vanagon/engine/base.rb
86
90
  - lib/vanagon/engine/docker.rb
91
+ - lib/vanagon/engine/ec2.rb
87
92
  - lib/vanagon/engine/hardware.rb
88
93
  - lib/vanagon/engine/local.rb
89
94
  - lib/vanagon/engine/pooler.rb
90
95
  - lib/vanagon/errors.rb
96
+ - lib/vanagon/extensions/hashable.rb
97
+ - lib/vanagon/extensions/ostruct/json.rb
98
+ - lib/vanagon/extensions/set/json.rb
91
99
  - lib/vanagon/extensions/string.rb
92
100
  - lib/vanagon/optparse.rb
93
101
  - lib/vanagon/patch.rb
@@ -122,6 +130,7 @@ files:
122
130
  - resources/osx/postinstall.erb
123
131
  - resources/osx/preinstall.erb
124
132
  - resources/osx/project-installer.xml.erb
133
+ - resources/osx/uninstaller.tool.erb
125
134
  - resources/rpm/project.spec.erb
126
135
  - resources/solaris/10/depend.erb
127
136
  - resources/solaris/10/pkginfo.erb
@@ -133,11 +142,8 @@ files:
133
142
  - resources/windows/nuget/chocolateyInstall.ps1
134
143
  - resources/windows/nuget/chocolateyUninstall.ps1
135
144
  - resources/windows/nuget/project.nuspec.erb
136
- - resources/windows/wix/componentgroup.wxs.erb
137
145
  - resources/windows/wix/directorylist.wxs.erb
138
146
  - resources/windows/wix/filter.xslt.erb
139
- - resources/windows/wix/project.wxs.erb
140
- - resources/windows/wix/registryEntries.wxs.erb
141
147
  - spec/fixtures/component/invalid-test-fixture.json
142
148
  - spec/fixtures/component/mcollective.service
143
149
  - spec/fixtures/component/test-fixture.json
@@ -165,11 +171,16 @@ files:
165
171
  - spec/lib/vanagon/component/source/localsource_spec.rb
166
172
  - spec/lib/vanagon/component/source_spec.rb
167
173
  - spec/lib/vanagon/component_spec.rb
174
+ - spec/lib/vanagon/driver_spec.rb
168
175
  - spec/lib/vanagon/engine/base_spec.rb
169
176
  - spec/lib/vanagon/engine/docker_spec.rb
177
+ - spec/lib/vanagon/engine/ec2_spec.rb
170
178
  - spec/lib/vanagon/engine/hardware_spec.rb
171
179
  - spec/lib/vanagon/engine/local_spec.rb
172
180
  - spec/lib/vanagon/engine/pooler_spec.rb
181
+ - spec/lib/vanagon/extensions/ostruct/json_spec.rb
182
+ - spec/lib/vanagon/extensions/set/json_spec.rb
183
+ - spec/lib/vanagon/extensions/string_spec.rb
173
184
  - spec/lib/vanagon/optparse_spec.rb
174
185
  - spec/lib/vanagon/platform/deb_spec.rb
175
186
  - spec/lib/vanagon/platform/dsl_spec.rb
@@ -218,11 +229,16 @@ test_files:
218
229
  - spec/lib/vanagon/component/source/localsource_spec.rb
219
230
  - spec/lib/vanagon/component/source_spec.rb
220
231
  - spec/lib/vanagon/component_spec.rb
232
+ - spec/lib/vanagon/driver_spec.rb
221
233
  - spec/lib/vanagon/engine/base_spec.rb
222
234
  - spec/lib/vanagon/engine/docker_spec.rb
235
+ - spec/lib/vanagon/engine/ec2_spec.rb
223
236
  - spec/lib/vanagon/engine/hardware_spec.rb
224
237
  - spec/lib/vanagon/engine/local_spec.rb
225
238
  - spec/lib/vanagon/engine/pooler_spec.rb
239
+ - spec/lib/vanagon/extensions/ostruct/json_spec.rb
240
+ - spec/lib/vanagon/extensions/set/json_spec.rb
241
+ - spec/lib/vanagon/extensions/string_spec.rb
226
242
  - spec/lib/vanagon/optparse_spec.rb
227
243
  - spec/lib/vanagon/platform/deb_spec.rb
228
244
  - spec/lib/vanagon/platform/dsl_spec.rb
@@ -1,33 +0,0 @@
1
- <?xml version="1.0" encoding="windows-1252"?>
2
- <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
3
-
4
- <!-- Default component groups that are to be included in this project.
5
- This can be copied in the project specific area to add additional component groups.
6
-
7
- Note that a number of the groups below are "pseudo-groups" that are necessary to
8
- force the Wix Linker (light) to include fragments (e.g. FragmentProperties).
9
-
10
- A UI reference is can also be included in the project specific area if required.
11
- Otherwise, the project will default here to using the minimal UI (WixUI_Minimal). -->
12
-
13
- <Fragment>
14
- <ComponentGroup Id="MainComponentGroup">
15
- <!-- We can add all components by referencing this one thing -->
16
- <ComponentGroupRef Id="AppComponentGroup" />
17
- <ComponentGroupRef Id="AppDataComponentGroup" />
18
- <ComponentGroupRef Id="RegistryComponentGroup" />
19
- <%- get_services.each do |service| -%>
20
- <ComponentGroupRef Id="<%= service.component_group_id %>" />
21
- <%- end -%>
22
- <!-- All of these Include refs are expected to be present -->
23
- <ComponentGroupRef Id="FragmentProperties" />
24
- <ComponentGroupRef Id="FragmentSequences" />
25
- <ComponentGroupRef Id="FragmentCustomActions" />
26
- </ComponentGroup>
27
-
28
- <UI>
29
- <UIRef Id="WixUI_Minimal"/>
30
- </UI>
31
-
32
- </Fragment>
33
- </Wix>
@@ -1,34 +0,0 @@
1
- <?xml version="1.0" encoding="windows-1252"?>
2
- <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
3
- <Product
4
- Id="*"
5
- UpgradeCode="<%= settings[:upgrade_code] %>"
6
- Name="<%= settings[:product_name] %>"
7
- Language="1033"
8
- Codepage="1252"
9
- Version="<%= @platform.wix_product_version(@version) %>"
10
- Manufacturer="<%= settings[:company_name] %>" >
11
-
12
- <Package
13
- InstallerVersion="300"
14
- InstallScope="perMachine"
15
- Description="<%= "#{settings[:product_id]}#{@platform.architecture == "x64" ? " (64-bit)" : ""}" %> Installer"
16
- Comments="<%= @homepage %>"
17
- Compressed="yes"
18
- Platform="<%= @platform.architecture %>" />
19
-
20
- <!-- We will use DirectoryRef at the project level to hook in the project directory structure -->
21
- <Directory Id='TARGETDIR' Name='SourceDir' />
22
-
23
- <MajorUpgrade AllowDowngrades="yes" />
24
- <Media Id="1" Cabinet="<%= settings[:product_id] %>.cab" EmbedCab="yes" CompressionLevel="high" />
25
-
26
- <Feature
27
- Id="<%= settings[:product_id] %>Runtime"
28
- Title="<%= settings[:product_id] %> Runtime"
29
- Level="1">
30
- <ComponentGroupRef Id="MainComponentGroup" />
31
- </Feature>
32
-
33
- </Product>
34
- </Wix>