Skip to content

Commit 5e86c37

Browse files
committed
Adding support for Windows to the Perl cookbook.
adding some handlers for installing Strawberry Perl on Windows escaping backslashes is important missing 'do' keywords changing :create_if_missing to :create; apparently that's been deprecated... adding owner, group, and mode. They're in Unix-talk, but hopefully it'll get chef to stop complaining removing a single. damn. period. confirmed that perl gets installed in Windows, but ignored the install location parameter. adding the proper flag to install to the specified directory, and prepending the new dir to the PATH adding PATH statement to the install block closing quotes fixing the path again. Use the right directory delimiter. using setx instead of set. May be problems due to required/escaped quotes backslashes for Windows paths... Moving the path modifier to a separate action, and trying the windows_path primitive fixing paths and going back to my prepend method I was missing a 'do' updating metadata and readme after completing install of Strawberry Perl on Windows.
1 parent cad84b2 commit 5e86c37

File tree

4 files changed

+70
-12
lines changed

4 files changed

+70
-12
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+

metadata.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
license "Apache 2.0"
44
description "Installs perl and provides a define for maintaining CPAN modules"
55
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
6-
version "1.0.2"
6+
version "1.0.3"
77

88
recipe "perl", "Installs perl and adds a provider to install cpan modules"
99

recipes/default.rb

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,58 @@
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
2324

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
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+
directory 'C:\\temp\\' do
38+
action :create
39+
owner "administrator"
40+
group "administrators"
41+
mode 0774
42+
end
43+
44+
directory node['perl']['install_dir'] do
45+
action :create
46+
owner "administrator"
47+
group "administrators"
48+
mode 0774
49+
end
50+
51+
remote_file "C:\\temp\\#{installer}" do
52+
source "https://strawberry-perl.googlecode.com/files/#{installer}"
53+
action :create
54+
owner "administrator"
55+
group "administrators"
56+
mode 0774
57+
end
58+
59+
execute "Install StrawberryPerl" do
60+
command "msiexec /qn /i C:\\temp\\#{installer} INSTALLDIR=#{node['perl']['install_dir']} PERL_PATH=YES"
61+
not_if { File.exists?("#{node['perl']['install_dir']}\\perl\\bin\\perl.exe") }
62+
end
63+
64+
execute "Add Perl to PATH" do
65+
command "setx /M path \"#{node['perl']['install_dir']}perl\\bin;%path%\""
66+
end
67+
68+
## Going to try the windows_path primitive
69+
## This appears to only Append to %PATH%, when I want it to Prepend
70+
#windows_path "#{node['perl']['install_dir']}perl\\bin" do
71+
# action :add
72+
#end
73+
3274
end

0 commit comments

Comments
 (0)