Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Feature: First running version of centralized php-modules.ini generation

  • Loading branch information...
commit 797b0922facfc4cdd8e1e96ace5cde6ac43d00cc 1 parent f58d8f7
@fh fh authored
View
4 php-enchant/recipes/default.rb
@@ -2,8 +2,6 @@
package "libglib2.0-dev"
package "libenchant-dev"
-php_pecl "enchant"
-
php_pecl "enchant" do
- action :setup
+ action [ :install, :setup]
end
View
4 php-phar/files/default/phar.ini
@@ -1,4 +0,0 @@
-extension=phar.so
-detect_unicode = Off
-phar.readonly = Off
-phar.require_hash = Off
View
12 php-phar/recipes/configure.rb
@@ -1,4 +1,8 @@
-cookbook_file "/usr/local/etc/php/phar.ini" do
- source "phar.ini"
- mode "0644"
-end
+php_pecl "phar" do
+ config_directives {
+ "detect_unicode" => "Off",
+ "phar.readonly" => "Off",
+ "phar.require_hash" => "Off"
+ }
+ action :setup
+end
View
2  php-xdebug/attributes/default.rb
@@ -1,5 +1,5 @@
default["xdebug"] = {}
-default["xdebug"]["version"] = "latest"
+default["xdebug"]["version"] = nil
default["xdebug"]["config"] = {
"scream" => 1,
View
8 php-xdebug/recipes/configure.rb
@@ -1,8 +0,0 @@
-template "#{node["php-fpm"]["prefix"]}/etc/php/xdebug.ini" do
- source "xdebug.ini.erb"
- mode "0644"
- variables(
- :config => node["xdebug"]["config"],
- :prefix => node["php-fpm"]["prefix"]
- )
-end
View
13 php-xdebug/recipes/default.rb
@@ -1,11 +1,12 @@
include_recipe "php-fpm::source"
if node["xdebug"]["version"] == 'latest'
- xdebug_version = ""
-else
- xdebug_version = "-#{node["xdebug"]["version"]}"
+ xdebug_version = nil
end
-php_pecl "xdebug#{xdebug_version}"
-
-include_recipe "php-xdebug::configure"
+php_pecl "xdebug" do
+ version xdebug_version
+ zend_extensions ['xdebug.so']
+ config_directives node['xdebug']['config']
+ action [ :install, :setup ]
+end
View
83 php/providers/pecl.rb
@@ -1,10 +1,17 @@
-action :install do
+require 'chef/mixin/shell_out'
+#require 'chef/mixin/language'
+include Chef::Mixin::ShellOut
+action :install do
extension = new_resource.name
- so_file = "#{new_resource.ext_dir}/#{extension}.so"
-
- if !new_resource.version.empty?
- extension = "#{extension}-#{new_resource.version}"
+ version = new_resource.version
+
+ ext_dir = get_extension_dir()
+ ext_dir << ::File::SEPARATOR if ext_dir[-1].chr != ::File::SEPARATOR
+ so_file = "#{ext_dir}/#{extension}.so"
+
+ if !version.nil?
+ extension = "#{extension}-#{version}"
end
execute "pecl install #{extension}" do
@@ -17,6 +24,43 @@
end
+action :setup do
+ name = new_resource.name
+ ext_prefix = get_extension_dir()
+ ext_prefix << ::File::SEPARATOR if ext_prefix[-1].chr != ::File::SEPARATOR
+
+ files = get_extension_files(name)
+ if files.empty?
+ Chef::Log.debug('files list returned by pecl was empty, falling back to default')
+ files = [ext_prefix + name + '.so']
+ end
+
+ extensions = Hash[ files.map { |filepath|
+ rel_file = filepath.clone
+ rel_file.slice! ext_prefix if rel_file.start_with? ext_prefix
+
+ zend = new_resource.zend_extensions.include?(rel_file)
+
+ [ (zend ? filepath : rel_file) , zend ]
+ }]
+
+ template "#{node["php-fpm"]["prefix"]}/etc/php/#{name}.ini" do
+ source "extension.ini.erb"
+ cookbook "php"
+ owner "root"
+ group "root"
+ mode "0644"
+ variables(
+ :name => name,
+ :extensions => extensions,
+ :directives => new_resource.config_directives
+ )
+ end
+
+ new_resource.updated_by_last_action(true)
+
+end
+
action :compile do
if new_resource.source_dir.empty?
@@ -41,7 +85,7 @@
"phpize",
configure,
"make",
- "cp modules/#{extension}.so #{new_resource.ext_dir}",
+ "cp modules/#{extension}.so #{new_resource.source_dir}",
]
commands.each do |command|
@@ -55,22 +99,21 @@
end
-action :setup do
-
- package = new_resource.name
- ini_file = "#{new_resource.prefix}/etc/php/#{new_resource.name}.ini"
-
- if package == "xdebug"
- ::Chef::Log.debug("Need to use zend_extension")
- return
+def get_extension_dir()
+ @extension_dir ||= begin
+ p = shell_out("#{new_resource.prefix}/bin/php-config --extension-dir")
+ p.stdout.strip
end
+end
- execute "enable PHP extension #{package}" do
- command "echo 'extension=#{package}.so' >> #{ini_file}"
- not_if do
- ::File.exists?(ini_file)
- end
+def get_extension_files(name)
+ files = []
+
+ p = shell_out("pecl list-files #{name}")
+ p.stdout.each_line.grep(/^src\s+.*\.so$/i).each do |line|
+ files << line.split[1]
end
- new_resource.updated_by_last_action(true)
+ files
end
+
View
8 php/resources/pecl.rb
@@ -3,15 +3,15 @@
def initialize(*args)
super
@action = :install
- @version = ""
- @ext_dir = "#{node["php-fpm"]["prefix"]}/lib/php/extensions/no-debug-non-zts-20090626"
@prefix = node["php-fpm"]["prefix"]
end
attribute :prefix, :kind_of => String
-attribute :ext_dir, :kind_of => String
attribute :package, :kind_of => String, :name_attribute => true
-attribute :version, :kind_of => String
+attribute :version, :kind_of => String, :default => nil
attribute :config, :kind_of => Hash
attribute :source_dir, :kind_of => String
attribute :cflags, :kind_of => String
+attribute :config_directives, :kind_of => Hash, :default => {}
+attribute :zend_extensions, :kind_of => Array, :default => Array.new
+
View
7 php/templates/default/extension.ini.erb
@@ -0,0 +1,7 @@
+; configuration for php <%= @name %> module
+<% @extensions.each do |filepath, zend| -%>
+<%= 'zend_' if zend %>extension=<%= filepath %>
+<% end -%>
+<% @directives.each do |k,v| -%>
+<%= "#{@name}.#{k}=\"#{v}\"" %>
+<% end -%>
Please sign in to comment.
Something went wrong with that request. Please try again.