vanagon 0.13.1 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +0 -45
- data/bin/ship +13 -0
- data/lib/vanagon/component.rb +26 -3
- data/lib/vanagon/component/dsl.rb +51 -10
- data/lib/vanagon/component/rules.rb +26 -10
- data/lib/vanagon/component/source/http.rb +17 -2
- data/lib/vanagon/driver.rb +17 -32
- data/lib/vanagon/engine/pooler.rb +43 -21
- data/lib/vanagon/optparse.rb +70 -24
- data/lib/vanagon/platform.rb +30 -0
- data/lib/vanagon/platform/deb.rb +6 -1
- data/lib/vanagon/platform/dsl.rb +4 -0
- data/lib/vanagon/platform/osx.rb +3 -1
- data/lib/vanagon/platform/rpm.rb +2 -1
- data/lib/vanagon/platform/rpm/aix.rb +1 -0
- data/lib/vanagon/platform/solaris_10.rb +3 -2
- data/lib/vanagon/platform/solaris_11.rb +2 -1
- data/lib/vanagon/platform/windows.rb +11 -1
- data/lib/vanagon/project.rb +152 -27
- data/lib/vanagon/project/dsl.rb +23 -0
- data/lib/vanagon/utilities.rb +5 -2
- data/resources/deb/postinst.erb +17 -0
- data/resources/deb/triggers.erb +11 -0
- data/resources/rpm/project.spec.erb +18 -2
- data/spec/lib/vanagon/component/dsl_spec.rb +92 -2
- data/spec/lib/vanagon/component/rules_spec.rb +84 -0
- data/spec/lib/vanagon/component/source/http_spec.rb +1 -1
- data/spec/lib/vanagon/component/source/rewrite_spec.rb +6 -4
- data/spec/lib/vanagon/component/source_spec.rb +10 -5
- data/spec/lib/vanagon/component_spec.rb +4 -0
- data/spec/lib/vanagon/optparse_spec.rb +30 -6
- data/spec/lib/vanagon/platform/windows_spec.rb +28 -0
- data/spec/lib/vanagon/project_spec.rb +179 -0
- metadata +3 -4
- data/bin/devkit +0 -22
@@ -65,6 +65,10 @@ describe "Vanagon::Component" do
|
|
65
65
|
.and_return(OpenStruct.new(verify: true))
|
66
66
|
end
|
67
67
|
|
68
|
+
it "will not consider a non-rewritten URI as a mirror" do
|
69
|
+
expect(subject.mirrors).to eq Set.new []
|
70
|
+
end
|
71
|
+
|
68
72
|
it "attempts to retrieve from a mirror before a canonical URI" do
|
69
73
|
allow(subject)
|
70
74
|
.to receive(:fetch_url)
|
@@ -3,28 +3,52 @@ require 'vanagon/optparse'
|
|
3
3
|
describe Vanagon::OptParse do
|
4
4
|
|
5
5
|
describe "options that don't take a value" do
|
6
|
-
[:skipcheck, :
|
6
|
+
[:skipcheck, :verbose].each do |flag|
|
7
7
|
it "can create an option parser that accepts the #{flag} flag" do
|
8
8
|
subject = described_class.new("test", [flag])
|
9
|
-
expect(subject.parse!(["--#{flag}"])).to
|
9
|
+
expect(subject.parse!(["--#{flag}"])).to have_key(flag)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
describe "short options" do
|
14
|
-
[["
|
14
|
+
[["v", :verbose]].each do |short, long|
|
15
15
|
it "maps the short option #{short} to #{long}" do
|
16
16
|
subject = described_class.new("test", [long])
|
17
|
-
expect(subject.parse!(["-#{short}"])).to
|
17
|
+
expect(subject.parse!(["-#{short}"])).to include(long => true)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
describe "options that only allow limited values" do
|
24
|
+
[[:preserve, ["always", "never", "on-failure"]]].each do |option, values|
|
25
|
+
values.each do |value|
|
26
|
+
it "can create a parser that accepts \"--#{option} #{value}\"" do
|
27
|
+
subject = described_class.new("test", [option, value])
|
28
|
+
expect(subject.parse!(["--#{option}", value])).to eq(option => value.to_sym)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
[[:preserve, ["bad-argument"]]].each do |option, values|
|
33
|
+
values.each do |value|
|
34
|
+
it "rejects the bad argument \"--#{option} #{value}\"" do
|
35
|
+
subject = described_class.new("test", [option, value])
|
36
|
+
expect{subject.parse!(["--#{option}", value])}.to raise_error(OptionParser::InvalidArgument)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
it "preserve defaults to :on-failure" do
|
41
|
+
subject = described_class.new("test")
|
42
|
+
expect(subject.parse!([])).to include(:preserve => :'on-failure')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
23
47
|
describe "options that take a value" do
|
24
48
|
[:workdir, :configdir, :target, :engine].each do |option|
|
25
49
|
it "can create an option parser that accepts the #{option} option" do
|
26
50
|
subject = described_class.new("test", [option])
|
27
|
-
expect(subject.parse!(["--#{option}", "hello"])).to
|
51
|
+
expect(subject.parse!(["--#{option}", "hello"])).to include(option => "hello")
|
28
52
|
end
|
29
53
|
end
|
30
54
|
|
@@ -32,7 +56,7 @@ describe Vanagon::OptParse do
|
|
32
56
|
[["w", :workdir], ["c", :configdir], ["t", :target], ["e", :engine]].each do |short, long|
|
33
57
|
it "maps the short option #{short} to #{long}" do
|
34
58
|
subject = described_class.new("test", [long])
|
35
|
-
expect(subject.parse!(["-#{short}", "hello"])).to
|
59
|
+
expect(subject.parse!(["-#{short}", "hello"])).to include(long => "hello")
|
36
60
|
end
|
37
61
|
end
|
38
62
|
end
|
@@ -38,6 +38,7 @@ describe "Vanagon::Platform::Windows" do
|
|
38
38
|
let (:project_block) {
|
39
39
|
<<-HERE.undent
|
40
40
|
project 'test-fixture' do |proj|
|
41
|
+
proj.version '0.0.0'
|
41
42
|
proj.setting(:company_name, "Test Name")
|
42
43
|
proj.setting(:company_id, "TestID")
|
43
44
|
proj.setting(:product_id, "TestProduct")
|
@@ -65,6 +66,33 @@ describe "Vanagon::Platform::Windows" do
|
|
65
66
|
expect(cur_plat._platform.wix_product_version("1.0.g0")).to eq("1.0.0")
|
66
67
|
end
|
67
68
|
end
|
69
|
+
|
70
|
+
describe '#package_type' do
|
71
|
+
it "skips package generation for 'archive' package types" do
|
72
|
+
cur_plat.instance_eval(plat[:block])
|
73
|
+
cur_plat.package_type 'archive'
|
74
|
+
proj = Vanagon::Project::DSL.new('test-fixture', cur_plat._platform, [])
|
75
|
+
proj.instance_eval(project_block)
|
76
|
+
expect(cur_plat._platform.generate_package(proj._project)).to eq([])
|
77
|
+
end
|
78
|
+
|
79
|
+
it "generates a package_name for 'archive' package types" do
|
80
|
+
cur_plat.instance_eval(plat[:block])
|
81
|
+
cur_plat.package_type 'archive'
|
82
|
+
proj = Vanagon::Project::DSL.new('test-fixture', cur_plat._platform, [])
|
83
|
+
proj.instance_eval(project_block)
|
84
|
+
expect(cur_plat._platform.package_name(proj._project)).to eq('test-fixture-0.0.0-archive')
|
85
|
+
end
|
86
|
+
|
87
|
+
it "skips packaging artifact generation for 'archive' package types" do
|
88
|
+
cur_plat.instance_eval(plat[:block])
|
89
|
+
cur_plat.package_type 'archive'
|
90
|
+
proj = Vanagon::Project::DSL.new('test-fixture', cur_plat._platform, [])
|
91
|
+
proj.instance_eval(project_block)
|
92
|
+
expect(cur_plat._platform.generate_packaging_artifacts('',proj._project.name,'',proj._project)).to eq(nil)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
68
96
|
describe '#generate_msi_packaging_artifacts' do
|
69
97
|
before(:each) do
|
70
98
|
# Create Workdir and temp root directory
|
@@ -11,6 +11,48 @@ describe 'Vanagon::Project' do
|
|
11
11
|
end"
|
12
12
|
}
|
13
13
|
|
14
|
+
let(:upstream_project_block) {
|
15
|
+
"project 'upstream-test' do |proj|
|
16
|
+
proj.setting(:test, 'upstream-test')
|
17
|
+
end"
|
18
|
+
}
|
19
|
+
|
20
|
+
let(:inheriting_project_block) {
|
21
|
+
"project 'inheritance-test' do |proj|
|
22
|
+
proj.inherit_settings 'upstream-test', 'git://some.url', 'master'
|
23
|
+
end"
|
24
|
+
}
|
25
|
+
|
26
|
+
let(:inheriting_project_block_with_settings) {
|
27
|
+
"project 'inheritance-test' do |proj|
|
28
|
+
proj.setting(:merged, 'yup')
|
29
|
+
proj.inherit_settings 'upstream-test', 'git://some.url', 'master'
|
30
|
+
end"
|
31
|
+
}
|
32
|
+
|
33
|
+
let(:preset_inheriting_project_block) {
|
34
|
+
"project 'inheritance-test' do |proj|
|
35
|
+
proj.setting(:test, 'inheritance-test')
|
36
|
+
proj.inherit_settings 'upstream-test', 'git://some.url', 'master'
|
37
|
+
end"
|
38
|
+
}
|
39
|
+
|
40
|
+
let(:postset_inheriting_project_block) {
|
41
|
+
"project 'inheritance-test' do |proj|
|
42
|
+
proj.inherit_settings 'upstream-test', 'git://some.url', 'master'
|
43
|
+
proj.setting(:test, 'inheritance-test')
|
44
|
+
end"
|
45
|
+
}
|
46
|
+
|
47
|
+
let (:dummy_platform_sysv) {
|
48
|
+
plat = Vanagon::Platform::DSL.new('debian-6-i386')
|
49
|
+
plat.instance_eval("platform 'debian-6-i386' do |plat|
|
50
|
+
plat.servicetype 'sysv'
|
51
|
+
plat.servicedir '/etc/init.d'
|
52
|
+
plat.defaultdir '/etc/default'
|
53
|
+
end")
|
54
|
+
plat._platform
|
55
|
+
}
|
14
56
|
|
15
57
|
describe '#get_root_directories' do
|
16
58
|
|
@@ -44,6 +86,46 @@ describe 'Vanagon::Project' do
|
|
44
86
|
end
|
45
87
|
end
|
46
88
|
|
89
|
+
describe "#load_upstream_settings" do
|
90
|
+
before(:each) do
|
91
|
+
# stub out all of the git methods so we don't actually clone
|
92
|
+
allow(Vanagon::Component::Source::Git).to receive(:valid_remote?).with(URI.parse('git://some.url')).and_return(true)
|
93
|
+
git_source = Vanagon::Component::Source::Git.new('git://some.url', workdir: Dir.getwd)
|
94
|
+
allow(Vanagon::Component::Source::Git).to receive(:new).and_return(git_source)
|
95
|
+
expect(git_source).to receive(:fetch).and_return(true)
|
96
|
+
|
97
|
+
# stubs for the upstream project
|
98
|
+
upstream_proj = Vanagon::Project::DSL.new('upstream-test', {}, [])
|
99
|
+
upstream_proj.instance_eval(upstream_project_block)
|
100
|
+
expect(Vanagon::Project).to receive(:load_project).and_return(upstream_proj._project)
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'loads upstream settings' do
|
104
|
+
inheriting_proj = Vanagon::Project::DSL.new('inheritance-test', {}, [])
|
105
|
+
inheriting_proj.instance_eval(inheriting_project_block)
|
106
|
+
expect(inheriting_proj._project.settings[:test]).to eq('upstream-test')
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'overrides duplicate settings from before the load' do
|
110
|
+
inheriting_proj = Vanagon::Project::DSL.new('inheritance-test', {}, [])
|
111
|
+
inheriting_proj.instance_eval(preset_inheriting_project_block)
|
112
|
+
expect(inheriting_proj._project.settings[:test]).to eq('upstream-test')
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'lets you override settings after the load' do
|
116
|
+
inheriting_proj = Vanagon::Project::DSL.new('inheritance-test', {}, [])
|
117
|
+
inheriting_proj.instance_eval(postset_inheriting_project_block)
|
118
|
+
expect(inheriting_proj._project.settings[:test]).to eq('inheritance-test')
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'merges settings' do
|
122
|
+
inheriting_proj = Vanagon::Project::DSL.new('inheritance-test', {}, [])
|
123
|
+
inheriting_proj.instance_eval(inheriting_project_block_with_settings)
|
124
|
+
expect(inheriting_proj._project.settings[:test]).to eq('upstream-test')
|
125
|
+
expect(inheriting_proj._project.settings[:merged]).to eq('yup')
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
47
129
|
describe "#filter_component" do
|
48
130
|
|
49
131
|
# All of the following tests should be run with one project level
|
@@ -116,6 +198,55 @@ describe 'Vanagon::Project' do
|
|
116
198
|
end
|
117
199
|
end
|
118
200
|
|
201
|
+
describe '#get_preinstall_actions' do
|
202
|
+
it "Collects the preinstall actions for the specified package state" do
|
203
|
+
proj = Vanagon::Project.new('action-test', {})
|
204
|
+
proj.get_preinstall_actions('upgrade')
|
205
|
+
proj.get_preinstall_actions('install')
|
206
|
+
expect(proj.get_preinstall_actions('install')).to be_instance_of(String)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
describe '#get_trigger_scripts' do
|
211
|
+
it "Collects the install triggers for the project for the specified packing state" do
|
212
|
+
proj = Vanagon::Project.new('action-test', {})
|
213
|
+
expect(proj.get_trigger_scripts('install')).to eq({})
|
214
|
+
expect(proj.get_trigger_scripts('upgrade')).to be_instance_of(Hash)
|
215
|
+
end
|
216
|
+
it 'fails with empty install trigger action' do
|
217
|
+
proj = Vanagon::Project.new('action-test', {})
|
218
|
+
expect { proj.get_trigger_scripts([]) }.to raise_error(Vanagon::Error)
|
219
|
+
end
|
220
|
+
it 'fails with incorrect install trigger action' do
|
221
|
+
proj = Vanagon::Project.new('action-test', {})
|
222
|
+
expect { proj.get_trigger_scripts('foo') }.to raise_error(Vanagon::Error)
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
describe '#get_interest_triggers' do
|
227
|
+
it "Collects the interest triggers for the project for the specified packaging state" do
|
228
|
+
proj = Vanagon::Project.new('action-test', {})
|
229
|
+
expect(proj.get_interest_triggers('install')).to eq([])
|
230
|
+
expect(proj.get_interest_triggers('upgrade')).to be_instance_of(Array)
|
231
|
+
end
|
232
|
+
it 'fails with empty interest trigger action' do
|
233
|
+
proj = Vanagon::Project.new('action-test', {})
|
234
|
+
expect { proj.get_interest_triggers([]) }.to raise_error(Vanagon::Error)
|
235
|
+
end
|
236
|
+
it 'fails with incorrect interest trigger action' do
|
237
|
+
proj = Vanagon::Project.new('action-test', {})
|
238
|
+
expect { proj.get_interest_triggers('foo') }.to raise_error(Vanagon::Error)
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
describe '#get_activate_triggers' do
|
243
|
+
it "Collects the activate triggers for the project for the specified packaging state" do
|
244
|
+
proj = Vanagon::Project.new('action-test', {})
|
245
|
+
expect(proj.get_activate_triggers()).to be_instance_of(Array)
|
246
|
+
expect(proj.get_activate_triggers()).to be_instance_of(Array)
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
119
250
|
describe '#generate_dependencies_info' do
|
120
251
|
before(:each) do
|
121
252
|
@proj = Vanagon::Project.new('test-project', {})
|
@@ -165,5 +296,53 @@ describe 'Vanagon::Project' do
|
|
165
296
|
'build_time' => '2017-07-10T13:34:25-07:00',
|
166
297
|
})
|
167
298
|
end
|
299
|
+
|
300
|
+
it 'should call pretty-print when we want pretty json' do
|
301
|
+
comp1 = Vanagon::Component.new('test-component1', {}, {})
|
302
|
+
comp1.version = '1.0.0'
|
303
|
+
@proj.components << comp1
|
304
|
+
@proj.version = '123abcde'
|
305
|
+
|
306
|
+
expect(JSON).to receive(:pretty_generate)
|
307
|
+
@proj.build_manifest_json(true)
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
describe '#generate_package' do
|
312
|
+
it "builds packages by default" do
|
313
|
+
platform = Vanagon::Platform::DSL.new('el-7-x86_64')
|
314
|
+
platform.instance_eval("platform 'el-7-x86_6' do |plat| end")
|
315
|
+
proj = Vanagon::Project::DSL.new('test-fixture', platform._platform, [])
|
316
|
+
expect(platform._platform).to receive(:generate_package) { ["# making a package"] }
|
317
|
+
expect(proj._project.generate_package).to eq(["# making a package"])
|
318
|
+
end
|
319
|
+
|
320
|
+
it "builds packages and archives if configured for both" do
|
321
|
+
platform = Vanagon::Platform::DSL.new('el-7-x86_64')
|
322
|
+
platform.instance_eval("platform 'el-7-x86_6' do |plat| end")
|
323
|
+
proj = Vanagon::Project::DSL.new('test-fixture', platform._platform, [])
|
324
|
+
proj.generate_archives(true)
|
325
|
+
expect(platform._platform).to receive(:generate_package) { ["# making a package"] }
|
326
|
+
expect(platform._platform).to receive(:generate_compiled_archive) { ["# making an archive"] }
|
327
|
+
expect(proj._project.generate_package).to eq(["# making a package", "# making an archive"])
|
328
|
+
end
|
329
|
+
|
330
|
+
it "can build only archives" do
|
331
|
+
platform = Vanagon::Platform::DSL.new('el-7-x86_64')
|
332
|
+
platform.instance_eval("platform 'el-7-x86_6' do |plat| end")
|
333
|
+
proj = Vanagon::Project::DSL.new('test-fixture', platform._platform, [])
|
334
|
+
proj.generate_archives(true)
|
335
|
+
proj.generate_packages(false)
|
336
|
+
expect(platform._platform).to receive(:generate_compiled_archive) { ["# making an archive"] }
|
337
|
+
expect(proj._project.generate_package).to eq(["# making an archive"])
|
338
|
+
end
|
339
|
+
|
340
|
+
it "builds nothing if that's what you really want" do
|
341
|
+
platform = Vanagon::Platform::DSL.new('el-7-x86_64')
|
342
|
+
platform.instance_eval("platform 'el-7-x86_6' do |plat| end")
|
343
|
+
proj = Vanagon::Project::DSL.new('test-fixture', platform._platform, [])
|
344
|
+
proj.generate_packages(false)
|
345
|
+
expect(proj._project.generate_package).to eq([])
|
346
|
+
end
|
168
347
|
end
|
169
348
|
end
|
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
|
+
version: 0.14.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet Labs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|
@@ -61,7 +61,6 @@ executables:
|
|
61
61
|
- ship
|
62
62
|
- render
|
63
63
|
- repo
|
64
|
-
- devkit
|
65
64
|
- build_host_info
|
66
65
|
extensions: []
|
67
66
|
extra_rdoc_files: []
|
@@ -70,7 +69,6 @@ files:
|
|
70
69
|
- README.md
|
71
70
|
- bin/build
|
72
71
|
- bin/build_host_info
|
73
|
-
- bin/devkit
|
74
72
|
- bin/inspect
|
75
73
|
- bin/render
|
76
74
|
- bin/repo
|
@@ -133,6 +131,7 @@ files:
|
|
133
131
|
- resources/deb/preinst.erb
|
134
132
|
- resources/deb/prerm.erb
|
135
133
|
- resources/deb/rules.erb
|
134
|
+
- resources/deb/triggers.erb
|
136
135
|
- resources/osx/postinstall.erb
|
137
136
|
- resources/osx/preinstall.erb
|
138
137
|
- resources/osx/project-installer.xml.erb
|
data/bin/devkit
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
load File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "vanagon.rb"))
|
3
|
-
|
4
|
-
optparse = Vanagon::OptParse.new("#{File.basename(__FILE__)} <project-name> <platform-name> [<component-name>...] [options]",
|
5
|
-
%i[workdir configdir target engine])
|
6
|
-
options = optparse.parse! ARGV
|
7
|
-
|
8
|
-
project = ARGV[0]
|
9
|
-
platform = ARGV[1]
|
10
|
-
components = ARGV.drop(2)
|
11
|
-
|
12
|
-
if project.nil? or platform.nil?
|
13
|
-
warn "project and platform are both required arguments."
|
14
|
-
$stderr.puts optparse
|
15
|
-
exit 1
|
16
|
-
end
|
17
|
-
|
18
|
-
artifact = Vanagon::Driver.new(platform, project, options.merge({ :components => components }))
|
19
|
-
|
20
|
-
artifact.preserve = true
|
21
|
-
|
22
|
-
artifact.prepare(options[:workdir])
|