madscience 0.0.4 → 0.0.5

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.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/Cheffile +1 -1
  3. data/Cheffile.lock +12 -12
  4. data/cookbooks/apt/CHANGELOG.md +25 -0
  5. data/cookbooks/apt/README.md +4 -7
  6. data/cookbooks/apt/attributes/default.rb +17 -0
  7. data/cookbooks/apt/metadata.json +2 -2
  8. data/cookbooks/apt/metadata.rb +1 -1
  9. data/cookbooks/apt/providers/repository.rb +62 -9
  10. data/cookbooks/apt/recipes/default.rb +15 -8
  11. data/cookbooks/apt/recipes/unattended-upgrades.rb +43 -0
  12. data/cookbooks/apt/templates/default/20auto-upgrades.erb +2 -0
  13. data/cookbooks/apt/templates/default/50unattended-upgrades.erb +62 -0
  14. data/cookbooks/apt/templates/default/unattended-upgrades.seed.erb +1 -0
  15. data/cookbooks/dmg/CHANGELOG.md +3 -0
  16. data/cookbooks/dmg/libraries/matchers.rb +24 -0
  17. data/cookbooks/dmg/metadata.json +1 -1
  18. data/cookbooks/dmg/metadata.rb +1 -1
  19. data/cookbooks/vagrant/README.md +4 -2
  20. data/cookbooks/vagrant/attributes/default.rb +5 -4
  21. data/cookbooks/vagrant/libraries/helpers.rb +50 -0
  22. data/cookbooks/vagrant/metadata.rb +1 -1
  23. data/cookbooks/vagrant/recipes/mac_os_x.rb +16 -0
  24. data/cookbooks/windows/Berksfile +7 -0
  25. data/cookbooks/windows/CHANGELOG.md +31 -0
  26. data/cookbooks/windows/CONTRIBUTING +46 -0
  27. data/cookbooks/windows/Gemfile +14 -0
  28. data/cookbooks/windows/LICENSE +201 -0
  29. data/cookbooks/windows/README.md +51 -6
  30. data/cookbooks/windows/TODO.md +6 -0
  31. data/cookbooks/windows/attributes/default.rb +1 -0
  32. data/cookbooks/windows/chefignore +2 -0
  33. data/cookbooks/windows/libraries/matchers.rb +18 -3
  34. data/cookbooks/windows/libraries/registry_helper.rb +10 -3
  35. data/cookbooks/windows/libraries/version.rb +4 -3
  36. data/cookbooks/windows/libraries/windows_architecture_helper.rb +1 -0
  37. data/cookbooks/windows/libraries/windows_helper.rb +15 -1
  38. data/cookbooks/windows/libraries/windows_package.rb +266 -0
  39. data/cookbooks/windows/libraries/wmi_helper.rb +32 -0
  40. data/cookbooks/windows/metadata.json +12 -4
  41. data/cookbooks/windows/metadata.rb +1 -1
  42. data/cookbooks/windows/providers/auto_run.rb +2 -1
  43. data/cookbooks/windows/providers/batch.rb +1 -0
  44. data/cookbooks/windows/providers/feature_servermanagercmd.rb +17 -3
  45. data/cookbooks/windows/providers/font.rb +69 -0
  46. data/cookbooks/windows/providers/pagefile.rb +2 -2
  47. data/cookbooks/windows/providers/path.rb +21 -4
  48. data/cookbooks/windows/providers/printer.rb +1 -0
  49. data/cookbooks/windows/providers/printer_port.rb +1 -0
  50. data/cookbooks/windows/providers/reboot.rb +2 -0
  51. data/cookbooks/windows/providers/registry.rb +9 -6
  52. data/cookbooks/windows/providers/task.rb +44 -5
  53. data/cookbooks/windows/providers/zipfile.rb +3 -2
  54. data/cookbooks/windows/recipes/reboot_handler.rb +1 -1
  55. data/cookbooks/windows/resources/auto_run.rb +1 -1
  56. data/cookbooks/windows/resources/font.rb +25 -0
  57. data/cookbooks/windows/resources/path.rb +1 -1
  58. data/cookbooks/windows/resources/task.rb +3 -3
  59. data/cookbooks/windows/resources/zipfile.rb +1 -1
  60. data/cookbooks/yum/CHANGELOG.md +42 -0
  61. data/cookbooks/yum/README.md +11 -1
  62. data/cookbooks/yum/attributes/main.rb +0 -1
  63. data/cookbooks/yum/metadata.json +2 -2
  64. data/cookbooks/yum/metadata.rb +1 -2
  65. data/cookbooks/yum/providers/repository.rb +18 -3
  66. data/cookbooks/yum/recipes/default.rb +6 -14
  67. data/cookbooks/yum/resources/globalconfig.rb +5 -2
  68. data/cookbooks/yum/resources/repository.rb +7 -3
  69. data/cookbooks/yum/templates/default/main.erb +19 -4
  70. data/cookbooks/yum/templates/default/repo.erb +17 -4
  71. data/lib/madscience/version.rb +1 -1
  72. data/site-cookbooks/madscience-vagrant-cookbook/recipes/default.rb +11 -10
  73. metadata +17 -3
  74. data/cookbooks/windows/providers/package.rb +0 -252
  75. data/cookbooks/windows/resources/package.rb +0 -46
