vanagon 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -4
  3. data/lib/vanagon/component.rb +1 -1
  4. data/lib/vanagon/component/dsl.rb +7 -3
  5. data/lib/vanagon/component/source/http.rb +1 -1
  6. data/lib/vanagon/engine/local.rb +15 -20
  7. data/lib/vanagon/optparse.rb +1 -1
  8. data/lib/vanagon/platform/windows.rb +88 -17
  9. data/lib/vanagon/utilities.rb +25 -6
  10. data/resources/rpm/project.spec.erb +19 -18
  11. data/resources/windows/nuget/chocolateyInstall.ps1 +9 -1
  12. data/resources/windows/wix/componentrefs.wxs.erb +11 -0
  13. data/resources/windows/wix/filter.xslt.erb +23 -0
  14. data/resources/windows/wix/project.wxs.erb +34 -0
  15. data/resources/windows/wix/registryEntries.wxs.erb +18 -0
  16. data/spec/{fixures → fixtures}/component/invalid-test-fixture.json +0 -0
  17. data/spec/{fixures → fixtures}/component/mcollective.service +0 -0
  18. data/spec/{fixures → fixtures}/component/test-fixture.json +0 -0
  19. data/spec/fixtures/wix/resources/windows/wix/file-1.wxs +1 -0
  20. data/spec/fixtures/wix/resources/windows/wix/file-2.wxs +1 -0
  21. data/spec/fixtures/wix/resources/windows/wix/file-3.wxs.erb +1 -0
  22. data/spec/fixtures/wix/resources/windows/wix/file-4.wxs.erb +1 -0
  23. data/spec/fixtures/wix/resources/windows/wix/include/include-sample-1.wxs +1 -0
  24. data/spec/fixtures/wix/resources/windows/wix/project.filter.xslt.erb +1 -0
  25. data/spec/fixtures/wix/resources/windows/wix/project.wxs +2 -0
  26. data/spec/fixtures/wix/resources/windows/wix/ui/bitmaps/bitmap.bmp +0 -0
  27. data/spec/fixtures/wix/resources/windows/wix/ui/ui-sample-1.wxs +1 -0
  28. data/spec/lib/vanagon/component/dsl_spec.rb +3 -3
  29. data/spec/lib/vanagon/engine/hardware_spec.rb +5 -1
  30. data/spec/lib/vanagon/engine/local_spec.rb +27 -0
  31. data/spec/lib/vanagon/platform/windows_spec.rb +123 -0
  32. data/spec/lib/vanagon/utilities_spec.rb +11 -0
  33. data/spec/spec_helper.rb +6 -0
  34. metadata +21 -6
  35. data/resources/windows/wix/service.component.wxs.erb +0 -55
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6faf9b7a2f17d4a0d10d3e9a050d066ba92ab7a0
4
- data.tar.gz: 112f2f90afafb386461ec92ed67238fefddcf76d
3
+ metadata.gz: 8a3414d151dd4f8f7162a06b6dfe3a5dc8c9b066
4
+ data.tar.gz: 944acf2e2cfa169c60f3072d05a5add5c03ac25c
5
5
  SHA512:
6
- metadata.gz: 8edf1722f845927b0ba7858b077bd3c57908f7395beee779aa068552ea7c5e46d7a827416b201b275fb90c947438162f1a0f42004a85662b1716a8e9f264161f
7
- data.tar.gz: 85a5e28c1954033d3120d3e4ee72582f413982762ba430d3e1ebaa0e38127cfb994d3edfdaf921392a76fd7737ff5a6176469b006ff0a63905da653ed37a2607
6
+ metadata.gz: d88e78e71ccdd7f878141dc0b26d741bbef71b9f9c21e8cc8f766bf241bc8c317c6090e9781508f812d17dddc46e8af42f39d38274618934d4871de498eecf45
7
+ data.tar.gz: 0152bcaa044f2c8f939a7c8bb4434801d023397d7d156692f6648a55bceca6958a3182577fd6b4492999712cb07ce7eaef017e7c7150cf2205153ddd318750e7
data/README.md CHANGED
@@ -30,10 +30,10 @@ components, then rebuild the project and test the installed artifacts.
30
30
 
31
31
  Runtime Requirements
32
32
  ---
33
- Vanagon is self-contained. A recent version of ruby should be all that is
34
- required. Beyond that, ssh, rsync and git are also required on the host, and
35
- ssh-server and rsync is required on the target (package installation for the
36
- target can be customized in the platform config for the target).
33
+ Vanagon is self-contained. A recent version of ruby (2.1 or greater) should be
34
+ all that is required. Beyond that, ssh, rsync and git are also required on the
35
+ host, and ssh-server and rsync is required on the target (package installation
36
+ for the target can be customized in the platform config for the target).
37
37
 
38
38
  Configuration and Usage
39
39
  ---
@@ -12,7 +12,7 @@ class Vanagon
12
12
  attr_accessor :settings, :platform, :patches, :requires, :service, :options
13
13
  attr_accessor :directories, :replaces, :provides, :cleanup_source
14
14
  attr_accessor :sources, :preinstall_actions, :postinstall_actions
15
- attr_accessor :preremove_actions, :postremove_actions
15
+ attr_accessor :preremove_actions, :postremove_actions, :license
16
16
 
17
17
  # Loads a given component from the configdir
18
18
  #
@@ -158,8 +158,7 @@ class Vanagon
158
158
  # @param default_file [String] path to the default file relative to the source
159
159
  # @param service_name [String] name of the service
160
160
  # @param service_type [String] type of the service (network, application, system, etc)
161
- # @param service_hash [Hash] hash of options to parse for the service
162
- def install_service(service_file, default_file = nil, service_name = @component.name, service_type: nil, service_hash: nil)
161
+ def install_service(service_file, default_file = nil, service_name = @component.name, service_type: nil)
163
162
  case @component.platform.servicetype
164
163
  when "sysv"
165
164
  target_service_file = File.join(@component.platform.servicedir, service_name)
@@ -185,7 +184,8 @@ class Vanagon
185
184
  # Return here because there is no file to install, just a string read in
186
185
  return
187
186
  when "windows"
188
- @component.service = OpenStruct.new(name: service_name, options: service_hash)
187
+ @component.service = OpenStruct.new(:id => "#{service_name.gsub(/[^A-Za-z0-9]/, '').upcase}", :service_file => service_file)
188
+ # return here as we are just collecting the name of the service file to put into the harvest filter list.
189
189
  return
