From 5379f73d5b088975050fb47c5cd32d7a98cef749 Mon Sep 17 00:00:00 2001 From: Franz Pletz Date: Fri, 9 Jan 2015 18:24:57 +0100 Subject: [PATCH] Add support to load pecl extensions as zend extensions Fixes #52. --- manifests/extension.pp | 19 +++++++++++++++++-- spec/defines/extension_spec.rb | 25 +++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/manifests/extension.pp b/manifests/extension.pp index 1c993c49..4edc94dd 100644 --- a/manifests/extension.pp +++ b/manifests/extension.pp @@ -20,9 +20,13 @@ # The pecl source channel to install pecl package from # # [*header_packages*] -# system packages dependecies to install for extensions (e.g. for +# System packages dependecies to install for extensions (e.g. for # memcached libmemcached-dev on debian) # +# [*zend*] +# Boolean parameter, whether to load extension as zend_extension. +# This can only be set for pecl modules. Defaults to false. +# # [*settings*] # Nested hash of global config parameters for php.ini # @@ -43,6 +47,7 @@ $package_prefix = $php::package_prefix, $header_packages = [], $compiler_packages = $php::params::compiler_packages, + $zend = false, $settings = {}, ) { @@ -53,6 +58,7 @@ validate_string($ensure) validate_string($package_prefix) validate_array($header_packages) + validate_bool($zend) if $provider != 'none' { if $provider == 'pecl' { @@ -87,9 +93,18 @@ } } + if $provider != 'pecl' and $zend { + fail('You can only use the zend parameter for pecl PHP extensions!') + } + + $extension_key = $zend ? { + true => 'zend_extension', + false => 'extension', + } + $lowercase_title = downcase($title) $real_settings = $provider ? { - 'pecl' => deep_merge({'extension' => "${name}.so"}, $settings), + 'pecl' => deep_merge({ "${extension_key}" => "${name}.so" }, $settings), default => $settings } $php_settings_file = "${php::params::config_root_ini}/${lowercase_title}.ini" diff --git a/spec/defines/extension_spec.rb b/spec/defines/extension_spec.rb index 93806278..7722fd5b 100644 --- a/spec/defines/extension_spec.rb +++ b/spec/defines/extension_spec.rb @@ -25,6 +25,15 @@ } end + context 'non-pecl extensions cannot be configured as zend' do + let(:title) { 'xdebug' } + let(:params) {{ + :zend => true, + }} + + it { expect { should raise_error(Puppet::Error) }} + end + context 'pecl installation' do let(:title) { 'json' } let(:params) {{ @@ -50,6 +59,22 @@ } end + context 'pecl extensions can be configured as zend' do + let(:title) { 'xdebug' } + let(:params) {{ + :provider => 'pecl', + :zend => true + }} + + it { + should contain_php__config('xdebug').with({ + :config => { + 'zend_extension' => 'xdebug.so' + } + }) + } + end + context 'on Debian' do let(:facts) { { :osfamily => 'Debian',