@@ -149,10 +149,10 @@ mirrorlist_expire=<%= @config.mirrorlist_expire %>
149
149
  <% if @config.multilib_policy %>
150
150
  multilib_policy=<%= @config.multilib_policy %>
151
151
  <% end %>
152
- <% if @config.obsoletes %>
153
- obsoletes=1
154
- <% else %>
152
+ <% if @config.obsoletes == false %>
155
153
  obsoletes=0
154
+ <% else %>
155
+ obsoletes=1
156
156
  <% end %>
157
157
  <% if @config.overwrite_groups %>
158
158
  overwrite_groups=<%= @config.overwrite_groups %>
@@ -222,7 +222,7 @@ sslclientcert=<%= @config.sslclientcert %>
222
222
  <% if @config.sslclientkey %>
223
223
  sslclientkey=<%= @config.sslclientkey %>
224
224
  <% end %>
225
- <% if @config.sslverify %>
225
+ <% unless @config.sslverify.nil? %>
226
226
  sslverify=<%= @config.sslverify %>
227
227
  <% end %>
228
228
  <% if @config.syslog_device %>
@@ -249,3 +249,18 @@ tsflags=<%= @config.tsflags %>
249
249
  <% if @config.username %>
250
250
  username=<%= @config.username %>
251
251
  <% end %>
252
+ <% if @config.options -%>
253
+ <% @config.options.each do |key, value| -%>
254
+ <%= key %>=<%=
255
+ case value
256
+ when Array
257
+ value.join("\n ")
258
+ when TrueClass
259
+ '1'
260
+ when FalseClass
261
+ '0'
262
+ else
263
+ value
264
+ end %>
265
+ <% end -%>
266
+ <% end -%>
@@ -99,11 +99,24 @@ sslclientcert=<%= @config.sslclientcert %>
99
99
  <% if @config.sslclientkey %>
100
100
  sslclientkey=<%= @config.sslclientkey %>
101
101
  <% end %>
102
- <% if @config.sslverify %>
103
- sslverify=1
104
- <% else %>
105
- sslverify=0
102
+ <% unless @config.sslverify.nil? %>
103
+ sslverify=<%= @config.sslverify %>
106
104
  <% end %>
107
105
  <% if @config.timeout %>
108
106
  timeout=<%= @config.timeout %>
109
107
  <% end %>