190
190
  else
191
191
  fail "Don't know how to install the #{@component.platform.servicetype}. Please teach #install_service how to do this."
@@ -387,6 +387,10 @@ class Vanagon
387
387
  end
388
388
  @component.postremove_actions << OpenStruct.new(:pkg_state => pkg_state, :scripts => scripts)
389
389
  end
390
+
391
+ def license(license)
392
+ @component.license = license
393
+ end
390
394
  end
391
395
  end
392
396
  end
@@ -101,7 +101,7 @@ class Vanagon
101
101
  when ".tar.gz", ".tgz"
102
102
  return "gunzip -c '#{@file}' | '#{tar}' xf -"
103
103
  when ".zip"
104
- return "unzip '#{@file}'"
104
+ return "unzip '#{@file}' || 7za x -r -tzip -o'#{File.basename(@file, ".zip")}' '#{@file}'"
105
105
  end
106
106
  else
107
107
  # Extension does not appear to be an archive
@@ -1,40 +1,35 @@
1
+ require 'vanagon/engine/base'
1
2
  require 'vanagon/utilities'
2
3
  require 'vanagon/errors'
3
- require 'benchmark'
4
4
 
5
5
  class Vanagon
6
6
  class Engine
7
- class Local
8
- attr_accessor :target
7
+ class Local < Base
9
8
 
10
9
  def initialize(platform, target = nil)
11
- @platform = platform
12
- @target = "local machine"
10
+ @target = target || "local machine"
13
11
  @name = 'local'
14
- end
12
+ super
15
13
 
16
- # Dispatches the command for execution
17
- def dispatch(command)
18
- puts Benchmark.measure { local_command(command, @workdir) }
14
+ # We inherit a set of required attributes from Base,
15
+ # and rather than instantiate a new empty array for
16
+ # required attributes, we can just clear out the
17
+ # existing ones.
18
+ @required_attributes.clear
19
19
  end
20
20
 
21
- # Steps needed to tear down or clean up the system after the build is
22
- # complete
23
- def teardown
24
- end
25
-
26
- # This method will take care of validation and target selection all at
27
- # once as an easy shorthand to call from the driver
28
- def startup(workdir)
29
- @workdir = workdir
30
- script = @platform.provisioning.join(' && ')
31
- dispatch(script)
21
+ # Dispatches the command for execution
22
+ def dispatch(command, return_output = false)
23
+ Vanagon::Utilities.local_command(command, return_command_output: return_output)
32
24
  end
33
25
 
34
26
  def ship_workdir(workdir)
27
+ FileUtils.cp_r(Dir.glob("#{workdir}/*"), "#{@remote_workdir}")
35
28
  end
36
29
 
37
30
  def retrieve_built_artifact
31
+ FileUtils.mkdir_p("output")
32
+ FileUtils.cp_r(Dir.glob("#{@remote_workdir}/output/*"), "output/")
38
33
  end
39
34
  end
40
35
  end
@@ -8,7 +8,7 @@ class Vanagon
8
8
  :configdir => ['-c', '--configdir DIR', 'Configs dir (defaults to $pwd/configs)'],
9
9
  :target => ['-t HOST', '--target HOST', 'Configure a target machine for build and packaging (defaults to grabbing one from the pooler)'],
10
10
  :engine => ['-e ENGINE', '--engine ENGINE', "A custom engine to use (defaults to the pooler) [base, local, docker, pooler currently supported]"],
11
- :skipcheck => ['--skipcheck', 'Ship the `check` stage when building components'],
11
+ :skipcheck => ['--skipcheck', 'Skip the `check` stage when building components'],
12
12
  :preserve => ['-p', '--preserve', 'Whether to tear down the VM on success or not (defaults to false)'],
13
13
  :verbose => ['-v', '--verbose', 'Verbose output (does nothing)'],
14
14
  }
@@ -53,8 +53,68 @@ class Vanagon
53
53
  # @param name [String] name of the project
54
54
  # @param binding [Binding] binding to use in evaluating the packaging templates
55
55
  def generate_msi_packaging_artifacts(workdir, name, binding)
56
- FileUtils.mkdir_p(File.join(workdir, "wix"))
57
- erb_file(File.join(VANAGON_ROOT, "resources/windows/wix/service.component.wxs.erb"), File.join(workdir, "wix", "service.#{name}.wxs"), false, { :binding => binding })
56
+ # Copy the project specific files first
57
+ copy_from_project("./resources/windows/wix", workdir)
58
+ merge_defaults_from_vanagon(File.join(VANAGON_ROOT, "resources/windows/wix"), "#{workdir}/wix")
59
+ process_templates("#{workdir}/wix", binding)
60
+ end
61
+
62
+ # Method to recursively copy from a source project resource directory
63
+ # to a destination (wix) work directory.
64
+ # strongly suspect the original cp_r command would have done all of this.
65
+ #
66
+ # @param proj_resources [String] Project Resource File directory
67
+ # @param destination [String] Destination directory
68
+ # @param verbose [String] True or false
69
+ def copy_from_project(proj_resources, destination, verbose: false)
70
+ FileUtils.cp_r(proj_resources, destination, :verbose => verbose)
71
+ end
72
+
73
+ # Method to merge in the files from the Vanagon (generic) directories.
74
+ # Project Specific files take precedence, so since these are copied prior
75
+ # to this function, then this merge operation will ignore existing files
76
+ #
77
+ # @param vanagon_root [String] Vanagon wix resources directory
78
+ # @param destination [String] Destination directory
79
+ # @param verbose [String] True or false
80
+ def merge_defaults_from_vanagon(vanagon_root, destination, verbose: false)
81
+ # Will use this Pathname object for relative path calculations in loop below.
82
+ vanagon_path = Pathname.new(vanagon_root)
83
+ files = Dir.glob(File.join(vanagon_root, "**/*.*"))
84
+ files.each do |file|
85
+ # Get Pathname for incoming file using Pathname library
86
+ src_pathname = Pathname.new(file).dirname
87
+ # This Pathname method allows us to effectively "subtract" the leading vanagon_path
88
+ # from the source filename path. This gives us a pathname fragment that we can
89
+ # then append to the target directory, preserving the files place in the directory
90
+ # tree relative to the parent.
91
+ # See following article for example:
92
+ # http://stackoverflow.com/questions/12093770/ruby-removing-parts-a-file-path
93
+ # and http://ruby-doc.org/stdlib-2.1.0/libdoc/pathname/rdoc/Pathname.html#method-i-relative_path_from
94
+ dest_pathname_fragment = src_pathname.relative_path_from(vanagon_path)
95
+ target_dir = File.join(destination, dest_pathname_fragment.to_s)
96
+ # Create the target directory if necessary.
97
+ FileUtils.mkdir_p(target_dir) unless File.exists?(target_dir)
98
+ # Skip the file copy if either target file or ERB equivalent exists.
99
+ # This means that any files already in place in the work directory as a
100
+ # result of being copied from the project specific area will not be
101
+ # overritten.
102
+ next if File.exists?(Pathname.new(target_dir) + File.basename(file))
103
+ next if File.exists?(Pathname.new(target_dir) + File.basename(file, ".erb"))
104
+ FileUtils.cp(file, target_dir, :verbose => verbose)
105
+ end
106
+ end
107
+
108
+ # Method to transform ERB templates in the work directory.
109
+ #
110
+ # @param workdir [String] working directory to stage the evaluated templates in
111
+ # @param binding [Binding] binding to use in evaluating the packaging templates
112
+ def process_templates(wixworkdir, binding)
113
+ files = Dir.glob(File.join(wixworkdir, "**/*.erb"))
114
+ files.each do |file|
115
+ erb_file(file, File.join(File.dirname(file), File.basename(file, ".erb")), false, { :binding => binding })
116
+ FileUtils.rm(file)
117
+ end
58
118
  end
