vanagon 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -2
- data/bin/build +1 -1
- data/lib/vanagon/component/dsl.rb +6 -6
- data/lib/vanagon/driver.rb +5 -3
- data/lib/vanagon/engine/always_be_scheduling.rb +1 -1
- data/lib/vanagon/engine/base.rb +11 -2
- data/lib/vanagon/engine/docker.rb +1 -1
- data/lib/vanagon/engine/ec2.rb +1 -1
- data/lib/vanagon/engine/hardware.rb +1 -1
- data/lib/vanagon/engine/local.rb +1 -1
- data/lib/vanagon/engine/pooler.rb +1 -1
- data/lib/vanagon/optparse.rb +1 -0
- data/lib/vanagon/platform.rb +10 -0
- data/lib/vanagon/platform/dsl.rb +7 -0
- data/lib/vanagon/platform/rpm.rb +1 -1
- data/resources/Makefile.erb +2 -2
- data/resources/rpm/project.spec.erb +1 -1
- data/spec/lib/vanagon/component/dsl_spec.rb +9 -2
- data/spec/lib/vanagon/driver_spec.rb +19 -0
- data/spec/lib/vanagon/platform/rpm_spec.rb +26 -34
- data/spec/lib/vanagon/platform/windows_spec.rb +65 -62
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79f3affb2f2797cad077ac7341d99cc2f613dd96
|
4
|
+
data.tar.gz: 4a90613f59d7e96c9015e61ff0200404f063fb3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f6b28cd90a8917063035914d5a094ce123aad6991aa721df89bab0c8bd9251e9aafbe924c5253b9c1ea8a6d046fa20149870b448496d126a0d354dd7ebee925
|
7
|
+
data.tar.gz: 6bc644ee0a223cebe705c0c43d7e69cc4de66b099dc05cfb436967298d21b194b320cb9d385e7beafb9132737eedd945268a93b7b8a75b45540940fdeae3a3c2
|
data/README.md
CHANGED
@@ -73,8 +73,13 @@ Build machines should be cleaned between builds.
|
|
73
73
|
#### Flagged arguments (can be anywhere in the command)
|
74
74
|
|
75
75
|
##### -w DIR, --workdir DIR
|
76
|
-
Specifies a directory where the sources should be placed and builds performed.
|
77
|
-
Defaults to a temporary directory created with Ruby's Dir.mktmpdir.
|
76
|
+
Specifies a directory on the local host where the sources should be placed and builds performed.
|
77
|
+
Defaults to a temporary directory created with Ruby's `Dir.mktmpdir` method.
|
78
|
+
|
79
|
+
##### --remote_dir
|
80
|
+
Explicitly specify a directory on the remote target to place sources and perform
|
81
|
+
builds. Components can then be rebuilt manually on the build host for faster iteration. Sources may not be correctly updated if this directory already exists.
|
82
|
+
Defaults to a temporary directory created by running `mktemp -d` on the remote target.
|
78
83
|
|
79
84
|
##### -c DIR, --configdir DIR
|
80
85
|
Specifies where project configuration is found. Defaults to $pwd/configs.
|
data/bin/build
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
load File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "vanagon.rb"))
|
3
3
|
|
4
4
|
optparse = Vanagon::OptParse.new("#{File.basename(__FILE__)} <project-name> <platform-name> [<target>] [options]",
|
5
|
-
[:workdir, :configdir, :engine, :preserve, :verbose, :skipcheck, :only_build])
|
5
|
+
[:workdir, :configdir, :engine, :preserve, :verbose, :skipcheck, :only_build, :remote_workdir])
|
6
6
|
options = optparse.parse! ARGV
|
7
7
|
|
8
8
|
project = ARGV[0]
|
@@ -230,14 +230,14 @@ class Vanagon
|
|
230
230
|
# upgrade if it has been modified
|
231
231
|
#
|
232
232
|
# @param file [String] name of the configfile
|
233
|
-
def configfile(file)
|
233
|
+
def configfile(file, mode: nil, owner: nil, group: nil)
|
234
234
|
# I AM SO SORRY
|
235
235
|
@component.delete_file file
|
236
236
|
if @component.platform.name =~ /solaris-10|osx/
|
237
237
|
@component.install << "mv '#{file}' '#{file}.pristine'"
|
238
|
-
@component.add_file Vanagon::Common::Pathname.configfile("#{file}.pristine")
|
238
|
+
@component.add_file Vanagon::Common::Pathname.configfile("#{file}.pristine", mode: mode, owner: owner, group: group)
|
239
239
|
else
|
240
|
-
@component.add_file Vanagon::Common::Pathname.configfile(file)
|
240
|
+
@component.add_file Vanagon::Common::Pathname.configfile(file, mode: mode, owner: owner, group: group)
|
241
241
|
end
|
242
242
|
end
|
243
243
|
|
@@ -245,9 +245,9 @@ class Vanagon
|
|
245
245
|
#
|
246
246
|
# @param source [String] path to the configfile to copy
|
247
247
|
# @param target [String] path to the desired target of the configfile
|
248
|
-
def install_configfile(source, target)
|
249
|
-
install_file(source, target)
|
250
|
-
configfile(target)
|
248
|
+
def install_configfile(source, target, mode: '0644', owner: nil, group: nil)
|
249
|
+
install_file(source, target, mode: mode, owner: owner, group: group)
|
250
|
+
configfile(target, mode: mode, owner: owner, group: group)
|
251
251
|
end
|
252
252
|
|
253
253
|
# link will add a command to the install to create a symlink from source to target
|
data/lib/vanagon/driver.rb
CHANGED
@@ -10,10 +10,10 @@ require 'logger'
|
|
10
10
|
class Vanagon
|
11
11
|
class Driver
|
12
12
|
include Vanagon::Utilities
|
13
|
-
attr_accessor :platform, :project, :target, :workdir, :verbose, :preserve
|
13
|
+
attr_accessor :platform, :project, :target, :workdir, :remote_workdir, :verbose, :preserve
|
14
14
|
attr_accessor :timeout, :retry_count
|
15
15
|
|
16
|
-
def initialize(platform, project, options = { workdir: nil, configdir: nil, target: nil, engine: nil, components: nil, skipcheck: false, verbose: false, preserve: false, only_build: nil }) # rubocop:disable Metrics/AbcSize
|
16
|
+
def initialize(platform, project, options = { workdir: nil, configdir: nil, target: nil, engine: nil, components: nil, skipcheck: false, verbose: false, preserve: false, only_build: nil, remote_workdir: nil }) # rubocop:disable Metrics/AbcSize
|
17
17
|
@verbose = options[:verbose]
|
18
18
|
@preserve = options[:preserve]
|
19
19
|
@workdir = options[:workdir] || Dir.mktmpdir
|
@@ -31,6 +31,8 @@ class Vanagon
|
|
31
31
|
filter_out_components(only_build) if only_build
|
32
32
|
loginit('vanagon_hosts.log')
|
33
33
|
|
34
|
+
@remote_workdir = options[:remote_workdir]
|
35
|
+
|
34
36
|
load_engine(engine, @platform, target)
|
35
37
|
rescue LoadError => e
|
36
38
|
raise Vanagon::Error.wrap(e, "Could not load the desired engine '#{engine}'")
|
@@ -63,7 +65,7 @@ class Vanagon
|
|
63
65
|
|
64
66
|
def load_engine_object(engine_type, platform, target)
|
65
67
|
require "vanagon/engine/#{engine_type}"
|
66
|
-
@engine = Object::const_get("Vanagon::Engine::#{camelize(engine_type)}").new(platform, target)
|
68
|
+
@engine = Object::const_get("Vanagon::Engine::#{camelize(engine_type)}").new(platform, target, remote_workdir: remote_workdir)
|
67
69
|
rescue
|
68
70
|
fail "No such engine '#{camelize(engine_type)}'"
|
69
71
|
end
|
@@ -66,7 +66,7 @@ class Vanagon
|
|
66
66
|
# $ build_host_info puppet-agent aix-5.3-ppc --engine always_be_scheduling
|
67
67
|
# {"name":"aix-53-ppc","engine":"always_be_scheduling"}
|
68
68
|
class AlwaysBeScheduling < Base
|
69
|
-
def initialize(platform, target)
|
69
|
+
def initialize(platform, target, **opts)
|
70
70
|
super
|
71
71
|
|
72
72
|
Vanagon::Driver.logger.debug "AlwaysBeScheduling engine invoked."
|
data/lib/vanagon/engine/base.rb
CHANGED
@@ -6,11 +6,12 @@ class Vanagon
|
|
6
6
|
class Base
|
7
7
|
attr_accessor :target, :remote_workdir
|
8
8
|
|
9
|
-
def initialize(platform, target = nil)
|
9
|
+
def initialize(platform, target = nil, **opts)
|
10
10
|
@platform = platform
|
11
11
|
@required_attributes = ["ssh_port"]
|
12
12
|
@target = target if target
|
13
13
|
@target_user = @platform.target_user
|
14
|
+
@remote_workdir_path = opts[:remote_workdir]
|
14
15
|
end
|
15
16
|
|
16
17
|
# Get the engine name
|
@@ -57,7 +58,15 @@ class Vanagon
|
|
57
58
|
end
|
58
59
|
|
59
60
|
def get_remote_workdir
|
60
|
-
@remote_workdir
|
61
|
+
unless @remote_workdir
|
62
|
+
if @remote_workdir_path
|
63
|
+
dispatch("mkdir -p #{@remote_workdir_path}", true)
|
64
|
+
@remote_workdir = @remote_workdir_path
|
65
|
+
else
|
66
|
+
@remote_workdir = dispatch("mktemp -d -p /var/tmp 2>/dev/null || mktemp -d -t 'tmp'", true)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
@remote_workdir
|
61
70
|
end
|
62
71
|
|
63
72
|
def ship_workdir(workdir)
|
@@ -5,7 +5,7 @@ class Vanagon
|
|
5
5
|
class Docker < Base
|
6
6
|
# Both the docker_image and the docker command itself are required for
|
7
7
|
# the docker engine to work
|
8
|
-
def initialize(platform, target = nil)
|
8
|
+
def initialize(platform, target = nil, **opts)
|
9
9
|
super
|
10
10
|
|
11
11
|
@docker_cmd = Vanagon::Utilities.find_program_on_path('docker')
|
data/lib/vanagon/engine/ec2.rb
CHANGED
@@ -9,7 +9,7 @@ class Vanagon
|
|
9
9
|
attr_accessor :ami, :key_name, :userdata, :key, :key_name, :shutdown_behavior
|
10
10
|
attr_accessor :subnet_id, :instance_type
|
11
11
|
|
12
|
-
def initialize(platform, target = nil) # rubocop:disable Metrics/AbcSize
|
12
|
+
def initialize(platform, target = nil, **opts) # rubocop:disable Metrics/AbcSize
|
13
13
|
super
|
14
14
|
|
15
15
|
@ami = @platform.aws_ami
|
data/lib/vanagon/engine/local.rb
CHANGED
data/lib/vanagon/optparse.rb
CHANGED
@@ -4,6 +4,7 @@ class Vanagon
|
|
4
4
|
class OptParse
|
5
5
|
FLAGS = {
|
6
6
|
:workdir => ['-w DIR', '--workdir DIR', "Working directory where build source should be put (defaults to a tmpdir)"],
|
7
|
+
:remote_workdir => ['--remote_workdir DIR', "Working directory where build source should be put on the remote host (defaults to a tmpdir)"],
|
7
8
|
:configdir => ['-c', '--configdir DIR', 'Configs dir (defaults to $pwd/configs)'],
|
8
9
|
:target => ['-t HOST', '--target HOST', 'Configure a target machine for build and packaging (defaults to grabbing one from the pooler)'],
|
9
10
|
:engine => ['-e ENGINE', '--engine ENGINE', "A custom engine to use (defaults to the pooler) [base, local, docker, pooler currently supported]"],
|
data/lib/vanagon/platform.rb
CHANGED
@@ -10,6 +10,7 @@ class Vanagon
|
|
10
10
|
attr_accessor :os_name
|
11
11
|
attr_accessor :os_version
|
12
12
|
attr_accessor :codename # this is Debian/Ubuntu specific
|
13
|
+
attr_writer :dist # most likely to be used by rpm
|
13
14
|
|
14
15
|
# The name of the sort of package type that a given platform expects,
|
15
16
|
# e.g. msi, rpm,
|
@@ -216,6 +217,15 @@ class Vanagon
|
|
216
217
|
@output_dir ||= File.join(@os_name, @os_version, target_repo, @architecture)
|
217
218
|
end
|
218
219
|
|
220
|
+
# Get the value of @dist, or derive it from the value of @os_name and @os_version.
|
221
|
+
# This is relatively RPM specific but '#codename' is defined in Platform, and that's
|
222
|
+
# just as Deb/Ubuntu specific. All of the accessors in the top-level Platform
|
223
|
+
# namespace should be refactored, but #dist will live here for now.
|
224
|
+
# @return [String] the %dist name that RPM will use to build new RPMs
|
225
|
+
def dist
|
226
|
+
@dist ||= @os_name.tr('-', '_') + @os_version
|
227
|
+
end
|
228
|
+
|
219
229
|
# Sets and gets the name of the operating system for the platform.
|
220
230
|
# Also has the side effect of setting the @os_name instance attribute
|
221
231
|
#
|
data/lib/vanagon/platform/dsl.rb
CHANGED
@@ -132,6 +132,13 @@ class Vanagon
|
|
132
132
|
@platform.cross_compiled = cxx_flag
|
133
133
|
end
|
134
134
|
|
135
|
+
# define an explicit Dist for the platform (most likely used for RPM platforms)
|
136
|
+
#
|
137
|
+
# @param dist_string [String] the value to use for .dist when building RPMs
|
138
|
+
def dist(dist_string)
|
139
|
+
@platform.dist = dist_string
|
140
|
+
end
|
141
|
+
|
135
142
|
# Set the path to rpmbuild for the platform
|
136
143
|
#
|
137
144
|
# @param rpmbuild_cmd [String] Full path to rpmbuild with arguments to be used by default
|
data/lib/vanagon/platform/rpm.rb
CHANGED
@@ -44,7 +44,7 @@ class Vanagon
|
|
44
44
|
defines = %(--define '_topdir $(tempdir)/rpmbuild' )
|
45
45
|
# RPM doesn't allow dashes in the os_name. This was added to
|
46
46
|
# convert cisco-wrlinux to cisco_wrlinux
|
47
|
-
defines << %(--define 'dist .#{
|
47
|
+
defines << %(--define 'dist .#{dist}')
|
48
48
|
end
|
49
49
|
|
50
50
|
def add_repository(definition) # rubocop:disable Metrics/AbcSize
|
data/resources/Makefile.erb
CHANGED
@@ -13,14 +13,14 @@ file-list-before-build:
|
|
13
13
|
<%- if dirnames.empty? -%>
|
14
14
|
touch file-list-before-build
|
15
15
|
<%- else -%>
|
16
|
-
(<%= @platform.find %> -
|
16
|
+
(<%= @platform.find %> -H "<%= dirnames.join('" "') %>" 2>/dev/null || <%= @platform.find %> "<%= dirnames.join('" "') %>" 2>/dev/null) | <%= "xargs -I[] cygpath --mixed --long-name --absolute [] |" if @platform.is_windows? %> <%= @platform.sort %> | uniq > file-list-before-build
|
17
17
|
<%- end -%>
|
18
18
|
|
19
19
|
file-list-after-build: <%= @components.map {|comp| comp.name }.join(" ") %>
|
20
20
|
<%- if dirnames.empty? -%>
|
21
21
|
touch file-list-after-build
|
22
22
|
<%- else -%>
|
23
|
-
(<%= @platform.find %> -
|
23
|
+
(<%= @platform.find %> -H "<%= dirnames.join('" "') %>" 2>/dev/null || <%= @platform.find %> "<%= dirnames.join('" "') %>" 2>/dev/null) | <%= "xargs -I[] cygpath --mixed --long-name --absolute [] |" if @platform.is_windows? %> <%= @platform.sort %> | uniq > file-list-after-build
|
24
24
|
<%- end -%>
|
25
25
|
|
26
26
|
<%= @name %>-<%= @version %>.tar.gz: file-list <%= @cleanup ? 'cleanup-components' : '' %>
|
@@ -142,7 +142,7 @@ install -d %{buildroot}
|
|
142
142
|
|
143
143
|
# Here we turn all dirs in the file-list into %dir entries to avoid duplicate files
|
144
144
|
for entry in `cat %{SOURCE1}`; do
|
145
|
-
if [ -n "$entry" -a -d "$entry" ]; then
|
145
|
+
if [ -n "$entry" -a -d "$entry" -a ! -L "$entry" ]; then
|
146
146
|
PATH=/opt/freeware/bin:$PATH sed -i "s|^\($entry\)\$|%dir \1|g" %{SOURCE1}
|
147
147
|
fi
|
148
148
|
done
|
@@ -587,7 +587,14 @@ end" }
|
|
587
587
|
it 'adds the file to the configfiles list' do
|
588
588
|
comp = Vanagon::Component::DSL.new('install-config-file-test', {}, platform)
|
589
589
|
comp.install_configfile('thing1', 'place/to/put/thing1')
|
590
|
-
expect(comp._component.configfiles).to include(Vanagon::Common::Pathname.configfile('place/to/put/thing1'))
|
590
|
+
expect(comp._component.configfiles).to include(Vanagon::Common::Pathname.configfile('place/to/put/thing1', mode: '0644'))
|
591
|
+
expect(comp._component.files).not_to include(Vanagon::Common::Pathname.file('place/to/put/thing1'))
|
592
|
+
end
|
593
|
+
|
594
|
+
it 'sets owner, group, and mode for the configfiles' do
|
595
|
+
comp = Vanagon::Component::DSL.new('install-config-file-test', {}, platform)
|
596
|
+
comp.install_configfile('thing1', 'place/to/put/thing1', owner: 'bob', group: 'timmy', mode: '0022')
|
597
|
+
expect(comp._component.configfiles).to include(Vanagon::Common::Pathname.configfile('place/to/put/thing1', mode: '0022', group: 'timmy', owner: 'bob'))
|
591
598
|
expect(comp._component.files).not_to include(Vanagon::Common::Pathname.file('place/to/put/thing1'))
|
592
599
|
end
|
593
600
|
end
|
@@ -617,7 +624,7 @@ end" }
|
|
617
624
|
it 'adds the file to the configfiles list' do
|
618
625
|
comp = Vanagon::Component::DSL.new('install-config-file-test', {}, platform)
|
619
626
|
comp.install_configfile('thing1', 'place/to/put/thing1')
|
620
|
-
expect(comp._component.configfiles).to include(Vanagon::Common::Pathname.configfile('place/to/put/thing1.pristine'))
|
627
|
+
expect(comp._component.configfiles).to include(Vanagon::Common::Pathname.configfile('place/to/put/thing1.pristine', mode: '0644'))
|
621
628
|
expect(comp._component.configfiles).not_to include(Vanagon::Common::Pathname.file('place/to/put/thing1'))
|
622
629
|
end
|
623
630
|
end
|
@@ -13,6 +13,9 @@ describe 'Vanagon::Driver' do
|
|
13
13
|
END
|
14
14
|
end
|
15
15
|
|
16
|
+
let(:explicit_workdir){ Dir.mktmpdir }
|
17
|
+
let(:explicit_remote_workdir){ Dir.mktmpdir }
|
18
|
+
|
16
19
|
def eval_platform(name, definition)
|
17
20
|
plat = Vanagon::Platform::DSL.new(name)
|
18
21
|
plat.instance_eval(definition)
|
@@ -27,6 +30,22 @@ describe 'Vanagon::Driver' do
|
|
27
30
|
end
|
28
31
|
|
29
32
|
describe 'when resolving build host info' do
|
33
|
+
it 'uses an expicitly specified workdir if provided' do
|
34
|
+
derived = create_driver(redhat)
|
35
|
+
explicit = create_driver(redhat, workdir: explicit_workdir)
|
36
|
+
|
37
|
+
expect(explicit.workdir).to eq(explicit_workdir)
|
38
|
+
expect(explicit.workdir).not_to eq(derived.workdir)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'uses an expicitly specified remote workdir if provided' do
|
42
|
+
derived = create_driver(redhat)
|
43
|
+
explicit = create_driver(redhat, remote_workdir: explicit_remote_workdir)
|
44
|
+
|
45
|
+
expect(explicit.remote_workdir).to eq(explicit_remote_workdir)
|
46
|
+
expect(explicit.remote_workdir).not_to eq(derived.remote_workdir)
|
47
|
+
end
|
48
|
+
|
30
49
|
it 'returns the vmpooler_template using the pooler engine' do
|
31
50
|
info = create_driver(redhat).build_host_info
|
32
51
|
|
@@ -1,43 +1,35 @@
|
|
1
1
|
require 'vanagon/platform'
|
2
2
|
|
3
|
-
describe
|
4
|
-
platforms =[
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
:architecture => "i386",
|
10
|
-
:block => %Q[ platform "el-5-i386" do |plat| end ]
|
11
|
-
},
|
12
|
-
{
|
13
|
-
:name => "fedora-21-x86_64",
|
14
|
-
:os_name => "fedora",
|
15
|
-
:os_version => "21",
|
16
|
-
:architecture => "x86_64",
|
17
|
-
:block => %Q[ platform "fedora-21-x86_64" do |plat| end ]
|
18
|
-
},
|
19
|
-
{
|
20
|
-
:name => "cisco-wrlinux-7-x86_64",
|
21
|
-
:os_name => "fedora",
|
22
|
-
:os_version => "21",
|
23
|
-
:architecture => "x86_64",
|
24
|
-
:block => %Q[ platform "cisco-wrlinux-7-x86_64" do |plat| end ]
|
25
|
-
},
|
26
|
-
]
|
3
|
+
describe 'Vanagon::Platform::RPM' do
|
4
|
+
platforms = [
|
5
|
+
{ name: 'el-5-i386' },
|
6
|
+
{ name: 'fedora-21-x86_64', dist: 'f21' },
|
7
|
+
{ name: 'cisco-wrlinux-7-x86_64' }
|
8
|
+
]
|
27
9
|
|
28
|
-
platforms.each do |
|
29
|
-
context "
|
30
|
-
|
31
|
-
|
10
|
+
platforms.each do |platform|
|
11
|
+
context "defines RPM-based platform attributes for #{platform[:name]}" do
|
12
|
+
subject {
|
13
|
+
plat = Vanagon::Platform::DSL.new(platform[:name])
|
14
|
+
plat.instance_eval(%(platform("#{platform[:name]}") { |plat| }))
|
15
|
+
plat._platform.dist = platform[:dist]
|
16
|
+
plat._platform
|
17
|
+
}
|
32
18
|
|
33
|
-
|
34
|
-
|
35
|
-
|
19
|
+
let(:derived_dist) { subject.os_name.tr('-', '_') + subject.os_version }
|
20
|
+
let(:dist) { platform[:dist] || derived_dist }
|
21
|
+
let(:defined_dist) { "--define 'dist .#{dist}'" }
|
36
22
|
|
37
23
|
describe '#rpm_defines' do
|
38
|
-
it "
|
39
|
-
|
40
|
-
|
24
|
+
it "includes the expected 'dist' defines" do
|
25
|
+
expect(subject.rpm_defines).to include(defined_dist)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#dist" do
|
30
|
+
it "uses explicit values when available" do
|
31
|
+
expect(subject.dist).to eq(derived_dist) unless platform[:dist]
|
32
|
+
expect(subject.dist).to eq(dist)
|
41
33
|
end
|
42
34
|
end
|
43
35
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
+
require 'tmpdir'
|
1
2
|
require 'vanagon/platform'
|
2
3
|
require 'vanagon/project'
|
3
4
|
require 'vanagon/common'
|
4
5
|
|
5
|
-
|
6
6
|
# These constants are defined for the purpose of the project/generic file merge tests
|
7
7
|
# to point these directories to test areas under the /tmp directory.
|
8
8
|
# This allows individual test cases to be specified accurately.
|
@@ -10,7 +10,7 @@ require 'vanagon/common'
|
|
10
10
|
# data structures are not available under the test conditions causing failures in the
|
11
11
|
# ERB template translation
|
12
12
|
|
13
|
-
WORK_BASE =
|
13
|
+
WORK_BASE = Dir.mktmpdir
|
14
14
|
VANAGON_ROOT = "#{WORK_BASE}/generic"
|
15
15
|
PROJ_ROOT = "#{WORK_BASE}/project"
|
16
16
|
WORKDIR = "#{WORK_BASE}/workdir"
|
@@ -36,14 +36,14 @@ describe "Vanagon::Platform::Windows" do
|
|
36
36
|
let(:platform) { plat }
|
37
37
|
let(:cur_plat) { Vanagon::Platform::DSL.new(plat[:name]) }
|
38
38
|
let (:project_block) {
|
39
|
-
<<-HERE
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
HERE
|
39
|
+
<<-HERE.undent
|
40
|
+
project 'test-fixture' do |proj|
|
41
|
+
proj.setting(:company_name, "Test Name")
|
42
|
+
proj.setting(:company_id, "TestID")
|
43
|
+
proj.setting(:product_id, "TestProduct")
|
44
|
+
proj.setting(:base_dir, "ProgramFilesFolder")
|
45
|
+
end
|
46
|
+
HERE
|
47
47
|
}
|
48
48
|
|
49
49
|
before do
|
@@ -180,13 +180,14 @@ HERE
|
|
180
180
|
cur_plat.instance_eval(plat[:block])
|
181
181
|
comp = Vanagon::Component::DSL.new('service-test', {}, cur_plat._platform)
|
182
182
|
comp.install_service('SourceDir/ProgramFilesFolder/TestID/TestProduct/opt/bin.exe')
|
183
|
-
expect(cur_plat._platform.generate_service_bin_dirs([comp._component.service].flatten.compact, proj._project))
|
184
|
-
|
185
|
-
|
186
|
-
<Directory Id="
|
187
|
-
|
188
|
-
|
189
|
-
|
183
|
+
expect(cur_plat._platform.generate_service_bin_dirs([comp._component.service].flatten.compact, proj._project))
|
184
|
+
.to eq(
|
185
|
+
<<-HERE.undent
|
186
|
+
<Directory Name="opt" Id="opt_0_0">
|
187
|
+
<Directory Id="SERVICETESTBINDIR" />
|
188
|
+
</Directory>
|
189
|
+
HERE
|
190
|
+
)
|
190
191
|
end
|
191
192
|
|
192
193
|
it "returns one directory with non-default name" do
|
@@ -195,14 +196,14 @@ HERE
|
|
195
196
|
cur_plat.instance_eval(plat[:block])
|
196
197
|
comp = Vanagon::Component::DSL.new('service-test', {}, cur_plat._platform)
|
197
198
|
comp.install_service('SourceDir/ProgramFilesFolder/TestID/TestProduct/opt/bin.exe', nil, "service-test-2")
|
198
|
-
expect(cur_plat._platform.generate_service_bin_dirs([comp._component.service].flatten.compact, proj._project))
|
199
|
-
|
200
|
-
<<-HERE
|
201
|
-
<Directory Name="opt" Id="opt_0_0">
|
202
|
-
<Directory Id="SERVICETEST2BINDIR" />
|
203
|
-
</Directory>
|
204
|
-
HERE
|
205
|
-
|
199
|
+
expect(cur_plat._platform.generate_service_bin_dirs([comp._component.service].flatten.compact, proj._project))
|
200
|
+
.to eq(
|
201
|
+
<<-HERE.undent
|
202
|
+
<Directory Name="opt" Id="opt_0_0">
|
203
|
+
<Directory Id="SERVICETEST2BINDIR" />
|
204
|
+
</Directory>
|
205
|
+
HERE
|
206
|
+
)
|
206
207
|
end
|
207
208
|
|
208
209
|
it "returns nested directory correctly with \\" do
|
@@ -211,16 +212,16 @@ HERE
|
|
211
212
|
cur_plat.instance_eval(plat[:block])
|
212
213
|
comp = Vanagon::Component::DSL.new('service-test', {}, cur_plat._platform)
|
213
214
|
comp.install_service('SourceDir\\ProgramFilesFolder\\TestID\\TestProduct\\somedir\\someotherdir\\bin.exe')
|
214
|
-
expect(cur_plat._platform.generate_service_bin_dirs([comp._component.service].flatten.compact, proj._project))
|
215
|
-
|
216
|
-
<<-HERE
|
217
|
-
<Directory Name="somedir" Id="somedir_0_0">
|
218
|
-
<Directory Name="someotherdir" Id="someotherdir_0_1">
|
219
|
-
<Directory Id="SERVICETESTBINDIR" />
|
220
|
-
</Directory>
|
221
|
-
</Directory>
|
222
|
-
HERE
|
223
|
-
|
215
|
+
expect(cur_plat._platform.generate_service_bin_dirs([comp._component.service].flatten.compact, proj._project))
|
216
|
+
.to eq(
|
217
|
+
<<-HERE.undent
|
218
|
+
<Directory Name="somedir" Id="somedir_0_0">
|
219
|
+
<Directory Name="someotherdir" Id="someotherdir_0_1">
|
220
|
+
<Directory Id="SERVICETESTBINDIR" />
|
221
|
+
</Directory>
|
222
|
+
</Directory>
|
223
|
+
HERE
|
224
|
+
)
|
224
225
|
end
|
225
226
|
|
226
227
|
|
@@ -233,14 +234,15 @@ HERE
|
|
233
234
|
comp.install_service('SourceDir\\ProgramFilesFolder\\TestID\\TestProduct\\somedir\\bin.exe')
|
234
235
|
comp2 = Vanagon::Component::DSL.new('service-test-2', {}, cur_plat._platform)
|
235
236
|
comp2.install_service('SourceDir\\ProgramFilesFolder\\TestID\\TestProduct\\somedir\\bin.exe')
|
236
|
-
expect(cur_plat._platform.generate_service_bin_dirs([comp._component.service, comp2._component.service].flatten.compact, proj._project))
|
237
|
-
|
238
|
-
|
239
|
-
<Directory Id="
|
240
|
-
<Directory Id="
|
241
|
-
|
242
|
-
|
243
|
-
|
237
|
+
expect(cur_plat._platform.generate_service_bin_dirs([comp._component.service, comp2._component.service].flatten.compact, proj._project))
|
238
|
+
.to eq(
|
239
|
+
<<-HERE.undent
|
240
|
+
<Directory Name="somedir" Id="somedir_0_0">
|
241
|
+
<Directory Id="SERVICETESTBINDIR" />
|
242
|
+
<Directory Id="SERVICETEST2BINDIR" />
|
243
|
+
</Directory>
|
244
|
+
HERE
|
245
|
+
)
|
244
246
|
end
|
245
247
|
|
246
248
|
it "returns correctly formatted multiple nested directories" do
|
@@ -253,25 +255,26 @@ HERE
|
|
253
255
|
comp2.install_service('SourceDir\\ProgramFilesFolder\\TestID\\TestProduct\\somedir\\oneUpAgain\\twoUp\\bin.exe')
|
254
256
|
comp3 = Vanagon::Component::DSL.new('service-test-3', {}, cur_plat._platform)
|
255
257
|
comp3.install_service('SourceDir\\ProgramFilesFolder\\TestID\\TestProduct\\somedir\\oneUpAgain\\twoUpAgain\\bin.exe')
|
256
|
-
expect(cur_plat._platform.generate_service_bin_dirs([comp._component.service, comp2._component.service, comp3._component.service].flatten.compact, proj._project))
|
257
|
-
|
258
|
-
|
259
|
-
<Directory Name="
|
260
|
-
<Directory Name="
|
261
|
-
<Directory Id="
|
262
|
-
|
263
|
-
</Directory>
|
264
|
-
|
265
|
-
<Directory Name="
|
266
|
-
<Directory Id="
|
267
|
-
|
268
|
-
|
269
|
-
<Directory Id="
|
270
|
-
|
271
|
-
</Directory>
|
272
|
-
</Directory>
|
273
|
-
|
274
|
-
|
258
|
+
expect(cur_plat._platform.generate_service_bin_dirs([comp._component.service, comp2._component.service, comp3._component.service].flatten.compact, proj._project))
|
259
|
+
.to eq(
|
260
|
+
<<-HERE.undent
|
261
|
+
<Directory Name="somedir" Id="somedir_0_0">
|
262
|
+
<Directory Name="oneUp" Id="oneUp_0_1">
|
263
|
+
<Directory Name="twoUp" Id="twoUp_0_2">
|
264
|
+
<Directory Id="SERVICETEST1BINDIR" />
|
265
|
+
</Directory>
|
266
|
+
</Directory>
|
267
|
+
<Directory Name="oneUpAgain" Id="oneUpAgain_1_1">
|
268
|
+
<Directory Name="twoUp" Id="twoUp_1_2">
|
269
|
+
<Directory Id="SERVICETEST2BINDIR" />
|
270
|
+
</Directory>
|
271
|
+
<Directory Name="twoUpAgain" Id="twoUpAgain_2_2">
|
272
|
+
<Directory Id="SERVICETEST3BINDIR" />
|
273
|
+
</Directory>
|
274
|
+
</Directory>
|
275
|
+
</Directory>
|
276
|
+
HERE
|
277
|
+
)
|
275
278
|
end
|
276
279
|
end
|
277
280
|
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.9.
|
4
|
+
version: 0.9.3
|
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-01
|
11
|
+
date: 2017-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|