108
+ <% if @config.options -%>
109
+ <% @config.options.each do |key, value| -%>
110
+ <%= key %>=<%=
111
+ case value
112
+ when Array
113
+ value.join("\n ")
114
+ when TrueClass
115
+ '1'
116
+ when FalseClass
117
+ '0'
118
+ else
119
+ value
120
+ end %>
121
+ <% end -%>
122
+ <% end -%>
@@ -1,3 +1,3 @@
1
1
  module MadScience
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -12,41 +12,42 @@
12
12
  # Default attributes in a cookbook override default
13
13
  # attributes in an attributes file, like the one
14
14
  # in vagrant-cookbook/attributes/default.rb.
15
+ node.default['vagrant']['version'] = '1.7.1'
15
16
  node.default['vagrant']['plugins'] = [ 'vagrant-omnibus', 'vagrant-librarian-chef' ]
16
17
 
17
18
  case node['platform_family']
18
19
  when 'fedora'
19
20
  if node['kernel']['machine'] == 'x86_64'
20
- node.default['vagrant']['url'] = 'https://dl.bintray.com/mitchellh/vagrant/vagrant_1.6.3_x86_64.rpm'
21
+ node.default['vagrant']['url'] = 'https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.1_x86_64.rpm'
21
22
  else
22
- node.default['vagrant']['url'] = 'https://dl.bintray.com/mitchellh/vagrant/vagrant_1.6.3_x86_32.rpm'
23
+ node.default['vagrant']['url'] = 'https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.1_x86_32.rpm'
23
24
  end
24
25
  when 'rhel'
25
26
  if node['kernel']['machine'] == 'x86_64'
26
- node.default['vagrant']['url'] = 'https://dl.bintray.com/mitchellh/vagrant/vagrant_1.6.3_x86_64.rpm'
27
+ node.default['vagrant']['url'] = 'https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.1_x86_64.rpm'
27
28
  else
28
- node.default['vagrant']['url'] = 'https://dl.bintray.com/mitchellh/vagrant/vagrant_1.6.3_x86_32.rpm'
29
+ node.default['vagrant']['url'] = 'https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.1_x86_32.rpm'
29
30
  end
30
31
  when 'debian'
31
32
  if node['kernel']['machine'] == 'x86_64'
32
- node.default['vagrant']['url'] = 'https://dl.bintray.com/mitchellh/vagrant/vagrant_1.6.3_x86_64.deb'
33
+ node.default['vagrant']['url'] = 'https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.1_x86_64.deb'
33
34
  else
34
- node.default['vagrant']['url'] = 'https://dl.bintray.com/mitchellh/vagrant/vagrant_1.6.3_x86_32.deb'
35
+ node.default['vagrant']['url'] = 'https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.1_x86_32.deb'
35
36
  end
36
37
  when 'windows'
37
38
  # TODO: find real MSI version
38
- node.default['vagrant']['url'] = 'https://dl.bintray.com/mitchellh/vagrant/vagrant_1.6.3.msi'
39
+ node.default['vagrant']['url'] = 'https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.1.msi'
39
40
  when 'mac_os_x'
40
- node.default['vagrant']['url'] = 'https://dl.bintray.com/mitchellh/vagrant/vagrant_1.6.3.dmg'
41
+ node.default['vagrant']['url'] = 'https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.1.dmg'
41
42
  else
42
43
  raise "Don't recognize OS family: #{node['platform_family'].inspect}!"
43
44
  end
44
45
 
45
46
  case node['platform_family']
46
47
  when 'mac_os_x'
47
- node.default['virtualbox']['url'] = 'http://download.virtualbox.org/virtualbox/4.3.12/VirtualBox-4.3.12-93733-OSX.dmg'
48
+ node.default['virtualbox']['url'] = 'http://download.virtualbox.org/virtualbox/4.3.20/VirtualBox-4.3.20-93733-OSX.dmg'
48
49
  when 'windows'
