Skip to content

Commit

Permalink
add recipe to bootstrap perlbrew
Browse files Browse the repository at this point in the history
  • Loading branch information
xdg committed Jan 6, 2012
1 parent 7cf6e78 commit fe1718b
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
22 changes: 22 additions & 0 deletions cookbooks/perlbrew/attributes/default.rb
Original file line number Original file line Diff line number Diff line change
@@ -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'

31 changes: 30 additions & 1 deletion cookbooks/perlbrew/recipes/default.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Cookbook Name:: perlbrew # Cookbook Name:: perlbrew
# Recipe:: default # Recipe:: default
# #
# Copyright 2012, David Golden # Copyright 2012, David A. Golden
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
Expand All @@ -16,3 +16,32 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # 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.