vanagon 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,4 +19,21 @@ describe "Vanagon::Component" do
19
19
  expect(comp.get_environment).to eq(':')
20
20
  end
21
21
  end
22
+
23
+ describe "#get_build_dir" do
24
+ subject(:comp) do
25
+ Vanagon::Component.new('build-dir-test', {}, {}).tap do |comp|
26
+ comp.dirname = "build-dir-test"
27
+ end
28
+ end
29
+
30
+ it "uses the dirname when no build_dir was set" do
31
+ expect(comp.get_build_dir).to eq "build-dir-test"
32
+ end
33
+
34
+ it "joins the dirname and the build dir when a build_dir was set" do
35
+ comp.build_dir = "cmake-build"
36
+ expect(comp.get_build_dir).to eq File.join("build-dir-test", "cmake-build")
37
+ end
38
+ end
22
39
  end
@@ -0,0 +1,48 @@
1
+ require 'vanagon/engine/hardware'
2
+ require 'vanagon/driver'
3
+ require 'vanagon/platform'
4
+ require 'logger'
5
+
6
+ # Haus, I added this, cause it prevented errors.
7
+ @@logger = Logger.new('/dev/null')
8
+
9
+ describe 'Vanagon::Engine::Hardware' do
10
+
11
+ let (:platform_without_build_hosts) {
12
+ plat = Vanagon::Platform::DSL.new('aix-7.1-ppc')
13
+ plat.instance_eval("platform 'aix-7.1-ppc' do |plat|
14
+ end")
15
+ plat._platform
16
+ }
17
+
18
+ let (:platform) {
19
+ plat = Vanagon::Platform::DSL.new('aix-6.1-ppc')
20
+ plat.instance_eval("platform 'aix-6.1-ppc' do |plat|
21
+ plat.build_host 'abcd'
22
+ end")
23
+ plat._platform
24
+ }
25
+
26
+ describe '#select_target' do
27
+ it 'raises an error without a target' do
28
+ base = Vanagon::Engine::Hardware.new(platform_without_build_hosts, nil)
29
+ expect { base.validate_platform }.to raise_error(Vanagon::Error)
30
+ end
31
+
32
+ it 'returns a target if one is set' do
33
+ base = Vanagon::Engine::Hardware.new(platform, nil)
34
+ expect(base).to receive(:node_lock).with(['abcd']).and_return('abcd')
35
+ expect(base.select_target).to eq('abcd')
36
+ end
37
+ end
38
+
39
+ describe '#validate_platform' do
40
+ it 'raises an error if the platform is missing a required attribute' do
41
+ expect{ Vanagon::Engine::Hardware.new(platform_without_build_hosts, nil).validate_platform }.to raise_error(Vanagon::Error)
42
+ end
43
+
44
+ it 'returns true if the platform has the required attributes' do
45
+ expect(Vanagon::Engine::Hardware.new(platform, nil).validate_platform).to be(true)
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,40 @@
1
+ require 'vanagon/optparse'
2
+
3
+ describe Vanagon::OptParse do
4
+
5
+ describe "options that don't take a value" do
6
+ [:skipcheck, :preserve, :verbose].each do |flag|
7
+ it "can create an option parser that accepts the #{flag} flag" do
8
+ subject = described_class.new("test", [flag])
9
+ expect(subject.parse!(["--#{flag}"])).to eq(flag => true)
10
+ end
11
+ end
12
+
13
+ describe "short options" do
14
+ [["p", :preserve], ["v", :verbose]].each do |short, long|
15
+ it "maps the short option #{short} to #{long}" do
16
+ subject = described_class.new("test", [long])
17
+ expect(subject.parse!(["-#{short}"])).to eq(long => true)
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ describe "options that take a value" do
24
+ [:workdir, :configdir, :target, :engine].each do |option|
25
+ it "can create an option parser that accepts the #{option} option" do
26
+ subject = described_class.new("test", [option])
27
+ expect(subject.parse!(["--#{option}", "hello"])).to eq(option => "hello")
28
+ end
29
+ end
30
+
31
+ describe "short options" do
32
+ [["w", :workdir], ["c", :configdir], ["t", :target], ["e", :engine]].each do |short, long|
33
+ it "maps the short option #{short} to #{long}" do
34
+ subject = described_class.new("test", [long])
35
+ expect(subject.parse!(["-#{short}", "hello"])).to eq(long => "hello")
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,32 @@
1
+ require 'vanagon/utilities/shell_utilities'
2
+
3
+ describe Vanagon::Utilities::ShellUtilities do
4
+ describe "#cmdjoin" do
5
+ it "returns a single value as-is" do
6
+ expect(described_class.cmdjoin(["make test"], " !! ")).to eq "make test"
7
+ end
8
+
9
+ it "turns an array with a single value into the wrapped value" do
10
+ expect(described_class.cmdjoin([["make test"]], " !! ")).to eq "make test"
11
+ end
12
+
13
+ it "joins multiple commands with the separator string" do
14
+ expect(described_class.cmdjoin(["cd build", "cmake ..", "make"], " !! ")).to eq "cd build !! cmake .. !! make"
15
+ end
16
+
17
+ it "joins single strings and arrays of strings" do
18
+ expect(described_class.cmdjoin([
19
+ "cd build",
20
+ ["make", "make test"]
21
+ ], " !! ")).to eq "cd build !! make !! make test"
22
+ end
23
+ end
24
+
25
+ it "#andand joins commands with &&" do
26
+ expect(described_class.andand("foo", ["bar", "baz"])).to eq "foo && bar && baz"
27
+ end
28
+
29
+ it "#andand_multiline joins commands with && and an escaped newline" do
30
+ expect(described_class.andand_multiline("foo", ["bar", "baz"])).to eq "foo && \\\nbar && \\\nbaz"
31
+ end
32
+ end
@@ -55,64 +55,7 @@ cleanup-components: <%= @components.map {|comp| "#{comp.name}-cleanup" }.join("
55
55
  touch <%= @name %>-project
56
56
 
57
57
  <%- @components.each do |comp| -%>
58
- <%= comp.name %>: <%= comp.name %>-install
59
-
60
- <%- if @cleanup -%>
61
- <%= comp.name %>-cleanup: <%= comp.name %>-install
62
- <%= comp.cleanup_source %>
63
- touch <%= comp.name %>-cleanup
64
- <%- end -%>
65
-
66
- <%= comp.name %>-unpack: file-list-before-build
67
- <%= comp.extract_with %>
68
- touch <%= comp.name %>-unpack
69
-
70
- <%= comp.name %>-patch: <%= comp.name %>-unpack
71
- <%- unless comp.patches.empty? -%>
72
- cd <%= comp.dirname %> && \
73
- <%- comp.patches.each do |patch| -%>
74
- <%= @platform.patch %> --strip=<%= patch.strip %> --fuzz=<%= patch.fuzz %> --ignore-whitespace < ../patches/<%= File.basename(patch.path) %> && \
75
- <%- end -%>
76
- :
77
- <%- end -%>
78
-
79
- touch <%= comp.name %>-patch
80
-
81
- <%= comp.name %>-configure: <%= comp.name %>-patch <%= list_component_dependencies(comp).join(" ") %>
82
- <%- unless comp.configure.empty? -%>
83
- cd <%= comp.dirname %> && \
84
- <%= comp.get_environment %> && \
85
- <%= comp.configure.join(" && \\\n\t") %>
86
- <%- end -%>
87
- touch <%= comp.name %>-configure
88
-
89
- <%= comp.name %>-build: <%= comp.name %>-configure
90
- <%- unless comp.build.empty? -%>
91
- cd <%= comp.dirname %> && \
92
- <%= comp.get_environment %> && \
93
- <%= comp.build.join(" && \\\n\t") %>
94
- <%- end -%>
95
- touch <%= comp.name %>-build
96
-
97
- <%= comp.name %>-install: <%= comp.name %>-build
98
- <%- unless comp.install.empty? -%>
99
- cd <%= comp.dirname %> && \
100
- <%= comp.get_environment %> && \
101
- <%= comp.install.join(" && \\\n\t") %>
102
- <%- end -%>
103
- touch <%= comp.name %>-install
104
-
105
- <%= comp.name %>-clean:
106
- [ -d <%= comp.dirname %> ] && cd <%= comp.dirname %> && \
107
- <%= @platform[:make] %> clean
108
- <%- ["configure", "build", "install"].each do |type| -%>
109
- [ -e <%= comp.name %>-<%= type %> ] && rm <%= comp.name %>-<%= type %>
110
- <%- end -%>
111
-
112
- <%= comp.name %>-clobber: <%= comp.name %>-clean
113
- [ -d <%= comp.dirname %> ] && rm -r <%= comp.dirname %>
114
- [ -e <%= comp.name %>-unpack ] && rm <%= comp.name %>-unpack
115
-
58
+ <%= comp.rules(self, @platform).to_s %>
116
59
  <%- end -%>
117
60
 
118
61
  clean: <%= @components.map {|comp| "#{comp.name}-clean" }.join(" ") %>
@@ -90,7 +90,7 @@ install -d %{buildroot}
90
90
  cp -Rp <%= file %> %{buildroot}/<%= File.dirname(file) %>
91
91
  <%- end -%>
92
92
 
93
- <%- if @platform.is_cisco_wrlinux? || @platform.is_huaweios? -%>
93
+ <%- if @platform.is_cisco_wrlinux? -%>
94
94
  # Generate a list of directories and append it to the file list. RPMv4
95
95
  # automatically does this implicitly, but RPMv5 is more strict and you
96
96
  # need to list the dirs for them to be packaged properly.
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.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-12 00:00:00.000000000 Z
11
+ date: 2016-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: lock_manager
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description: Vanagon is a tool to build a single package out of a project, which can
42
56
  itself contain one or more components.
43
57
  email: info@puppetlabs.com
@@ -55,50 +69,59 @@ files:
55
69
  - bin/devkit
56
70
  - bin/repo
57
71
  - bin/ship
72
+ - lib/makefile.rb
58
73
  - lib/vanagon.rb
59
74
  - lib/vanagon/common.rb
60
75
  - lib/vanagon/common/pathname.rb
61
76
  - lib/vanagon/common/user.rb
62
77
  - lib/vanagon/component.rb
63
78
  - lib/vanagon/component/dsl.rb
79
+ - lib/vanagon/component/rules.rb
64
80
  - lib/vanagon/component/source.rb
65
81
  - lib/vanagon/component/source/git.rb
66
82
  - lib/vanagon/component/source/http.rb
67
83
  - lib/vanagon/driver.rb
68
84
  - lib/vanagon/engine/base.rb
69
85
  - lib/vanagon/engine/docker.rb
86
+ - lib/vanagon/engine/hardware.rb
70
87
  - lib/vanagon/engine/local.rb
71
88
  - lib/vanagon/engine/pooler.rb
72
89
  - lib/vanagon/errors.rb
73
90
  - lib/vanagon/extensions/string.rb
74
91
  - lib/vanagon/optparse.rb
92
+ - lib/vanagon/patch.rb
75
93
  - lib/vanagon/platform.rb
76
94
  - lib/vanagon/platform/deb.rb
77
95
  - lib/vanagon/platform/dsl.rb
78
96
  - lib/vanagon/platform/osx.rb
79
97
  - lib/vanagon/platform/rpm.rb
80
98
  - lib/vanagon/platform/rpm/aix.rb
99
+ - lib/vanagon/platform/rpm/eos.rb
81
100
  - lib/vanagon/platform/rpm/sles.rb
82
101
  - lib/vanagon/platform/rpm/wrl.rb
83
102
  - lib/vanagon/platform/solaris_10.rb
84
103
  - lib/vanagon/platform/solaris_11.rb
85
- - lib/vanagon/platform/swix.rb
86
104
  - lib/vanagon/project.rb
87
105
  - lib/vanagon/project/dsl.rb
88
106
  - lib/vanagon/utilities.rb
107
+ - lib/vanagon/utilities/shell_utilities.rb
89
108
  - spec/fixures/component/invalid-test-fixture.json
90
109
  - spec/fixures/component/mcollective.service
91
110
  - spec/fixures/component/test-fixture.json
111
+ - spec/lib/makefile_spec.rb
92
112
  - spec/lib/vanagon/common/pathname_spec.rb
93
113
  - spec/lib/vanagon/common/user_spec.rb
94
114
  - spec/lib/vanagon/component/dsl_spec.rb
115
+ - spec/lib/vanagon/component/rules_spec.rb
95
116
  - spec/lib/vanagon/component/source/git_spec.rb
96
117
  - spec/lib/vanagon/component/source/http_spec.rb
97
118
  - spec/lib/vanagon/component/source_spec.rb
98
119
  - spec/lib/vanagon/component_spec.rb
99
120
  - spec/lib/vanagon/engine/base_spec.rb
100
121
  - spec/lib/vanagon/engine/docker_spec.rb
122
+ - spec/lib/vanagon/engine/hardware_spec.rb
101
123
  - spec/lib/vanagon/engine/pooler_spec.rb
124
+ - spec/lib/vanagon/optparse_spec.rb
102
125
  - spec/lib/vanagon/platform/deb_spec.rb
103
126
  - spec/lib/vanagon/platform/dsl_spec.rb
104
127
  - spec/lib/vanagon/platform/rpm/aix_spec.rb
@@ -107,6 +130,7 @@ files:
107
130
  - spec/lib/vanagon/platform_spec.rb
108
131
  - spec/lib/vanagon/project/dsl_spec.rb
109
132
  - spec/lib/vanagon/project_spec.rb
133
+ - spec/lib/vanagon/utilities/shell_utilities_spec.rb
110
134
  - spec/lib/vanagon/utilities_spec.rb
111
135
  - templates/Makefile.erb
112
136
  - templates/deb/changelog.erb
@@ -151,21 +175,25 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
175
  version: '0'
152
176
  requirements: []
153
177
  rubyforge_project:
154
- rubygems_version: 2.4.5
178
+ rubygems_version: 2.4.6
155
179
  signing_key:
156
180
  specification_version: 3
157
181
  summary: All of your packages will fit into this van with this one simple trick.
158
182
  test_files:
183
+ - spec/lib/makefile_spec.rb
159
184
  - spec/lib/vanagon/common/pathname_spec.rb
160
185
  - spec/lib/vanagon/common/user_spec.rb
161
186
  - spec/lib/vanagon/component/dsl_spec.rb
187
+ - spec/lib/vanagon/component/rules_spec.rb
162
188
  - spec/lib/vanagon/component/source/git_spec.rb
163
189
  - spec/lib/vanagon/component/source/http_spec.rb
164
190
  - spec/lib/vanagon/component/source_spec.rb
165
191
  - spec/lib/vanagon/component_spec.rb
166
192
  - spec/lib/vanagon/engine/base_spec.rb
167
193
  - spec/lib/vanagon/engine/docker_spec.rb
194
+ - spec/lib/vanagon/engine/hardware_spec.rb
168
195
  - spec/lib/vanagon/engine/pooler_spec.rb
196
+ - spec/lib/vanagon/optparse_spec.rb
169
197
  - spec/lib/vanagon/platform/deb_spec.rb
170
198
  - spec/lib/vanagon/platform/dsl_spec.rb
171
199
  - spec/lib/vanagon/platform/rpm/aix_spec.rb
@@ -174,5 +202,6 @@ test_files:
174
202
  - spec/lib/vanagon/platform_spec.rb
175
203
  - spec/lib/vanagon/project/dsl_spec.rb
176
204
  - spec/lib/vanagon/project_spec.rb
205
+ - spec/lib/vanagon/utilities/shell_utilities_spec.rb
177
206
  - spec/lib/vanagon/utilities_spec.rb
178
207
  has_rdoc:
@@ -1,35 +0,0 @@
1
- class Vanagon
2
- class Platform
3
- class RPM
4
- class Swix < Vanagon::Platform::RPM
5
- # The specific bits used to generate an SWIX package for a given project
6
- #
7
- # @param project [Vanagon::Project] project to build a SWIX package of
8
- # @return [Array] list of commands required to build the SWIX package
9
- # for the given project from an rpm
10
- def generate_package(project)
11
- target_dir = project.repo ? output_dir(project.repo) : output_dir
12
-
13
- commands = super(project)
14
- pkgname_swix = package_name(project)
15
- pkgname_rpm = pkgname_swix.sub(/swix$/, 'rpm')
16
- commands += ["echo 'format: 1' > ./output/#{target_dir}/manifest.txt",
17
- "echo \"primaryRpm: #{pkgname_rpm}\" >> ./output/#{target_dir}/manifest.txt",
18
- "echo #{pkgname_rpm}-sha1: `sha1sum ./output/#{target_dir}/#{pkgname_rpm}`",
19
- "cd ./output/#{target_dir}/ && zip #{pkgname_swix} manifest.txt #{pkgname_rpm}",
20
- "rm ./output/#{target_dir}/manifest.txt ./output/#{target_dir}/#{pkgname_rpm}"]
21
-
22
- commands
23
- end
24
-
25
- # Method to derive the package name for the project
26
- #
27
- # @param project [Vanagon::Project] project to name
28
- # @return [String] name of the SWIX package for this project
29
- def package_name(project)
30
- "#{project.name}-#{project.version}-#{project.release}.#{os_name}#{os_version}.#{project.noarch ? 'noarch' : @architecture}.swix"
31
- end
32
- end
33
- end
34
- end
35
- end