49
- node.default['virtualbox']['url'] = 'http://download.virtualbox.org/virtualbox/4.3.12/VirtualBox-4.3.12-93733-Win.exe'
50
+ node.default['virtualbox']['url'] = 'http://download.virtualbox.org/virtualbox/4.3.20/VirtualBox-4.3.20-93733-Win.exe'
50
51
  node.default['virtualbox']['version'] = Vbox::Helpers.vbox_version(node['virtualbox']['url'])
51
52
  when 'debian', 'rhel'
52
53
  node.default['virtualbox']['version'] = '4.3'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: madscience
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noah Gibbs
@@ -185,11 +185,15 @@ files:
185
185
  - cookbooks/apt/recipes/cacher-client.rb
186
186
  - cookbooks/apt/recipes/cacher-ng.rb
187
187
  - cookbooks/apt/recipes/default.rb
188
+ - cookbooks/apt/recipes/unattended-upgrades.rb
188
189
  - cookbooks/apt/resources/preference.rb
189
190
  - cookbooks/apt/resources/repository.rb
190
191
  - cookbooks/apt/templates/debian-6.0/acng.conf.erb
191
192
  - cookbooks/apt/templates/default/01proxy.erb
193
+ - cookbooks/apt/templates/default/20auto-upgrades.erb
194
+ - cookbooks/apt/templates/default/50unattended-upgrades.erb
192
195
  - cookbooks/apt/templates/default/acng.conf.erb
196
+ - cookbooks/apt/templates/default/unattended-upgrades.seed.erb
193
197
  - cookbooks/apt/templates/ubuntu-10.04/acng.conf.erb
194
198
  - cookbooks/chef_handler/CHANGELOG.md
195
199
  - cookbooks/chef_handler/README.md
@@ -205,6 +209,7 @@ files:
205
209
  - cookbooks/dmg/CHANGELOG.md
206
210
  - cookbooks/dmg/README.md
207
211
  - cookbooks/dmg/attributes/default.rb
212
+ - cookbooks/dmg/libraries/matchers.rb
208
213
  - cookbooks/dmg/metadata.json
209
214
  - cookbooks/dmg/metadata.rb
210
215
  - cookbooks/dmg/providers/package.rb
@@ -215,6 +220,7 @@ files:
215
220
  - cookbooks/vagrant/README.md
216
221
  - cookbooks/vagrant/TESTING.md
217
222
  - cookbooks/vagrant/attributes/default.rb
223
+ - cookbooks/vagrant/libraries/helpers.rb
218
224
  - cookbooks/vagrant/metadata.rb
219
225
  - cookbooks/vagrant/providers/plugin.rb
220
226
  - cookbooks/vagrant/recipes/debian.rb
@@ -242,9 +248,15 @@ files:
242
248
  - cookbooks/virtualbox/templates/ubuntu/config.erb
243
249
  - cookbooks/virtualbox/templates/ubuntu/config.php.erb
244
250
  - cookbooks/virtualbox/templates/ubuntu/vbox.cfg.erb
251
+ - cookbooks/windows/Berksfile
245
252
  - cookbooks/windows/CHANGELOG.md
253
+ - cookbooks/windows/CONTRIBUTING
254
+ - cookbooks/windows/Gemfile
255
+ - cookbooks/windows/LICENSE
246
256
  - cookbooks/windows/README.md
257
+ - cookbooks/windows/TODO.md
247
258
  - cookbooks/windows/attributes/default.rb
259
+ - cookbooks/windows/chefignore
248
260
  - cookbooks/windows/files/default/handlers/windows_reboot_handler.rb
249
261
  - cookbooks/windows/libraries/feature_base.rb
250
262
  - cookbooks/windows/libraries/matchers.rb
@@ -254,7 +266,9 @@ files:
254
266
  - cookbooks/windows/libraries/version.rb
255
267
  - cookbooks/windows/libraries/windows_architecture_helper.rb
256
268
  - cookbooks/windows/libraries/windows_helper.rb
269
+ - cookbooks/windows/libraries/windows_package.rb
257
270
  - cookbooks/windows/libraries/windows_privileged.rb
