Skip to content

Commit 9b5872d

Browse files
author
Joshua Timberman
committed
Merge pull request sous-chefs#7 from gwaldo/master
Adding Windows support to the Perl cookbook (COOK-1765)
2 parents 9b88fe3 + ca4e23d commit 9b5872d

File tree

3 files changed

+77
-11
lines changed

3 files changed

+77
-11
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Requirements
1212
* Debian/Ubuntu/Mint
1313
* RHEL/CentOS/Scientific/Oracle/Fedora
1414
* ArchLinux
15+
* Windows
1516

1617
Attributes
1718
==========

attributes/default.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,25 @@
3030
default['perl']['packages'] = %w{ perl libperl-dev }
3131
when "arch"
3232
default['perl']['packages'] = %w{ perl perl-libwww }
33+
when "windows"
34+
default['perl']['maj_version'] = '5'
35+
default['perl']['min_version'] = '16'
36+
default['perl']['sub_version'] = '1.1'
37+
case node['kernel']['machine'].to_s
38+
when "x86_64"
39+
default['perl']['bitness'] = '64bit'
40+
else
41+
default['perl']['bitness'] = '32bit'
42+
end
3343
else
3444
default['perl']['packages'] = %w{ perl libperl-dev }
3545
end
3646

3747
default['perl']['cpanm']['url'] = 'https://raw.github.com/miyagawa/cpanminus/1.5015/cpanm'
3848
default['perl']['cpanm']['checksum'] = '8cb7b62b55a3043c4ccb'
3949
default['perl']['cpanm']['path'] = '/usr/local/bin/cpanm'
50+
51+
default['perl']['install_dir'] = 'C:\\perl\\'
52+
53+
54+

recipes/default.rb

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,66 @@
1717
# limitations under the License.
1818
#
1919

20-
node['perl']['packages'].each do |perl_pkg|
21-
package perl_pkg
22-
end
20+
unless node['platform'] == 'windows'
21+
node['perl']['packages'].each do |perl_pkg|
22+
package perl_pkg
23+
end
24+
25+
cpanm = node['perl']['cpanm'].to_hash
26+
root_group = (node[:platform] == "mac_os_x") ? "admin" : "root"
27+
remote_file cpanm['path'] do
28+
source cpanm['url']
29+
checksum cpanm['checksum']
30+
owner "root"
31+
group root_group
32+
mode 0755
33+
end
34+
else
35+
installer = "strawberry-perl-#{node['perl']['maj_version']}.#{node['perl']['min_version']}.#{node['perl']['sub_version']}-#{node['perl']['bitness']}.msi"
36+
37+
tempdir = "#{ENV['TEMP']}"
38+
39+
if tempdir.nil? || tempdir == ''
40+
tempdir = 'C:\\temp\\'
2341

24-
cpanm = node['perl']['cpanm'].to_hash
25-
root_group = (node[:platform] == "mac_os_x") ? "admin" : "root"
26-
remote_file cpanm['path'] do
27-
source cpanm['url']
28-
checksum cpanm['checksum']
29-
owner "root"
30-
group root_group
31-
mode 0755
42+
#directory 'C:\\temp\\' do
43+
directory "#{tempdir}" do
44+
action :create
45+
inherits true
46+
owner "administrator"
47+
group "administrators"
48+
end
49+
end
50+
51+
directory node['perl']['install_dir'] do
52+
action :create
53+
recursive true
54+
inherits true
55+
owner "administrator"
56+
group "administrators"
57+
end
58+
59+
remote_file "#{tempdir}\\#{installer}" do
60+
source "https://strawberry-perl.googlecode.com/files/#{installer}"
61+
action :create
62+
owner "administrator"
63+
group "administrators"
64+
mode 0774
65+
end
66+
67+
execute "Install StrawberryPerl" do
68+
command "msiexec /qn /i #{tempdir}\\#{installer} INSTALLDIR=#{node['perl']['install_dir']} PERL_PATH=YES"
69+
not_if { File.exists?("#{node['perl']['install_dir']}\\perl\\bin\\perl.exe") }
70+
end
71+
72+
execute "Add Perl to PATH" do
73+
command "setx /M path \"#{node['perl']['install_dir']}perl\\bin;%path%\""
74+
end
75+
76+
## Going to try the windows_path primitive
77+
## This appears to only Append to %PATH%, when I want it to Prepend
78+
#windows_path "#{node['perl']['install_dir']}perl\\bin" do
79+
# action :add
80+
#end
81+
3282
end

0 commit comments

Comments
 (0)