59
119
 
60
120
  # Method to generate the files required to build a nuget package for the project
@@ -103,23 +163,34 @@ class Vanagon
103
163
  # @return [Array] list of commands required to build an msi package for the given project from a tarball
104
164
  def generate_msi_package(project)
105
165
  target_dir = project.repo ? output_dir(project.repo) : output_dir
106
- cg_name = "compfiles"
107
- dir_ref = "INSTALLDIR"
166
+ cg_name = "ProductComponentGroup"
167
+ wix_extensions = "-ext WiXUtilExtension -ext WixUIExtension"
168
+ candle_flags = "-dPlatform=#{@architecture} -arch #{@architecture} #{wix_extensions}"
169
+ # Enable verbose mode for the moment (will be removed for production)
170
+ # localisation flags to be added
171
+ light_flags = "-v -cultures:en-us #{wix_extensions}"
108
172
  # Actual array of commands to be written to the Makefile
109
173
  ["mkdir -p output/#{target_dir}",
110
- "mkdir -p $(tempdir)/staging",
111
- "gunzip -c #{project.name}-#{project.version}.tar.gz | '#{@tar}' -C '$(tempdir)/staging' --strip-components 1 -xf -",
112
- # Run the Heat command in a single pass
113
- # Heat command documentation at: http://wixtoolset.org/documentation/manual/v3/overview/heat.html
114
- # dir <directory> - Traverse directory to find all sub-files and directories.
115
- # -ke - Keep Empty directories
116
- # -cg - Component Group Name
117
- # -gg - Generate GUIDS now
118
- # -dr - Directory reference to root directories (cannot contains spaces e.g. -dr MyAppDirRef)
119
- # -sreg - Suppress registry harvesting.
120
- # -var <variable> - Substitute File/@Source="SourceDir" with a preprocessor or a wix variable
121
- "cd $(tempdir); \"$$WIX/bin/heat.exe\" dir staging -v -ke -indent 2 -cg #{cg_name} -gg -dr #{dir_ref} -sreg -var var.StageDir -out wix/#{project.name}-harvest.wxs",
122
- ]
174
+ "mkdir -p $(tempdir)/{SourceDir,wix/wixobj}",
175
+ "#{@copy} -r wix/* $(tempdir)/wix/",
176
+ "gunzip -c #{project.name}-#{project.version}.tar.gz | '#{@tar}' -C '$(tempdir)/SourceDir' --strip-components 1 -xf -",
177
+ # Run the Heat command in a single pass
178
+ # Heat command documentation at: http://wixtoolset.org/documentation/manual/v3/overview/heat.html
179
+ # dir <directory> - Traverse directory to find all sub-files and directories.
180
+ # -ke - Keep Empty directories
181
+ # -cg - Component Group Name
182
+ # -gg - Generate GUIDS now
183
+ # -srd - Suppress root element generation, we want to reference the default root element
184
+ # TARGETDIR in the project.wxs file, not a newly generated one.
185
+ # -sreg - Suppress registry harvesting.
186
+ "cd $(tempdir); \"$$WIX/bin/heat.exe\" dir SourceDir -v -ke -indent 2 -cg #{cg_name} -gg -srd -t wix/filter.xslt -sreg -out wix/#{project.name}-harvest.wxs",
187
+ # Apply Candle command to all *.wxs files - generates .wixobj files in wix directory.
188
+ # cygpath conversion is necessary as candle is unable to handle posix path specs
189
+ "cd $(tempdir)/wix/wixobj; for wix_file in `find $(tempdir)/wix -name \'*.wxs\'`; do \"$$WIX/bin/candle.exe\" #{candle_flags} $$(cygpath -aw $$wix_file) || exit 1; done",
190
+ # run all wix objects through light to produce the msi
191
+ # the -b flag simply points light to where the SourceDir location is
192
+ "cd $(tempdir)/wix/wixobj; \"$$WIX/bin/light.exe\" #{light_flags} -b $$(cygpath -aw $(tempdir)) -out $$(cygpath -aw $(workdir)/output/#{target_dir}/#{msi_package_name(project)}) *.wixobj",
193
+ ]
123
194
  end
124
195
 
125
196
  # Method to derive the msi (Windows Installer) package name for the project.
@@ -266,14 +266,33 @@ class Vanagon
266
266
 
267
267
  # Runs the command on the local host
268
268
  #
269
- # @param command [String] command to run on the target
270
- # @return [true] Returns true if the command was successful
269
+ # @param command [String] command to run locally
270
+ # @param return_command_output [Boolean] whether or not command output should be returned
271
+ # @return [true, String] Returns true if the command was successful or the
272
+ # output of the command if return_command_output is true
271
273
  # @raise [RuntimeError] If the command fails an exception is raised