271
+ - cookbooks/windows/libraries/wmi_helper.rb
258
272
  - cookbooks/windows/metadata.json
259
273
  - cookbooks/windows/metadata.rb
260
274
  - cookbooks/windows/providers/auto_run.rb
@@ -262,7 +276,7 @@ files:
262
276
  - cookbooks/windows/providers/feature_dism.rb
263
277
  - cookbooks/windows/providers/feature_powershell.rb
264
278
  - cookbooks/windows/providers/feature_servermanagercmd.rb
265
- - cookbooks/windows/providers/package.rb
279
+ - cookbooks/windows/providers/font.rb
266
280
  - cookbooks/windows/providers/pagefile.rb
267
281
  - cookbooks/windows/providers/path.rb
268
282
  - cookbooks/windows/providers/printer.rb
@@ -277,7 +291,7 @@ files:
277
291
  - cookbooks/windows/resources/auto_run.rb
278
292
  - cookbooks/windows/resources/batch.rb
279
293
  - cookbooks/windows/resources/feature.rb
280
- - cookbooks/windows/resources/package.rb
294
+ - cookbooks/windows/resources/font.rb
281
295
  - cookbooks/windows/resources/pagefile.rb
282
296
  - cookbooks/windows/resources/path.rb
283
297
  - cookbooks/windows/resources/printer.rb
