Sha256: 6c9d5c17be63dff8b331face60d106dc0d620ba6a125b900e1a386e8f590c43b

Contents?: true

Size: 1.99 KB

Versions: 2

Compression:

Stored size: 1.99 KB

Contents

action :create do
  unless exists?
    Chef::Log.info("Installing PHP #{@new_resource.version} with php-build")
    new_resource  = @new_resource
    phpbuild_path = "#{node.travis_build_environment.home}/.php-build"
    version       = new_resource.version
    target_path   = "#{new_resource.path}/#{version}"
    pear_option   = @new_resource.with_pear ? "--pear" : ""

    bash "install PHP #{version} with php-build" do
      user        new_resource.owner
      group       new_resource.group
      # LDFLAGS are necessary to solve PHP 5.3 issues with the intl extension, which is crucial
      # for Symfony among other projects. MK.
      environment Hash["HOME" => node.travis_build_environment.home, "LDFLAGS" => "-lstdc++"]
      cwd         "#{phpbuild_path}/bin"
      ini_suffix  = version < '5.3' ? 'dist' : 'development'
      code <<-EOF
      PHP_VERSION=#{version} ./php-build -i #{ini_suffix} #{pear_option} #{version} #{target_path}
      EOF
    end

    template "#{target_path}/etc/conf.d/travis.ini" do
      owner    new_resource.owner
      group    new_resource.group
      cookbook "phpbuild"
      source   "travis.ini.erb"
      variables(
        :timezone     => node.phpbuild.custom.php_ini.timezone,
        :memory_limit => node.phpbuild.custom.php_ini.memory_limit
      )
    end

    new_resource.updated_by_last_action(true)
  end
end

action :delete do
  if exists?
    Chef::Log.info("Uninstalling PHP #{@new_resource.version} from php-build")
    phpbuild_path = "#{node.travis_build_environment.home}/.php-build"
    target_path   = "#{@new_resource.path}/#{@new_resource.version}"

    FileUtils.rm_rf(target_path)
    new_resource.updated_by_last_action(true)
  end
end

private
def exists?
  phpbuild_path = "#{node.travis_build_environment.home}/.php-build"
  target_path   = "#{@new_resource.path}/#{@new_resource.version}"

  ::File.exist?(target_path) && ::File.directory?(target_path) \
    && ::File.exists?("#{target_path}/bin/php") && ::File.exists?("#{target_path}/bin/phpunit")
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
ciborg-3.0.0 chef/travis-cookbooks/ci_environment/phpbuild/providers/build.rb
lobot-2.1.0 chef/travis-cookbooks/ci_environment/phpbuild/providers/build.rb