272
- def local_command(command, workdir)
273
- puts "Executing '#{command}' locally in #{workdir}"
274
- Kernel.system(command, :chdir => workdir)
275
- $?.success? or raise "Local command (#{command}) failed."
274
+ def local_command(command, return_command_output: false)
275
+ clean_environment do
276
+ puts "Executing '#{command}' locally"
277
+ if return_command_output
278
+ ret = %x(#{command}).chomp
279
+ if $?.success?
280
+ return ret
281
+ else
282
+ raise "Local command (#{command}) failed."
283
+ end
284
+ else
285
+ Kernel.system(command)
286
+ $?.success? or raise "Local command (#{command}) failed."
287
+ end
288
+ end
289
+ end
290
+
291
+ def clean_environment(&block)
292
+ return Bundler.with_clean_env { yield } if defined?(Bundler)
293
+ yield
276
294
  end
295
+ private :clean_environment
277
296
 
278
297
  # Helper method that takes a template file and runs it through ERB
279
298
  #
@@ -118,10 +118,10 @@ done
118
118
  %pre
119
119
  # Save state so we know later if this is an upgrade or an install
120
120
  mkdir -p %{_localstatedir}/lib/rpm-state/%{name}
121
- if [ $1 -eq 1 ] ; then
121
+ if [ "$1" -eq 1 ] ; then
122
122
  touch %{_localstatedir}/lib/rpm-state/%{name}/install
123
123
  fi
124
- if [ $1 -eq 2 ] ; then
124
+ if [ "$1" -gt 1 ] ; then
125
125
  touch %{_localstatedir}/lib/rpm-state/%{name}/upgrade
126
126
  fi
127
127
 
@@ -132,12 +132,12 @@ fi
132
132
  <%- end -%>
133
133
 
134
134
  # Run preinstall scripts on install if defined
135
- if [ $1 -eq 1 ] ; then
135
+ if [ "$1" -eq 1 ] ; then
136
136
  <%= get_preinstall_actions("install") %>
137
137
  fi
138
138
 
139
139
  # Run preinstall scripts on upgrade if defined
140
- if [ $1 -eq 2 ] ; then
140
+ if [ "$1" -gt 1 ] ; then
141
141
  <%= get_preinstall_actions("upgrade") %>
142
142
  fi
143
143
 
@@ -146,14 +146,9 @@ fi
146
146
  <%- if @platform.is_aix? || (@platform.is_el? && @platform.os_version.to_i == 4) -%>
147
147
  ## EL-4 and AIX RPM don't have %posttrans, so we'll put them here
148
148
  # Run postinstall scripts on install if defined
149
- if [ $1 -eq 1 ] ; then
149
+ if [ "$1" -eq 1 ] ; then
150
150
  <%= get_postinstall_actions("install") %>
151
151
  fi
152
-
153
- # Run postinstall scripts on upgrade if defined
154
- if [ $1 -eq 2 ] ; then
155
- <%= get_postinstall_actions("upgrade") %>
156
- fi
157
152
  <%- end -%>
158
153
  <%- get_services.each do |service| -%>
159
154
  # switch based on systemd vs systemv vs smf vs aix
@@ -178,12 +173,12 @@ fi
178
173
 
179
174
  %postun
180
175
  # Run post-uninstall scripts on upgrade if defined
181
- if [ $1 -eq 1 ] ; then
176
+ if [ "$1" -eq 1 ] ; then
182
177
  <%= get_postremove_actions("upgrade") %>
183
178
  fi
184
179
 
185
180
  # Run post-uninstall scripts on removal if defined
186
- if [ $1 -eq 0 ] ; then
181
+ if [ "$1" -eq 0 ] ; then
187
182
  <%= get_postremove_actions("removal") %>
188
183
  fi
189
184
 
@@ -197,26 +192,30 @@ fi
197
192
  %systemd_postun_with_restart <%= service.name %>.service
198
193
  <%- end -%>
199
194
  <%- elsif @platform.servicetype == "sysv" -%>
200
- if [ $1 -ge 1 ]; then
195
+ if [ "$1" -eq 1 ]; then
201
196
  /sbin/service <%= service.name %> condrestart || :
202
197
  fi
203
198
  <%- elsif @platform.servicetype == "aix" -%>
204
- if [ $1 -eq 0 ]; then
199
+ if [ "$1" -eq 0 ]; then
205
200
  /usr/bin/rmssys -s <%= service.name -%> > /dev/null 2>&1 || :
206
201
  /usr/sbin/rmitab <%= service.name -%> > /dev/null 2>&1 || :
207
202
  fi
203
+ # Run postinstall scripts on upgrade if defined
204
+ if [ "$1" -eq 1 ] ; then
205
+ <%= get_postinstall_actions("upgrade") %>
206
+ fi
208
207
  <%- end -%>
209
208
  <%- end -%>
210
209
 
211
210
 
212
211
  %preun
213
212
  # Run pre-uninstall scripts on upgrade if defined
214
- if [ $1 -eq 1 ] ; then
213
+ if [ "$1" -eq 1 ] ; then
215
214
  <%= get_preremove_actions("upgrade") %>
216
215
  fi
217
216
 
218
217
  # Run pre-uninstall scripts on removal if defined
219
- if [ $1 -eq 0 ] ; then
218
+ if [ "$1" -eq 0 ] ; then
220
219
  <%= get_preremove_actions("removal") %>
221
220
  fi
222
221
 
@@ -228,12 +227,14 @@ fi
228
227
  %systemd_preun <%= service.name %>.service
229
228
  <%- end -%>
230
229
  <%- elsif @platform.servicetype == "sysv" -%>
231
- if [ $1 = 0 ]; then
230
+ if [ "$1" -eq 0 ]; then
232
231
  /sbin/service <%= service.name %> stop >/dev/null 2>&1 || :
233
232
  chkconfig --del <%= service.name %> || :
234
233
  fi
235
234
  <%- elsif @platform.servicetype == "aix" -%>
236
- /usr/bin/stopsrc -s <%= service.name -%> > /dev/null 2>&1 || :
235
+ if [ "$1" -eq 0 ]; then
236
+ /usr/bin/stopsrc -s <%= service.name -%> > /dev/null 2>&1 || :
237
+ fi
237
238
  <%- end -%>
238
239
  <%- end -%>
239
240
 
@@ -23,6 +23,14 @@ foreach ($destination in $lines) {
23
23
  # we assume it is an empty directory and simply create one in its place. There is
24
24
  # a possibility that this will hide an error where there is actually a missing
25
25
  # file. However, this is such a slim possibity, this action was deemed safe.
26
- New-Item -ItemType directory -Path "$destination"
26
+ if (Test-Path -path "$destination") {
27
+ if (Test-Path -path "$destination" -pathType container) {
28
+ Write-Debug "Directory '$destination' already exists"
29
+ } else {
30
+ Throw "File '$destination' exists and is not a directory, cannot proceed with install"
31
+ }
32
+ } else {
33
+ New-Item -ItemType directory -Path "$destination"
34
+ }
27
35
  }
28
36
  }
