include_recipe "perlbrew"

home = node.travis_build_environment.home
brew = "source #{home}/perl5/perlbrew/etc/bashrc && perlbrew"
env  = { 'HOME' => home }
user = node.travis_build_environment.user

setup = lambda do |bash|
  bash.user user
  bash.environment env
end

bash "install cpanm" do
  setup.call(self)
  code "#{brew} install-cpanm"
  not_if "ls #{home}/perl5/perlbrew/bin | grep cpanm"
end

node.perlbrew.perls.each do |pl|
  args = pl[:arguments].to_s
  args << " --notest"

  bash "installing #{pl[:version]} as #{pl[:name]} with Perlbrew arguments: #{args}" do
    setup.call(self)
    code   "#{brew} install #{pl[:version]} --as #{pl[:name]} #{args}"
    not_if "ls #{home}/perl5/perlbrew/perls | grep #{pl[:name]}"
  end
end


include_recipe "perlbrew"

home = node.travis_build_environment.home
brew = "source #{home}/perl5/perlbrew/etc/bashrc && perlbrew"
env  = { 'HOME' => home }
user = node.travis_build_environment.user

setup = lambda do |bash|
  bash.user user
  bash.environment env
end

bash "install cpanm" do
  setup.call(self)
  code "#{brew} install-cpanm"
  not_if "ls #{home}/perl5/perlbrew/bin | grep cpanm"
end

node.perlbrew.perls.each do |pl|
  args = pl[:arguments].to_s
  args << " --notest"

  bash "installing #{pl[:version]} as #{pl[:name]} with Perlbrew arguments: #{args}" do
    setup.call(self)
    code   "#{brew} install #{pl[:version]} --as #{pl[:name]} #{args}"
    not_if "ls #{home}/perl5/perlbrew/perls | grep #{pl[:name]}"
  end

  bash "preinstall Dist::Zilla" do
    setup.call(self)
    code   "#{brew} use #{pl[:name]} && cpanm Dist::Zilla --force"
  end
end


Revert "Screw Dist::Zilla, it takes forever to install and fails VM provisioning 3 times out of 4"
Revert "Screw Dist::Zilla, it takes forever to install and fails VM provisioning 3 times out of 4"

This reverts commit c246ca59f87d68ef917e3dfadaaf475e9d600f18.

Lets give it another shot with mirroring.
