Permalink
Browse files

add recipe to bootstrap perlbrew

  • Loading branch information...
1 parent 7cf6e78 commit fe1718bf7862477a5c18526528481427f8578410 @xdg xdg committed Jan 6, 2012
Showing with 52 additions and 1 deletion.
  1. +22 −0 cookbooks/perlbrew/attributes/default.rb
  2. +30 −1 cookbooks/perlbrew/recipes/default.rb
@@ -0,0 +1,22 @@
+#
+# Author:: David A. Golden (<dagolden@cpan.org>)
+# Cookbook Name:: perlbrew
+# Attribute:: default
+#
+# Copyright 2012, David A. Golden
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+default['perlbrew']['perlbrew_root'] = '/opt/perlbrew'
+
@@ -2,7 +2,7 @@
# Cookbook Name:: perlbrew
# Recipe:: default
#
-# Copyright 2012, David Golden
+# Copyright 2012, David A. Golden
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -16,3 +16,32 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+
+prereqs = [ "build-essential", "perl", "curl" ]
+
+prereqs.each do |p|
+ package p
+end
+
+perlbrew_root = node['perlbrew']['perlbrew_root']
+perlbrew_bin = "#{perlbrew_root}/bin/perlbrew"
+
+# if we have perlbrew, upgrade it
+bash "perlbrew self-upgrade" do
+ command = "#{perlbrew_bin} self-upgrade"
+ environment ({'PERLBREW_ROOT' => perlbrew_root})
+ if ::File.exists?(perlbrew_bin)
+end
+
+# if not, install it
+remote_file "#{Chef::Config[:file_cache_path]}/perlbrew-install" do
+ source "http://install.perlbrew.pl"
+ mode "0644"
+ not_if ::File.exists?(perlbrew_bin)
+end
+
+bash "perlbrew-install" do
+ cwd Chef::Config[:file_cache_path]
+ environment ({'PERLBREW_ROOT' => perlbrew_root})
+ not_if ::File.exists?(perlbrew_bin)
+end

0 comments on commit fe1718b

Please sign in to comment.