@@ -0,0 +1,11 @@
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
+ <Fragment>
5
+ <ComponentGroup Id="ServiceListGroup">
6
+ <%- get_services.each do |service| -%>
7
+ <ComponentGroupRef Id="Service_<%= service.id %>" />
8
+ <%- end -%>
9
+ </ComponentGroup>
10
+ </Fragment>
11
+ </Wix>
@@ -0,0 +1,23 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <xsl:stylesheet version="1.0"
3
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
+ xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
5
+ <!-- https://ahordijk.wordpress.com/2013/03/26/automatically-add-references-and-content-to-the-wix-installer/ -->
6
+ <!-- http://www.chriskonces.com/using-xslt-with-heat-exe-wix-to-create-windows-service-installs/ -->
7
+ <xsl:output method="xml" indent="yes" />
8
+ <!--<xsl:strip-space elements="*"/>-->
9
+ <xsl:template match="@*|node()">
10
+ <xsl:copy>
11
+ <xsl:apply-templates select="@*|node()"/>
12
+ </xsl:copy>
13
+ </xsl:template>
14
+ <!-- Filter out all Service File Executables from the Harvest (heat) run as these are specified in the transformed service.components.wxs file -->
15
+ <!-- The list of component service files are collected in an array so that a set of unique names can be extracted -->
16
+ <%- service_files = Array.new -%>
17
+ <%- get_services.each do |service| -%>
18
+ <%- service_files << service.service_file -%>
19
+ <%- end -%>
20
+ <%- service_files.uniq.each do |service_file| -%>
21
+ <xsl:template match="wix:Component[wix:File[@Source='<%= service_file %>']]" />
22
+ <%- end -%>
23
+ </xsl:stylesheet>
@@ -0,0 +1,34 @@
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="<%= @version.sub(/\.g[0-9a-z]{7}$/, '') %>"
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
+
21
+ <MajorUpgrade AllowDowngrades="yes" />
22
+ <Media Id="1" Cabinet="<%= settings[:product_id] %>.cab" EmbedCab="yes" CompressionLevel="high" />
23
+
24
+ <Feature Id="<%= settings[:product_id] %>Runtime" Title="<%= settings[:product_id] %> Runtime" Level="1">
25
+ <!-- We can add all components by referencing this one thing -->
26
+ <ComponentGroupRef Id="ProductComponentGroup" />
27
+ <ComponentGroupRef Id="RegistryComponentGroup" />
28
+ <ComponentGroupRef Id="ServiceListGroup" />
29
+ </Feature>
30
+ <!-- We will use DirectoryRef at the project level to hook in the project directory structure -->
31
+ <Directory Id='TARGETDIR' Name='SourceDir' />
32
+
33
+ </Product>
34
+ </Wix>
@@ -0,0 +1,18 @@
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
+ <Fragment>
4
+ <ComponentGroup Id="RegistryComponentGroup">
5
+ <Component Id="RegistryEntriesArchitectureDependent" Directory="TARGETDIR" Guid="E6D5AF4F-ACC4-4D11-AFCE-299A9ED2152C" Win64="<%= settings[:win64] %>" Permanent="yes">
6
+ <RegistryKey Root="HKLM" Key="SOFTWARE\<%= settings[:company_name] %>\<%= settings[:product_name] %>" ForceCreateOnInstall="yes" >
7
+ <RegistryValue Type="integer" Value="0"/>
8
+ <%- if @platform.architecture == "x64" -%>
9
+ <RegistryValue Name="RememberedInstallDir" Type="string" Value="[INSTALLDIR_X86]" />
10
+ <RegistryValue Name="RememberedInstallDir64" Type="string" Value="[INSTALLDIR]" KeyPath="yes" />
11
+ <%- else %>
12
+ <RegistryValue Name="RememberedInstallDir" Type="string" Value="[INSTALLDIR]" KeyPath="yes" />
13
+ <%- end -%>
14
+ </RegistryKey>
15
+ </Component>
16
+ </ComponentGroup>
17
+ </Fragment>
18
+ </Wix>
@@ -0,0 +1 @@
1
+ # Wix Test File 1
@@ -0,0 +1 @@
1
+ # Wix Test File 2
@@ -0,0 +1 @@
1
+ # ERB Wix Test File 3
@@ -0,0 +1 @@
1
+ # ERB Wix Test File 4
@@ -0,0 +1 @@
1
+ # Null ERB File for testing
@@ -0,0 +1,2 @@
1
+ # Test file for Vanagon/Wix unit testing.
2
+ # This file will "over-ride" the generic Product.wix.erb file
@@ -0,0 +1 @@
1
+ # This is a sample UI wxs file
@@ -5,12 +5,12 @@ require 'json'
5
5
  describe 'Vanagon::Component::DSL' do