@@ -1,252 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Cookbook Name:: windows
4
- # Provider:: package
5
- #
6
- # Copyright:: 2011, Opscode, Inc.
7
- #
8
- # Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- # See the License for the specific language governing permissions and
18
- # limitations under the License.
19
- #
20
-
21
- if RUBY_PLATFORM =~ /mswin|mingw32|windows/
22
- require 'win32/registry'
23
- end
24
-
25
- require 'chef/mixin/shell_out'
26
- require 'chef/mixin/language'
27
-
28
- include Chef::Mixin::ShellOut
29
- include Windows::Helper
30
-
31
- # the logic in all action methods mirror that of
32
- # the Chef::Provider::Package which will make
33
- # refactoring into core chef easy
34
-
35
- action :install do
36
- # If we specified a version, and it's not the current version, move to the specified version
37
- if @new_resource.version != nil && @new_resource.version != @current_resource.version
38
- install_version = @new_resource.version
39
- # If it's not installed at all, install it
40
- elsif @current_resource.version == nil
41
- install_version = candidate_version
42
- end
43
-
44
- if install_version
45
- Chef::Log.info("Installing #{@new_resource} version #{install_version}")
46
- status = install_package(@new_resource.package_name, install_version)
47
- if status
48
- @new_resource.updated_by_last_action(true)
49
- end
50
- end
51
- end
52
-
53
- action :upgrade do
54
- if @current_resource.version != candidate_version
55
- orig_version = @current_resource.version || "uninstalled"
56
- Chef::Log.info("Upgrading #{@new_resource} version from #{orig_version} to #{candidate_version}")
57
- status = upgrade_package(@new_resource.package_name, candidate_version)
58
- if status
59
- @new_resource.updated_by_last_action(true)
60
- end
61
- end
62
- end
63
-
64
- action :remove do
65
- if removing_package?
66
- Chef::Log.info("Removing #{@new_resource}")
67
- remove_package(@current_resource.package_name, @new_resource.version)
68
- @new_resource.updated_by_last_action(true)
69
- else
70
- end
71
- end
72
-
73
- def removing_package?
74
- if @current_resource.version.nil?
75
- false # nothing to remove
76
- elsif @new_resource.version.nil?
77
- true # remove any version of a package
78
- elsif @new_resource.version == @current_resource.version
79
- true # remove the version we have
80
- else
81
- false # we don't have the version we want to remove
82
- end
83
- end
84
-
85
- def expand_options(options)
86
- options ? " #{options}" : ""
87
- end
88
-
89
- # these methods are the required overrides of
90
- # a provider that extends from Chef::Provider::Package
91
- # so refactoring into core Chef should be easy
92
-
93
- def load_current_resource
94
- @current_resource = Chef::Resource::WindowsPackage.new(@new_resource.name)
95
- @current_resource.package_name(@new_resource.package_name)
96
- @current_resource.version(nil)
97
-
98
- unless current_installed_version.nil?
99
- @current_resource.version(current_installed_version)
100
- end
101
-
102
- @current_resource
103
- end
104
-
105
- def current_installed_version
106
- @current_installed_version ||= begin
107
- if installed_packages.include?(@new_resource.package_name)
108
- installed_packages[@new_resource.package_name][:version]
109
- end
110
- end
111
- end
112
-
113
- def candidate_version
114
- @candidate_version ||= begin
115
- @new_resource.version || 'latest'
116
- end
117
- end
118
-
119
- def install_package(name,version)
120
- Chef::Log.debug("Processing #{@new_resource} as a #{installer_type} installer.")
121
- install_args = [cached_file(@new_resource.source, @new_resource.checksum), expand_options(unattended_installation_flags), expand_options(@new_resource.options)]
122
- Chef::Log.info("Starting installation...this could take awhile.")
123
- Chef::Log.debug "Install command: #{ sprintf(install_command_template, *install_args) }"
124
- shell_out!(sprintf(install_command_template, *install_args), {:timeout => @new_resource.timeout, :returns => @new_resource.success_codes})
125
- end
126
-
127
- def remove_package(name, version)
128
- uninstall_string = installed_packages[@new_resource.package_name][:uninstall_string]
129
- Chef::Log.info("Registry provided uninstall string for #{@new_resource} is '#{uninstall_string}'")
130
- uninstall_command = begin
131
- if uninstall_string =~ /msiexec/i
132
- "#{uninstall_string} /qn"
133
- else
134
- uninstall_string.gsub!('"','')
135
- "start \"\" /wait /d\"#{::File.dirname(uninstall_string)}\" #{::File.basename(uninstall_string)}#{expand_options(@new_resource.options)} /S"
136
- end
137
- end
138
- Chef::Log.info("Removing #{@new_resource} with uninstall command '#{uninstall_command}'")
139
- shell_out!(uninstall_command, {:returns => @new_resource.success_codes})
140
- end
141
-
142
- private
143
-
144
- def install_command_template
145
- case installer_type
146
- when :msi
147
- "msiexec%2$s \"%1$s\"%3$s"
148
- else
149
- "start \"\" /wait \"%1$s\"%2$s%3$s"
150
- end
151
- end
152
-
153
- def uninstall_command_template
154
- case installer_type
155
- when :msi
156
- "msiexec %2$s %1$s"
157
- else
158
- "start \"\" /wait /d%1$s %2$s %3$s"
159
- end
160
- end
161
-
162
- # http://unattended.sourceforge.net/installers.php
163
- def unattended_installation_flags
164
- case installer_type
165
- when :msi
166
- # this is no-ui
167
- "/qn /i"
168
- when :installshield
169
- "/s /sms"
170
- when :nsis
171
- "/S /NCRC"
172
- when :inno
173
- #"/sp- /silent /norestart"
174
- "/verysilent /norestart"
175
- when :wise
176
- "/s"
177
- else
178
- end
179
- end
180
-
181
- def installed_packages
182
- @installed_packages || begin
183
- installed_packages = {}
184
- # Computer\HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall
185
- installed_packages.merge!(extract_installed_packages_from_key(::Win32::Registry::HKEY_LOCAL_MACHINE)) #rescue nil
186
- # 64-bit registry view
187
- # Computer\HKEY_LOCAL_MACHINE\Software\Wow6464Node\Microsoft\Windows\CurrentVersion\Uninstall
188
- installed_packages.merge!(extract_installed_packages_from_key(::Win32::Registry::HKEY_LOCAL_MACHINE, (::Win32::Registry::Constants::KEY_READ | 0x0100))) #rescue nil
189
- # 32-bit registry view
190
- # Computer\HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
191
- installed_packages.merge!(extract_installed_packages_from_key(::Win32::Registry::HKEY_LOCAL_MACHINE, (::Win32::Registry::Constants::KEY_READ | 0x0200))) #rescue nil
192
- # Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall
193
- installed_packages.merge!(extract_installed_packages_from_key(::Win32::Registry::HKEY_CURRENT_USER)) #rescue nil
194
- installed_packages
195
- end
196
- end
197
-
198
- def extract_installed_packages_from_key(hkey = ::Win32::Registry::HKEY_LOCAL_MACHINE, desired = ::Win32::Registry::Constants::KEY_READ)
199
- uninstall_subkey = 'Software\Microsoft\Windows\CurrentVersion\Uninstall'
200
- packages = {}
201
- begin
202
- ::Win32::Registry.open(hkey, uninstall_subkey, desired) do |reg|
203
- reg.each_key do |key, wtime|
204
- begin
205
- k = reg.open(key, desired)
206
- display_name = k["DisplayName"] rescue nil
207
- version = k["DisplayVersion"] rescue "NO VERSION"
208
- uninstall_string = k["UninstallString"] rescue nil
209
- if display_name
210
- packages[display_name] = {:name => display_name,
211
- :version => version,
212
- :uninstall_string => uninstall_string}
213
- end
214
- rescue ::Win32::Registry::Error
215
- end
216
- end
217
- end
218
- rescue ::Win32::Registry::Error
219
- end
220
- packages
221
- end
222
-
223
- def installer_type
224
- @installer_type || begin
225
- if @new_resource.installer_type
226
- @new_resource.installer_type
227
- else
228
- basename = ::File.basename(cached_file(@new_resource.source, @new_resource.checksum))
229
- if basename.split(".").last.downcase == "msi" # Microsoft MSI
230
- :msi
231
- else
232
- # search the binary file for installer type
233
- contents = ::Kernel.open(::File.expand_path(cached_file(@new_resource.source)), "rb") {|io| io.read } # TODO limit data read in
234
- case contents
235
- when /inno/i # Inno Setup
236
- :inno
237
- when /wise/i # Wise InstallMaster
238
- :wise
239
- when /nsis/i # Nullsoft Scriptable Install System
240
- :nsis
241
- else
242
- # if file is named 'setup.exe' assume installshield
243
- if basename == "setup.exe"
244
- :installshield
245
- else
246
- raise Chef::Exceptions::AttributeNotFound, "installer_type could not be determined, please set manually"
247
- end
248
- end
249
- end
250
- end
251
- end
252
- end
@@ -1,46 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Cookbook Name:: windows
4
- # Resource:: package
5
- #
6
- # Copyright:: 2011, Opscode, Inc.
7
- #
8
- # Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- # See the License for the specific language governing permissions and
18
- # limitations under the License.
19
- #
20
-
21
- actions :install, :remove
22
-
23
- default_action :install
24
-
25
- attribute :package_name, :kind_of => String, :name_attribute => true
26
- attribute :source, :kind_of => String, :required => true
27
- attribute :version, :kind_of => String
28
- attribute :options, :kind_of => String
29
- attribute :installer_type, :kind_of => Symbol, :default => nil, :equal_to => [:msi, :inno, :nsis, :wise, :installshield, :custom]
30
- attribute :checksum, :kind_of => String
31
- attribute :timeout, :kind_of => Integer, :default => 600
32
- attribute :success_codes, :kind_of => Array, :default => [0, 42, 127]
33
-
34
- # TODO
35
-
36
- # add preseeding support
37
- #attribute :response_file
38
-
39
- # allow target dirtory of installation to be set
40
- #attribute :target_dir
41
-
42
- # Covers 0.10.8 and earlier
43
- def initialize(*args)
44
- super
45
- @action = :install
46
- end