6
6
  let (:component_block) {
7
7
  "component 'test-fixture' do |pkg, settings, platform|
8
- pkg.load_from_json('spec/fixures/component/test-fixture.json')
8
+ pkg.load_from_json('spec/fixtures/component/test-fixture.json')
9
9
  end" }
10
10
 
11
11
  let (:invalid_component_block) {
12
12
  "component 'test-fixture' do |pkg, settings, platform|
13
- pkg.load_from_json('spec/fixures/component/invalid-test-fixture.json')
13
+ pkg.load_from_json('spec/fixtures/component/invalid-test-fixture.json')
14
14
  end" }
15
15
 
16
16
  let (:dummy_platform_sysv) {
@@ -405,7 +405,7 @@ end" }
405
405
 
406
406
  it 'reads from a file when the OS is AIX for services' do
407
407
  comp = Vanagon::Component::DSL.new('service-test', {}, dummy_platform_aix)
408
- comp.install_service('spec/fixures/component/mcollective.service', nil, 'mcollective')
408
+ comp.install_service('spec/fixtures/component/mcollective.service', nil, 'mcollective')
409
409
  expect(comp._component.service.name).to eq('mcollective')
410
410
  expect(comp._component.service.service_command).to include('/opt/puppetlabs/puppet/bin/ruby')
411
411
  expect(comp._component.service.service_command).not_to include("\n")
@@ -4,7 +4,11 @@ require 'vanagon/platform'
4
4
  require 'logger'
5
5
 
6
6
  # Haus, I added this, cause it prevented errors.
7
- @@logger = Logger.new('/dev/null')
7
+ class Vanagon
8
+ class Driver
9
+ @@logger = Logger.new('/dev/null')
10
+ end
11
+ end
8
12
 
9
13
  describe 'Vanagon::Engine::Hardware' do
10
14
 
@@ -0,0 +1,27 @@
1
+ require 'vanagon/engine/local'
2
+
3
+ describe 'Vanagon::Engine::Local' do
4
+ let (:platform) {
5
+ plat = Vanagon::Platform::DSL.new('debian-6-i386')
6
+ plat.instance_eval("platform('debian-6-i386') { }")
7
+ plat._platform
8
+ }
9
+
10
+ describe '#validate_platform' do
11
+ it 'succeeds' do
12
+ expect(Vanagon::Engine::Local.new(platform).validate_platform).to be(true)
13
+ end
14
+ end
15
+
16
+ describe '#dispatch' do
17
+ it 'execs successfully' do
18
+ engine = Vanagon::Engine::Local.new(platform)
19
+ expect(engine.dispatch('true')).to be(true)
20
+ end
21
+
22
+ it 'returns the result if return_output is true' do
23
+ engine = Vanagon::Engine::Local.new(platform)
24
+ expect(engine.dispatch('true', true)).to eq('')
25
+ end
26
+ end
27
+ end
@@ -1,5 +1,20 @@
1
1
  require 'vanagon/platform'
2
2
 
3
+ # These constants are defined for the purpose of the project/generic file merge tests
4
+ # to point these directories to test areas under the /tmp directory.
5
+ # This allows individual test cases to be specified accurately.
6
+ # The actual resources/windows/wix files under vanagon are avoided, as the necessary
7
+ # data structures are not available under the test conditions causing failures in the
8
+ # ERB template translation
9
+
10
+ WORK_BASE = "/tmp/vanwintest"
11
+ VANAGON_ROOT = "#{WORK_BASE}/generic"
12
+ PROJ_ROOT = "#{WORK_BASE}/project"
13
+ WORKDIR = "#{WORK_BASE}/workdir"
14
+ # Admittedly this might not be the best placed statement, but my limited rspec
15
+ # started to defeat me when it came to using "let" for wixtestfiles
16
+ WIXTESTFILES = File.expand_path("./spec/fixtures/wix/resources/windows/wix")
17
+
3
18
  describe "Vanagon::Platform::Windows" do
4
19
  platforms =[
5
20
  {
@@ -10,6 +25,7 @@ describe "Vanagon::Platform::Windows" do
10
25
  :output_dir => "windows/x64",
11
26
  :output_dir_with_target => "windows/thing/x64",
12
27
  :target_user => "Administrator",
28
+ :projname => "test-proj",
13
29
  :block => %Q[ platform "windows-2012r2-x64" do |plat| end ]
14
30
  },
15
31
  ]
@@ -38,6 +54,113 @@ describe "Vanagon::Platform::Windows" do
38
54
  expect(cur_plat._platform.target_user).to eq(plat[:target_user])
39
55
  end
40
56
  end
57
+
58
+ describe '#generate_msi_packaging_artifacts' do
59
+ before(:each) do
60
+ # Create Workdir and temp root directory
61
+ FileUtils.mkdir_p("#{WORKDIR}/wix")
62
+ FileUtils.mkdir_p("#{VANAGON_ROOT}/resources/windows/wix")
63
+ FileUtils.mkdir_p("#{PROJ_ROOT}/resources/windows/wix")
64
+ # Switch directory so that project specific folder points to tmp area
65
+ @pwd = Dir.pwd
66
+ Dir.chdir(PROJ_ROOT)
67
+ end
68
+ after(:each) do
69
+ # Cleanup the complete work directory tree
70
+ FileUtils.rm_rf("#{WORK_BASE}")
71
+ Dir.chdir(@pwd)
72
+ end
73
+
74
+ it "Copies Wix File from product specific directory to output directory" do
75
+ # setup source directories and run artifact generation
76
+ FileUtils.cp("#{WIXTESTFILES}/file-1.wxs", "#{PROJ_ROOT}/resources/windows/wix/file-1.wxs")
77
+ cur_plat._platform.generate_msi_packaging_artifacts(WORKDIR, plat[:projname], binding)
78
+ # check the result
79
+ expect(File).to exist("#{WORKDIR}/wix/file-1.wxs")
80
+ end
81
+
82
+ it "Copies Wix File from Vanagon directory to work directory" do
83
+ # setup source directories and run artifact generation
84
+ FileUtils.cp("#{WIXTESTFILES}/file-1.wxs", "#{VANAGON_ROOT}/resources/windows/wix/file-1.wxs")
85
+ cur_plat._platform.generate_msi_packaging_artifacts(WORKDIR, plat[:projname], binding)
86
+ # check the result
87
+ expect(File).to exist("#{WORKDIR}/wix/file-1.wxs")
88
+ end
89
+
90
+ it "Picks Project Specific Wix File in favour of Generic Wix file" do
91
+ # setup source directories and run artifact generation
92
+ FileUtils.cp("#{WIXTESTFILES}/file-1.wxs", "#{PROJ_ROOT}/resources/windows/wix/file-wix.wxs")
93
+ FileUtils.cp("#{WIXTESTFILES}/file-2.wxs", "#{VANAGON_ROOT}/resources/windows/wix/file-wix.wxs")
94
+ cur_plat._platform.generate_msi_packaging_artifacts(WORKDIR, plat[:projname], binding)
95
+ # check the result
96
+ expect(FileUtils.compare_file("#{WIXTESTFILES}/file-1.wxs", "#{WORKDIR}/wix/file-wix.wxs")).to be_truthy
97
+ end
98
+
99
+ it "Picks Project Specific Wix File in favour of Generic ERB file" do
100
+ # setup source directories and run artifact generation
101
+ FileUtils.cp("#{WIXTESTFILES}/file-1.wxs", "#{PROJ_ROOT}/resources/windows/wix/file-wix.wxs")
102
+ FileUtils.cp("#{WIXTESTFILES}/file-3.wxs.erb", "#{VANAGON_ROOT}/resources/windows/wix/file-wix.wxs.erb")
103
+ cur_plat._platform.generate_msi_packaging_artifacts(WORKDIR, plat[:projname], binding)
104
+ # check the result
105
+ expect(FileUtils.compare_file("#{WIXTESTFILES}/file-1.wxs", "#{WORKDIR}/wix/file-wix.wxs")).to be_truthy
106
+ end
107
+
108
+ it "Picks Project Specific ERB File in favour of Generic Wix file" do
109
+ # setup source directories and run artifact generation
110
+ FileUtils.cp("#{WIXTESTFILES}/file-3.wxs.erb", "#{PROJ_ROOT}/resources/windows/wix/file-wix.wxs.erb")
111
+ FileUtils.cp("#{WIXTESTFILES}/file-2.wxs", "#{VANAGON_ROOT}/resources/windows/wix/file-wix.wxs")
112
+ cur_plat._platform.generate_msi_packaging_artifacts(WORKDIR, plat[:projname], binding)
113
+ # check the result
114
+ expect(FileUtils.compare_file("#{WIXTESTFILES}/file-3.wxs.erb", "#{WORKDIR}/wix/file-wix.wxs")).to be_truthy
115
+ end
116
+
117
+ it "Picks Project Specific ERB File in favour of Generic ERB file" do
118
+ # setup source directories and run artifact generation
119
+ FileUtils.cp("#{WIXTESTFILES}/file-3.wxs.erb", "#{PROJ_ROOT}/resources/windows/wix/file-wix.wxs.erb")
120
+ FileUtils.cp("#{WIXTESTFILES}/file-4.wxs.erb", "#{VANAGON_ROOT}/resources/windows/wix/file-wix.wxs.erb")
121
+ cur_plat._platform.generate_msi_packaging_artifacts(WORKDIR, plat[:projname], binding)
122
+ # check the result
123
+ expect(FileUtils.compare_file("#{WIXTESTFILES}/file-3.wxs.erb", "#{WORKDIR}/wix/file-wix.wxs")).to be_truthy
124
+ end
125
+
126
+ it "Copies Hierarchy of files from Product Specific Directory to output directory with ERB translation as necessary" do
127
+ # setup source directories and run artifact generation
128
+ FileUtils.cp_r("#{WIXTESTFILES}/", "#{PROJ_ROOT}/resources/windows/", :verbose => true)
129
+ cur_plat._platform.generate_msi_packaging_artifacts(WORKDIR, plat[:projname], binding)
130
+ # check the result
131
+ expect(File).to exist("#{WORKDIR}/wix/file-1.wxs")
132
+ expect(File).to exist("#{WORKDIR}/wix/file-2.wxs")
133
+ expect(File).to exist("#{WORKDIR}/wix/file-3.wxs")
134
+ expect(File).to exist("#{WORKDIR}/wix/file-4.wxs")
135
+ expect(File).to exist("#{WORKDIR}/wix/project.filter.xslt")
136
+ expect(File).to exist("#{WORKDIR}/wix/project.wxs")
137
+ expect(File).to exist("#{WORKDIR}/wix/include/include-sample-1.wxs")
138
+ expect(File).to exist("#{WORKDIR}/wix/ui/ui-sample-1.wxs")
139
+ expect(File).to exist("#{WORKDIR}/wix/ui/bitmaps/bitmap.bmp")
140
+ expect(File).not_to exist("#{WORKDIR}/wix/project.filter.xslt.erb")
141
+ expect(File).not_to exist("#{WORKDIR}/wix/file-3.wxs.erb")
142
+ expect(File).not_to exist("#{WORKDIR}/wix/file-4.wxs.erb")
143
+ end
144
+
145
+ it "Copies Hierarchy of files from vanagon directory to output directory with ERB translation as necessary" do
146
+ # setup source directories and run artifact generation
147
+ FileUtils.cp_r("#{WIXTESTFILES}/", "#{VANAGON_ROOT}/resources/windows/", :verbose => true)
148
+ cur_plat._platform.generate_msi_packaging_artifacts(WORKDIR, plat[:projname], binding)
149
+ # check the result
150
+ expect(File).to exist("#{WORKDIR}/wix/file-1.wxs")
151
+ expect(File).to exist("#{WORKDIR}/wix/file-2.wxs")
152
+ expect(File).to exist("#{WORKDIR}/wix/file-3.wxs")
153
+ expect(File).to exist("#{WORKDIR}/wix/file-4.wxs")
154
+ expect(File).to exist("#{WORKDIR}/wix/project.filter.xslt")
155
+ expect(File).to exist("#{WORKDIR}/wix/project.wxs")
156
+ expect(File).to exist("#{WORKDIR}/wix/include/include-sample-1.wxs")
157
+ expect(File).to exist("#{WORKDIR}/wix/ui/ui-sample-1.wxs")
158
+ expect(File).to exist("#{WORKDIR}/wix/ui/bitmaps/bitmap.bmp")
159
+ expect(File).not_to exist("#{WORKDIR}/wix/project.filter.xslt.erb")
160
+ expect(File).not_to exist("#{WORKDIR}/wix/file-3.wxs.erb")
161
+ expect(File).not_to exist("#{WORKDIR}/wix/file-4.wxs.erb")
162
+ end
163
+ end
41
164
  end
42
165
  end
43
166
  end
@@ -41,6 +41,17 @@ describe "Vanagon::Utilities" do
41
41
  end
42
42
  end
43
43
 
44
+ describe '#local_command' do
45
+ it 'runs commands in an unpolluted environment' do
46
+ cmd = lambda { |arg| %(echo 'if [ "$#{arg}" = "" ]; then exit 0; else exit 1; fi' | /bin/sh) }
47
+ vars = %w(BUNDLE_BIN_PATH BUNDLE_GEMFILE)
48
+ vars.each do |var|
49
+ Vanagon::Utilities.local_command(cmd.call(var))
50
+ expect($?.exitstatus).to eq(0)
51
+ end
52
+ end
53
+ end
54
+
44
55
  describe "#is_git_repo?" do
45
56
  let(:dir) { Dir.mktmpdir }
46
57
  after(:each) { FileUtils.rm_rf(dir) }
@@ -0,0 +1,6 @@
1
+ RSpec.configure do |c|
2
+ c.before do
3
+ allow($stdout).to receive(:puts)
4
+ allow($stderr).to receive(:puts)
5
+ end
6
+ 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.5.1
4
+ version: 0.5.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-02-04 00:00:00.000000000 Z
11
+ date: 2016-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -132,10 +132,22 @@ files:
132
132
  - resources/windows/nuget/chocolateyInstall.ps1
133
133
  - resources/windows/nuget/chocolateyUninstall.ps1
134
134
  - resources/windows/nuget/project.nuspec.erb
135
- - resources/windows/wix/service.component.wxs.erb
136
- - spec/fixures/component/invalid-test-fixture.json
137
- - spec/fixures/component/mcollective.service
138
- - spec/fixures/component/test-fixture.json
135
+ - resources/windows/wix/componentrefs.wxs.erb
136
+ - resources/windows/wix/filter.xslt.erb
137
+ - resources/windows/wix/project.wxs.erb
138
+ - resources/windows/wix/registryEntries.wxs.erb
139
+ - spec/fixtures/component/invalid-test-fixture.json
140
+ - spec/fixtures/component/mcollective.service
141
+ - spec/fixtures/component/test-fixture.json
142
+ - spec/fixtures/wix/resources/windows/wix/file-1.wxs
143
+ - spec/fixtures/wix/resources/windows/wix/file-2.wxs
144
+ - spec/fixtures/wix/resources/windows/wix/file-3.wxs.erb
145
+ - spec/fixtures/wix/resources/windows/wix/file-4.wxs.erb
146
+ - spec/fixtures/wix/resources/windows/wix/include/include-sample-1.wxs
147
+ - spec/fixtures/wix/resources/windows/wix/project.filter.xslt.erb
148
+ - spec/fixtures/wix/resources/windows/wix/project.wxs
149
+ - spec/fixtures/wix/resources/windows/wix/ui/bitmaps/bitmap.bmp
150
+ - spec/fixtures/wix/resources/windows/wix/ui/ui-sample-1.wxs
139
151
  - spec/lib/makefile_spec.rb
140
152
  - spec/lib/vanagon/common/pathname_spec.rb
141
153
  - spec/lib/vanagon/common/user_spec.rb
@@ -148,6 +160,7 @@ files:
148
160
  - spec/lib/vanagon/engine/base_spec.rb
149
161
  - spec/lib/vanagon/engine/docker_spec.rb
150
162
  - spec/lib/vanagon/engine/hardware_spec.rb
163
+ - spec/lib/vanagon/engine/local_spec.rb
151
164
  - spec/lib/vanagon/engine/pooler_spec.rb
152
165
  - spec/lib/vanagon/optparse_spec.rb
153
166
  - spec/lib/vanagon/platform/deb_spec.rb
@@ -161,6 +174,7 @@ files:
161
174
  - spec/lib/vanagon/project_spec.rb
162
175
  - spec/lib/vanagon/utilities/shell_utilities_spec.rb
163
176
  - spec/lib/vanagon/utilities_spec.rb
177
+ - spec/spec_helper.rb
164
178
  homepage: http://github.com/puppetlabs/vanagon
165
179
  licenses:
166
180
  - Apache-2.0
@@ -198,6 +212,7 @@ test_files:
198
212
  - spec/lib/vanagon/engine/base_spec.rb
199
213
  - spec/lib/vanagon/engine/docker_spec.rb
200
214
  - spec/lib/vanagon/engine/hardware_spec.rb
215
+ - spec/lib/vanagon/engine/local_spec.rb
201
216
  - spec/lib/vanagon/engine/pooler_spec.rb
202
217
  - spec/lib/vanagon/optparse_spec.rb
203
218
  - spec/lib/vanagon/platform/deb_spec.rb
@@ -1,55 +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
- <Fragment>
4
- <%- get_services.each do |service| -%>
5
- <%- service.options.each do |component| -%>
6
- <DirectoryRef Id="<%= component[:directory_ref] %>">
7
- <Component Id='<%= component[:id] %>' Guid="<%= component[:guid] %>" <%= "Win64=\"#{component[:win64]}\"" unless component[:win64].nil? %>>
8
- <%- unless component[:conditions].nil? -%>
9
- <%- component[:conditions].each do |condition| -%>
10
- <Condition>
11
- <%= condition %>
12
- </Condition>
13
- <%- end -%>
14
- <%- end -%>
15
- <File Id="<%= component[:file][:id] %>" KeyPath="yes" Source="<%= component[:file][:source] %>" />
16
- <ServiceInstall Id="<%= component[:serviceinstall][:id] %>"
17
- Account="[PUPPET_AGENT_ACCOUNT_DOMAIN]\[PUPPET_AGENT_ACCOUNT_USER]"
18
- Password="[PUPPET_AGENT_ACCOUNT_PASSWORD]"
19
- Description="<%= component[:serviceinstall][:description] %>"
20
- DisplayName="<%= component[:serviceinstall][:displayname] %>"
21
- Interactive="no"
22
- Name="<%= component[:serviceinstall][:name] %>"
23
- Start="<%= component[:serviceinstall][:start] %>"
24
- Type="ownProcess"
25
- ErrorControl="normal"
26
- Vital="yes"
27
- <%- unless component[:serviceinstall][:arguments].nil? -%>
28
- Arguments="<%= component[:serviceinstall][:arguments] %>"
29
- <%- end -%>
30
- />
31
- <%- unless component[:registries].nil? -%>
32
- <RegistryKey Root="<%= component[:registries][:root] %>" Key="<%= component[:registries][:key] %>">
33
- <%- unless component[:registries][:values].nil? -%>
34
- <%- component[:registries][:values].each do |value| -%>
35
- <RegistryValue Name="<%= value[:name] %>" Value="<%= value[:value] %>" Type="<%= value[:type] %>" <%= "Action=\"#{value[:action]}\"" unless value[:action].nil? %> />
36
- <%- end -%>
37
- <%- end -%>
38
- <%- unless component[:registries][:keys].nil? -%>
39
- <%- component[:registries][:keys].each do |key| -%>
40
- <RegistryKey Key="<%= key[:name] %>">
41
- <%- key[:values].each do |value| -%>
42
- <RegistryValue <%= "Name=\"#{value[:name]}\"" unless value[:name].nil? %> Value="<%= value[:value] %>" Type="<%= value[:type] %>" />
43
- <%- end -%>
44
- </RegistryKey>
45
- <%- end -%>
46
- <%- end -%>
47
- </RegistryKey>
48
- <%- end -%>
49
- <ServiceControl Id="<%= component[:servicecontrol][:id] %>" <%= "Start=\"#{component[:servicecontrol][:start]}\"" unless component[:servicecontrol][:start].nil? %> Stop="both" Remove="uninstall" Name="<%= component[:servicecontrol][:name] %>" Wait="yes" />
50
- </Component>
51
- </DirectoryRef>
52
- <%- end -%>
53
- <%- end -%>
54
- </Fragment>
55
- </Wix>