Initial Chef repository

This commit is contained in:
Greg Karékinian
2015-07-21 19:45:23 +02:00
parent 7e5401fc71
commit ee4079fa85
1151 changed files with 185163 additions and 0 deletions

139
cookbooks/php/CHANGELOG.md Normal file
View File

@@ -0,0 +1,139 @@
php Cookbook CHANGELOG
======================
This file is used to list changes made in each version of the php cookbook.
v1.5.0 (2014-10-06)
-------------------
- Adding package_options attribute, utilizing in package resource
v1.4.6 (2014-03-19)
-------------------
- [COOK-4436] - Test this cookbook, not yum. Also test Fedora 20.
- [COOK-4427] - Add oracle as supported operating system
v1.4.4 (2014-03-12)
-------------------
- [COOK-4393] - Fix convergence bug in source install
v1.4.2 (2014-02-27)
-------------------
[COOK-4300] - Simplified and fixed pear/pecl logic. [Fixes #56 / #57]
v1.4.0 (2014-02-27)
-------------------
[COOK-3639] - Allow users to specify php.ini source template
v1.3.14 (2014-02-21)
--------------------
### Bug
- **[COOK-4186](https://tickets.opscode.com/browse/COOK-4186)** - Upgrade_package concatenates an empty version string when version is not set or is empty.
v1.3.12 (2014-01-28)
--------------------
Fix github issue 'Cannot find a resource for preferred_state'
v1.3.10
-------
Fixing my stove
v1.3.8
------
Version bump to ensure artifact sanity
v1.3.6
------
Version bump for toolchain
v1.3.4
------
Adding platform_family check to include_recipe in source.rb
v1.3.2
------
Fixing style cops. Updating test harness
v1.3.0
------
### Bug
- **[COOK-3479](https://tickets.opscode.com/browse/COOK-3479)** - Added Windows support to PHP
- **[COOK-2909](https://tickets.opscode.com/browse/COOK-2909)** - Warnings about Chef::Exceptions::ShellCommandFailed is deprecated
v1.2.6
------
### Bug
- **[COOK-3628](https://tickets.opscode.com/browse/COOK-3628)** - Fix PHP download URL
- **[COOK-3568](https://tickets.opscode.com/browse/COOK-3568)** - Fix Test Kitchen tests
- **[COOK-3402](https://tickets.opscode.com/browse/COOK-3402)** - When the `ext_dir` setting is present, configure php properly for the source recipe
- **[COOK-2926](https://tickets.opscode.com/browse/COOK-2926)** - Fix pear package detection when installing specific version
v1.2.4
------
### Improvement
- **[COOK-3047](https://tickets.opscode.com/browse/COOK-3047)** - Sort directives in `php.ini`
- **[COOK-2928](https://tickets.opscode.com/browse/COOK-2928)** - Abstract `php.ini` directives into variables
### Bug
- **[COOK-2378](https://tickets.opscode.com/browse/COOK-2378)** - Fix `php_pear` for libevent
v1.2.2
------
### Bug
- [COOK-3050]: `lib_dir` declared in wrong place for redhat
- [COOK-3102]: remove fileinfo recipe from php cookbook
### Improvement
- [COOK-3101]: use a method to abstract range of "el 5" versions in php recipes
v1.2.0
------
### Improvement
- [COOK-2516]: Better support for SUSE distribution for php cookbook
- [COOK-3035]: update php::source to install 5.4.15 by default
### Bug
- [COOK-2463]: PHP PEAR Provider Installs Most Recent Version, Without Respect to Preferred State
- [COOK-2514]: php_pear: does not handle more exotic version strings
v1.1.8
------
- [COOK-1998] - Enable override of PHP packages in attributes
v1.1.6
------
- [COOK-2324] - adds Oracle linux support
v1.1.4
------
- [COOK-2106] - `php_pear` cannot find available packages
v1.1.2
------
- [COOK-1803] - use better regexp to match package name
- [COOK-1926] - support Amazon linux
v1.1.0
------
- [COOK-543] - php.ini template should be configurable
- [COOK-1067] - support for PECL zend extensions
- [COOK-1193] - update package names for EPEL 6
- [COOK-1348] - rescue Mixlib::ShellOut::ShellCommandFailed (chef 0.10.10)
- [COOK-1465] - fix pear extension template
v1.0.2
------
- [COOK-993] Add mhash-devel to centos php source libs
- [COOK-989] - bump version of php to 5.3.10
- Also download the .tar.gz instead of .tar.bz2 as bzip2 may not be in the base OS (e.g., CentOS 6 minimal)

347
cookbooks/php/README.md Normal file
View File

@@ -0,0 +1,347 @@
php Cookbook
============
Installs and configures PHP 5.3 and the PEAR package management system. Also includes LWRPs for managing PEAR (and PECL) packages along with PECL channels.
Requirements
------------
### Platforms
- Debian, Ubuntu
- CentOS, Red Hat, Fedora, Amazon Linux
- Microsoft Windows
### Cookbooks
- build-essential
- xml
- mysql
These cookbooks are only used when building PHP from source.
Attributes
----------
- `node['php']['install_method']` = method to install php with, default `package`.
- `node['php']['directives']` = Hash of directives and values to append to `php.ini`, default `{}`.
The file also contains the following attribute types:
* platform specific locations and settings.
* source installation settings
Resource/Provider
-----------------
This cookbook includes LWRPs for managing:
- PEAR channels
- PEAR/PECL packages
### `php_pear_channel`
[PEAR Channels](http://pear.php.net/manual/en/guide.users.commandline.channels.php) are alternative sources for PEAR packages. This LWRP provides and easy way to manage these channels.
#### Actions
- :discover: Initialize a channel from its server.
- :add: Add a channel to the channel list, usually only used to add private channels. Public channels are usually added using the `:discover` action
- :update: Update an existing channel
- :remove: Remove a channel from the List
#### Attribute Parameters
- channel_name: name attribute. The name of the channel to discover
- channel_xml: the channel.xml file of the channel you are adding
#### Examples
```ruby
# discover the horde channel
php_pear_channel "pear.horde.org" do
action :discover
end
# download xml then add the symfony channel
remote_file "#{Chef::Config[:file_cache_path]}/symfony-channel.xml" do
source "http://pear.symfony-project.com/channel.xml"
mode 0644
end
php_pear_channel "symfony" do
channel_xml "#{Chef::Config[:file_cache_path]}/symfony-channel.xml"
action :add
end
# update the main pear channel
php_pear_channel 'pear.php.net' do
action :update
end
# update the main pecl channel
php_pear_channel 'pecl.php.net' do
action :update
end
```
### `php_pear`
[PEAR](http://pear.php.net/) is a framework and distribution system for reusable PHP components. [PECL](http://pecl.php.net/) is a repository for PHP Extensions. PECL contains C extensions for compiling into PHP. As C programs, PECL extensions run more efficiently than PEAR packages. PEARs and PECLs use the same packaging and distribution system. As such this LWRP is clever enough to abstract away the small differences and can be used for managing either. This LWRP also creates the proper module .ini file for each PECL extension at the correct location for each supported platform.
#### Actions
- :install: Install a pear package - if version is provided, install that specific version
- :upgrade: Upgrade a pear package - if version is provided, upgrade to that specific version
- :remove: Remove a pear package
- :purge: Purge a pear package (this usually entails removing configuration files as well as the package itself). With pear packages this behaves the same as `:remove`
#### Attribute Parameters
- package_name: name attribute. The name of the pear package to install
- version: the version of the pear package to install/upgrade. If no version is given latest is assumed.
- preferred_state: PEAR by default installs stable packages only, this allows you to install pear packages in a devel, alpha or beta state
- directives: extra extension directives (settings) for a pecl. on most platforms these usually get rendered into the extension's .ini file
- zend_extensions: extension filenames which should be loaded with zend_extension.
- options: Add additional options to the underlying pear package command
#### Examples
```ruby
# upgrade a pear
php_pear "XML_RPC" do
action :upgrade
end
# install a specific version
php_pear "XML_RPC" do
version "1.5.4"
action :install
end
# install the mongodb pecl
php_pear "mongo" do
action :install
end
# install the xdebug pecl
php_pear "xdebug" do
# Specify that xdebug.so must be loaded as a zend extension
zend_extensions ['xdebug.so']
action :install
end
# install apc pecl with directives
php_pear "apc" do
action :install
directives(:shm_size => 128, :enable_cli => 1)
end
# install the beta version of Horde_Url
# from the horde channel
hc = php_pear_channel "pear.horde.org" do
action :discover
end
php_pear "Horde_Url" do
preferred_state "beta"
channel hc.channel_name
action :install
end
# install the YAML pear from the symfony project
sc = php_pear_channel "pear.symfony-project.com" do
action :discover
end
php_pear "YAML" do
channel sc.channel_name
action :install
end
```
Recipes
-------
### default
Include the default recipe in a run list, to get `php`. By default `php` is installed from packages but this can be changed by using the `install_method` attribute.
### package
This recipe installs PHP from packages.
### source
This recipe installs PHP from source.
Deprecated Recipes
------------------
The following recipes are deprecated and will be removed from a future version of this cookbook.
- `module_apc`
- `module_curl`
- `module_fileinfo`
- `module_fpdf`
- `module_gd`
- `module_ldap`
- `module_memcache`
- `module_mysql`
- `module_pgsql`
- `module_sqlite3`
The installation of the php modules in these recipes can now be accomplished by installing from a native package or via the new php_pear LWRP. For example, the functionality of the `module_memcache` recipe can be enabled in the following ways:
```ruby
# using apt
package "php5-memcache" do
action :install
end
# using pear LWRP
php_pear "memcache" do
action :install
end
```
Usage
-----
Simply include the `php` recipe where ever you would like php installed. To install from source override the `node['php']['install_method']` attribute with in a role:
```ruby
name "php"
description "Install php from source"
override_attributes(
"php" => {
"install_method" => "source"
}
)
run_list(
"recipe[php]"
)
```
Development
-----------
This section details "quick development" steps. For a detailed explanation, see [[Contributing.md]].
1. Clone this repository from GitHub:
$ git clone git@github.com:opscode-cookbooks/php.git
2. Create a git branch
$ git checkout -b my_bug_fix
3. Install dependencies:
$ bundle install
4. Make your changes/patches/fixes, committing appropiately
5. **Write tests**
6. Run the tests:
- `bundle exec foodcritic -f any .`
- `bundle exec rspec`
- `bundle exec rubocop`
- `bundle exec kitchen test`
In detail:
- Foodcritic will catch any Chef-specific style errors
- RSpec will run the unit tests
- Rubocop will check for Ruby-specific style errors
- Test Kitchen will run and converge the recipes
License & Authors
-----------------
- Author:: Seth Chisamore (<schisamo@opscode.com>)
- Author:: Joshua Timberman (<joshua@opscode.com>)
- Author:: Julian C. Dunn (<jdunn@getchef.com>)
```text
Copyright:: 2013, Chef Software, Inc.
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.
```
Note: This cookbook contains a modified copy of `go-phar.pear` for use on the
Microsoft Windows platform only to correct an (upstream bug)[http://pear.php.net/bugs/bug.php?id=16644]. The original
`go-pear.phar` is licensed under the (PHP License version 2.02)[http://www.php.net/license/2_02.txt]:
```
--------------------------------------------------------------------
The PHP License, version 2.02
Copyright (c) 1999 - 2002 The PHP Group. All rights reserved.
--------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, is permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
3. The name "PHP" must not be used to endorse or promote products
derived from this software without prior permission from the
PHP Group. This does not apply to add-on libraries or tools
that work in conjunction with PHP. In such a case the PHP
name may be used to indicate that the product supports PHP.
4. The PHP Group may publish revised and/or new versions of the
license from time to time. Each version will be given a
distinguishing version number.
Once covered code has been published under a particular version
of the license, you may always continue to use it under the
terms of that version. You may also choose to use such covered
code under the terms of any subsequent version of the license
published by the PHP Group. No one other than the PHP Group has
the right to modify the terms applicable to covered code created
under this License.
5. Redistributions of any form whatsoever must retain the following
acknowledgment:
"This product includes PHP, freely available from
http://www.php.net/".
6. The software incorporates the Zend Engine, a product of Zend
Technologies, Ltd. ("Zend"). The Zend Engine is licensed to the
PHP Association (pursuant to a grant from Zend that can be
found at http://www.php.net/license/ZendGrant/) for
distribution to you under this license agreement, only as a
part of PHP. In the event that you separate the Zend Engine
(or any portion thereof) from the rest of the software, or
modify the Zend Engine, or any portion thereof, your use of the
separated or modified Zend Engine software shall not be governed
by this license, and instead shall be governed by the license
set forth at http://www.zend.com/license/ZendLicense/.
THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP
DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------
This software consists of voluntary contributions made by many
individuals on behalf of the PHP Group.
The PHP Group can be contacted via Email at group@php.net.
For more information on the PHP Group and the PHP project,
please see <http://www.php.net>.
```

View File

@@ -0,0 +1,126 @@
#
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Cookbook Name:: php
# Attribute:: default
#
# Copyright 2011, Opscode, Inc.
#
# 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.
#
lib_dir = 'lib'
default['php']['install_method'] = 'package'
default['php']['directives'] = {}
default['php']['bin'] = 'php'
default['php']['pear'] = 'pear'
default['php']['pecl'] = 'pecl'
case node['platform_family']
when 'rhel', 'fedora'
lib_dir = node['kernel']['machine'] =~ /x86_64/ ? 'lib64' : 'lib'
default['php']['conf_dir'] = '/etc'
default['php']['ext_conf_dir'] = '/etc/php.d'
default['php']['fpm_user'] = 'nobody'
default['php']['fpm_group'] = 'nobody'
default['php']['ext_dir'] = "/usr/#{lib_dir}/php/modules"
if node['platform_version'].to_f < 6
default['php']['packages'] = %w{ php53 php53-devel php53-cli php-pear }
else
default['php']['packages'] = %w{ php php-devel php-cli php-pear }
end
when 'debian'
default['php']['conf_dir'] = '/etc/php5/cli'
default['php']['ext_conf_dir'] = '/etc/php5/conf.d'
default['php']['fpm_user'] = 'www-data'
default['php']['fpm_group'] = 'www-data'
default['php']['packages'] = %w{ php5-cgi php5 php5-dev php5-cli php-pear }
when 'suse'
default['php']['conf_dir'] = '/etc/php5/cli'
default['php']['ext_conf_dir'] = '/etc/php5/conf.d'
default['php']['fpm_user'] = 'wwwrun'
default['php']['fpm_group'] = 'www'
default['php']['packages'] = %w{ apache2-mod_php5 php5-pear }
lib_dir = node['kernel']['machine'] =~ /x86_64/ ? 'lib64' : 'lib'
when 'windows'
default['php']['windows']['msi_name'] = 'PHP 5.3.28'
default['php']['windows']['msi_source'] = 'http://windows.php.net/downloads/releases/php-5.3.28-nts-Win32-VC9-x86.msi'
default['php']['bin'] = 'php.exe'
default['php']['conf_dir'] = 'C:\Program Files (x86)\PHP'
default['php']['ext_conf_dir'] = node['php']['conf_dir']
# These extensions are installed by default by the GUI MSI
default['php']['packages'] = %w{ cgi ScriptExecutable PEAR
iis4FastCGI ext_php_bz2 ext_php_curl
ext_php_exif ext_php_gd2 ext_php_gettext
ext_php_gmp ext_php_imap ext_php_mbstring
ext_php_mysql ext_php_mysqli ext_php_openssl
ext_php_pdo_mysql ext_php_pdo_odbc ext_php_pdo_sqlite
ext_php_pgsql ext_php_soap ext_php_sockets
ext_php_sqlite3 ext_php_tidy ext_php_xmlrpc
}
default['php']['package_options'] = "" # Use this to customise your yum or apt command
default['php']['pear'] = 'pear.bat'
default['php']['pecl'] = 'pecl.bat'
else
default['php']['conf_dir'] = '/etc/php5/cli'
default['php']['ext_conf_dir'] = '/etc/php5/conf.d'
default['php']['fpm_user'] = 'www-data'
default['php']['fpm_group'] = 'www-data'
default['php']['packages'] = %w{ php5-cgi php5 php5-dev php5-cli php-pear }
end
default['php']['url'] = 'http://us1.php.net/get'
default['php']['version'] = '5.5.9'
default['php']['checksum'] = '378de162efdaeeb725ed38d7fe956c9f0b9084ff'
default['php']['prefix_dir'] = '/usr/local'
default['php']['configure_options'] = %W{--prefix=#{php['prefix_dir']}
--with-libdir=#{lib_dir}
--with-config-file-path=#{php['conf_dir']}
--with-config-file-scan-dir=#{php['ext_conf_dir']}
--with-pear
--enable-fpm
--with-fpm-user=#{php['fpm_user']}
--with-fpm-group=#{php['fpm_group']}
--with-zlib
--with-openssl
--with-kerberos
--with-bz2
--with-curl
--enable-ftp
--enable-zip
--enable-exif
--with-gd
--enable-gd-native-ttf
--with-gettext
--with-gmp
--with-mhash
--with-iconv
--with-imap
--with-imap-ssl
--enable-sockets
--enable-soap
--with-xmlrpc
--with-libevent-dir
--with-mcrypt
--enable-mbstring
--with-t1lib
--with-mysql
--with-mysqli=/usr/bin/mysql_config
--with-mysql-sock
--with-sqlite3
--with-pdo-mysql
--with-pdo-sqlite}
default['php']['ini']['template'] = "php.ini.erb"
default['php']['ini']['cookbook'] = "php"

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,23 @@
#
# Author:: Joshua Timberman (<joshua@opscode.com>)
# Cookbook Name:: php
# Libraries:: helpers
#
# Copyright 2013, Opscode, Inc.
#
# 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.
#
def el5_range
(0..99).to_a.map { |i| "5.#{i}" }
end

View File

@@ -0,0 +1,57 @@
{
"name": "php",
"version": "1.5.0",
"description": "Installs and maintains php and php modules",
"long_description": "",
"maintainer": "Opscode, Inc.",
"maintainer_email": "cookbooks@opscode.com",
"license": "Apache 2.0",
"platforms": {
"debian": ">= 0.0.0",
"ubuntu": ">= 0.0.0",
"centos": ">= 0.0.0",
"redhat": ">= 0.0.0",
"fedora": ">= 0.0.0",
"scientific": ">= 0.0.0",
"amazon": ">= 0.0.0",
"windows": ">= 0.0.0",
"oracle": ">= 0.0.0"
},
"dependencies": {
"build-essential": ">= 0.0.0",
"xml": ">= 0.0.0",
"mysql": ">= 0.0.0",
"yum-epel": ">= 0.0.0",
"windows": ">= 0.0.0",
"iis": ">= 0.0.0"
},
"recommendations": {
},
"suggestions": {
},
"conflicting": {
},
"providing": {
},
"replacing": {
},
"attributes": {
},
"groupings": {
},
"recipes": {
"php": "Installs php",
"php::package": "Installs php using packages.",
"php::source": "Installs php from source.",
"php::module_apc": "Install the php5-apc package",
"php::module_curl": "Install the php5-curl package",
"php::module_fileinfo": "Install the php5-fileinfo package",
"php::module_fpdf": "Install the php-fpdf package",
"php::module_gd": "Install the php5-gd package",
"php::module_ldap": "Install the php5-ldap package",
"php::module_memcache": "Install the php5-memcache package",
"php::module_mysql": "Install the php5-mysql package",
"php::module_pgsql": "Install the php5-pgsql packag",
"php::module_sqlite3": "Install the php5-sqlite3 package"
}
}

31
cookbooks/php/metadata.rb Normal file
View File

@@ -0,0 +1,31 @@
name 'php'
maintainer 'Opscode, Inc.'
maintainer_email 'cookbooks@opscode.com'
license 'Apache 2.0'
description 'Installs and maintains php and php modules'
version '1.5.0'
depends 'build-essential'
depends 'xml'
depends 'mysql'
depends 'yum-epel'
depends 'windows'
depends 'iis'
%w{ debian ubuntu centos redhat fedora scientific amazon windows oracle }.each do |os|
supports os
end
recipe 'php', 'Installs php'
recipe 'php::package', 'Installs php using packages.'
recipe 'php::source', 'Installs php from source.'
recipe 'php::module_apc', 'Install the php5-apc package'
recipe 'php::module_curl', 'Install the php5-curl package'
recipe 'php::module_fileinfo', 'Install the php5-fileinfo package'
recipe 'php::module_fpdf', 'Install the php-fpdf package'
recipe 'php::module_gd', 'Install the php5-gd package'
recipe 'php::module_ldap', 'Install the php5-ldap package'
recipe 'php::module_memcache', 'Install the php5-memcache package'
recipe 'php::module_mysql', 'Install the php5-mysql package'
recipe 'php::module_pgsql', 'Install the php5-pgsql packag'
recipe 'php::module_sqlite3', 'Install the php5-sqlite3 package'

View File

@@ -0,0 +1,280 @@
#
# Author:: Seth Chisamore <schisamo@opscode.com>
# Cookbook Name:: php
# Provider:: pear_package
#
# Copyright:: 2011, Opscode, Inc <legal@opscode.com>
#
# 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.
#
require 'chef/mixin/shell_out'
require 'chef/mixin/language'
include Chef::Mixin::ShellOut
# the logic in all action methods mirror that of
# the Chef::Provider::Package which will make
# refactoring into core chef easy
def whyrun_supported?
true
end
action :install do
# If we specified a version, and it's not the current version, move to the specified version
install_version = @new_resource.version unless @new_resource.version.nil? || @new_resource.version == @current_resource.version
# If it's not installed at all or an upgrade, install it
if install_version || @current_resource.version.nil?
description = "install package #{@new_resource} #{install_version}"
converge_by(description) do
info_output = "Installing #{@new_resource}"
info_output << " version #{install_version}" if install_version && !install_version.empty?
Chef::Log.info(info_output)
status = install_package(@new_resource.package_name, install_version)
end
end
end
action :upgrade do
if @current_resource.version != candidate_version
orig_version = @current_resource.version || 'uninstalled'
description = "upgrade package #{@new_resource} version from #{orig_version} to #{candidate_version}"
converge_by(description) do
Chef::Log.info("Upgrading #{@new_resource} version from #{orig_version} to #{candidate_version}")
status = upgrade_package(@new_resource.package_name, candidate_version)
end
end
end
action :remove do
if removing_package?
description = "remove package #{@new_resource}"
converge_by(description) do
Chef::Log.info("Removing #{@new_resource}")
remove_package(@current_resource.package_name, @new_resource.version)
end
else
end
end
action :purge do
if removing_package?
description = "purge package #{@new_resource}"
converge_by(description) do
Chef::Log.info("Purging #{@new_resource}")
purge_package(@current_resource.package_name, @new_resource.version)
end
end
end
def removing_package?
if @current_resource.version.nil?
false # nothing to remove
elsif @new_resource.version.nil?
true # remove any version of a package
elsif @new_resource.version == @current_resource.version
true # remove the version we have
else
false # we don't have the version we want to remove
end
end
def expand_options(options)
options ? " #{options}" : ''
end
# these methods are the required overrides of
# a provider that extends from Chef::Provider::Package
# so refactoring into core Chef should be easy
def load_current_resource
@current_resource = Chef::Resource::PhpPear.new(@new_resource.name)
@current_resource.package_name(@new_resource.package_name)
@bin = node['php']['pear']
if pecl?
Chef::Log.debug("#{@new_resource} smells like a pecl...installing package in Pecl mode.")
@bin = node['php']['pecl']
end
Chef::Log.debug("#{@current_resource}: Installed version: #{current_installed_version} Candidate version: #{candidate_version}")
unless current_installed_version.nil?
@current_resource.version(current_installed_version)
Chef::Log.debug("Current version is #{@current_resource.version}") if @current_resource.version
end
@current_resource
end
def current_installed_version
@current_installed_version ||= begin
v = nil
version_check_cmd = "#{@bin} -d "
version_check_cmd << " preferred_state=#{can_haz(@new_resource, "preferred_state")}"
version_check_cmd << " list#{expand_channel(can_haz(@new_resource, "channel"))}"
p = shell_out(version_check_cmd)
response = nil
response = grep_for_version(p.stdout, @new_resource.package_name) if p.stdout =~ /\.?Installed packages/i
response
end
end
def candidate_version
@candidate_version ||= begin
candidate_version_cmd = "#{@bin} -d "
candidate_version_cmd << "preferred_state=#{can_haz(@new_resource, "preferred_state")}"
candidate_version_cmd << " search#{expand_channel(can_haz(@new_resource, "channel"))}"
candidate_version_cmd << "#{@new_resource.package_name}"
p = shell_out(candidate_version_cmd)
response = nil
response = grep_for_version(p.stdout, @new_resource.package_name) if p.stdout =~ /\.?Matched packages/i
response
end
end
def install_package(name, version)
command = "echo \"\r\" | #{@bin} -d"
command << " preferred_state=#{can_haz(@new_resource, "preferred_state")}"
command << " install -a#{expand_options(@new_resource.options)}"
command << " #{prefix_channel(can_haz(@new_resource, "channel"))}#{name}"
command << "-#{version}" if version && !version.empty?
pear_shell_out(command)
manage_pecl_ini(name, :create, can_haz(@new_resource, 'directives'), can_haz(@new_resource, 'zend_extensions')) if pecl?
end
def upgrade_package(name, version)
command = "echo \"\r\" | #{@bin} -d"
command << " preferred_state=#{can_haz(@new_resource, "preferred_state")}"
command << " upgrade -a#{expand_options(@new_resource.options)}"
command << " #{prefix_channel(can_haz(@new_resource, "channel"))}#{name}"
command << "-#{version}" if version && !version.empty?
pear_shell_out(command)
manage_pecl_ini(name, :create, can_haz(@new_resource, 'directives'), can_haz(@new_resource, 'zend_extensions')) if pecl?
end
def remove_package(name, version)
command = "#{@bin} uninstall"
command << " #{expand_options(@new_resource.options)}"
command << " #{prefix_channel(can_haz(@new_resource, "channel"))}#{name}"
command << "-#{version}" if version && !version.empty?
pear_shell_out(command)
manage_pecl_ini(name, :delete) if pecl?
end
def pear_shell_out(command)
p = shell_out!(command)
# pear/pecl commands return a 0 on failures...we'll grep for it
p.invalid! if p.stdout.split('\n').last =~ /^ERROR:.+/i
p
end
def purge_package(name, version)
remove_package(name, version)
end
def expand_channel(channel)
channel ? " -c #{channel}" : ''
end
def prefix_channel(channel)
channel ? "#{channel}/" : ''
end
def get_extension_dir
@extension_dir ||= begin
# Consider using "pecl config-get ext_dir". It is more cross-platform.
# p = shell_out("php-config --extension-dir")
p = shell_out("#{node['php']['pecl']} config-get ext_dir")
p.stdout.strip
end
end
def get_extension_files(name)
files = []
p = shell_out("#{@bin} list-files #{name}")
p.stdout.each_line.grep(/^src\s+.*\.so$/i).each do |line|
files << line.split[1]
end
files
end
def manage_pecl_ini(name, action, directives, zend_extensions)
ext_prefix = get_extension_dir
ext_prefix << ::File::SEPARATOR if ext_prefix[-1].chr != ::File::SEPARATOR
files = get_extension_files(name)
extensions = Hash[
files.map do |filepath|
rel_file = filepath.clone
rel_file.slice! ext_prefix if rel_file.start_with? ext_prefix
zend = zend_extensions.include?(rel_file)
[(zend ? filepath : rel_file) , zend]
end
]
template "#{node['php']['ext_conf_dir']}/#{name}.ini" do
source 'extension.ini.erb'
cookbook 'php'
owner 'root'
group 'root'
mode '0644'
variables(:name => name, :extensions => extensions, :directives => directives)
action action
end
end
def grep_for_version(stdout, package)
v = nil
stdout.split(/\n/).grep(/^#{package}\s/i).each do |m|
# XML_RPC 1.5.4 stable
# mongo 1.1.4/(1.1.4 stable) 1.1.4 MongoDB database driver
# Horde_Url -n/a-/(1.0.0beta1 beta) Horde Url class
# Horde_Url 1.0.0beta1 (beta) 1.0.0beta1 Horde Url class
v = m.split(/\s+/)[1].strip
if v.split(/\//)[0] =~ /.\./
# 1.1.4/(1.1.4 stable)
v = v.split(/\//)[0]
else
# -n/a-/(1.0.0beta1 beta)
v = v.split(/(.*)\/\((.*)/).last.split(/\s/)[0]
end
end
v
end
def pecl?
@pecl ||=
begin
# search as a pear first since most 3rd party channels will report pears as pecls!
search_args = String.new
search_args << " -d preferred_state=#{can_haz(@new_resource, "preferred_state")}"
search_args << " search#{expand_channel(can_haz(@new_resource, "channel"))} #{@new_resource.package_name}"
if grep_for_version(shell_out(node['php']['pear'] + search_args).stdout, @new_resource.package_name)
false
elsif grep_for_version(shell_out(node['php']['pecl'] + search_args).stdout, @new_resource.package_name)
true
else
fail "Package #{@new_resource.package_name} not found in either PEAR or PECL."
end
end
end
# TODO: remove when provider is moved into Chef core
# this allows PhpPear to work with Chef::Resource::Package
def can_haz(resource, attribute_name)
resource.respond_to?(attribute_name) ? resource.send(attribute_name) : nil
end

View File

@@ -0,0 +1,93 @@
#
# Author:: Seth Chisamore <schisamo@opscode.com>
# Cookbook Name:: php
# Provider:: pear_channel
#
# Copyright:: 2011, Opscode, Inc <legal@opscode.com>
#
# 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.
#
# http://pear.php.net/manual/en/guide.users.commandline.channels.php
require 'chef/mixin/shell_out'
require 'chef/mixin/language'
include Chef::Mixin::ShellOut
def whyrun_supported?
true
end
action :discover do
unless exists?
Chef::Log.info("Discovering pear channel #{@new_resource}")
execute "#{node['php']['pear']} channel-discover #{@new_resource.channel_name}" do
action :run
end
end
end
action :add do
unless exists?
Chef::Log.info("Adding pear channel #{@new_resource} from #{@new_resource.channel_xml}")
execute "#{node['php']['pear']} channel-add #{@new_resource.channel_xml}" do
action :run
end
end
end
action :update do
if exists?
update_needed = false
begin
updated_needed = true if shell_out("#{node['php']['pear']} search -c #{@new_resource.channel_name} NNNNNN").stdout =~ /channel-update/
rescue Chef::Exceptions::CommandTimeout
# CentOS can hang on 'pear search' if a channel needs updating
Chef::Log.info("Timed out checking if channel-update needed...forcing update of pear channel #{@new_resource}")
update_needed = true
end
if update_needed
description = "update pear channel #{@new_resource}"
converge_by(description) do
Chef::Log.info("Updating pear channel #{@new_resource}")
shell_out!("#{node['php']['pear']} channel-update #{@new_resource.channel_name}")
end
end
end
end
action :remove do
if exists?
Chef::Log.info("Deleting pear channel #{@new_resource}")
execute "#{node['php']['pear']} channel-delete #{@new_resource.channel_name}" do
action :run
end
end
end
def load_current_resource
@current_resource = Chef::Resource::PhpPearChannel.new(@new_resource.name)
@current_resource.channel_name(@new_resource.channel_name)
@current_resource
end
private
def exists?
begin
shell_out!("#{node['php']['pear']} channel-info #{@current_resource.channel_name}")
true
rescue Mixlib::ShellOut::ShellCommandFailed
false
end
end

View File

@@ -0,0 +1,33 @@
#
# Author:: Joshua Timberman (<joshua@opscode.com>)
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Cookbook Name:: php
# Recipe:: default
#
# Copyright 2009-2011, Opscode, Inc.
#
# 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.
#
include_recipe "php::#{node['php']['install_method']}"
# update the main channels
php_pear_channel 'pear.php.net' do
action :update
end
php_pear_channel 'pecl.php.net' do
action :update
end
include_recipe "php::ini"

View File

@@ -0,0 +1,30 @@
#
# Author:: Christo De Lange (<opscode@dldinternet.com>)
# Cookbook Name:: php
# Recipe:: ini
#
# Copyright 2011, Opscode, Inc.
#
# 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.
#
template "#{node['php']['conf_dir']}/php.ini" do
source node['php']['ini']['template']
cookbook node['php']['ini']['cookbook']
unless platform?('windows')
owner 'root'
group 'root'
mode '0644'
end
variables(:directives => node['php']['directives'])
end

View File

@@ -0,0 +1,37 @@
#
# Author:: Joshua Timberman (<joshua@opscode.com>)
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Cookbook Name:: php
# Recipe:: module_apc
#
# Copyright 2009-2011, Opscode, Inc.
#
# 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.
#
case node['platform_family']
when 'rhel', 'fedora'
%w{ httpd-devel pcre pcre-devel }.each do |pkg|
package pkg do
action :install
end
end
php_pear 'APC' do
action :install
directives(:shm_size => '128M', :enable_cli => 0)
end
when 'debian'
package 'php-apc' do
action :install
end
end

View File

@@ -0,0 +1,29 @@
#
# Author:: Joshua Timberman (<joshua@opscode.com>)
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Cookbook Name:: php
# Recipe:: module_curl
#
# Copyright 2009-2011, Opscode, Inc.
#
# 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.
#
case node['platform_family']
when 'rhel', 'fedora'
# centos php compiled with curl
when 'debian'
package 'php5-curl' do
action :upgrade
end
end

View File

@@ -0,0 +1,35 @@
#
# Author:: Joshua Timberman (<joshua@opscode.com>)
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Cookbook Name:: php
# Recipe:: module_fpdf
#
# Copyright 2009-2011, Opscode, Inc.
#
# 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.
#
case node['platform_family']
when 'rhel', 'fedora'
pearhub_chan = php_pear_channel 'pearhub.org' do
action :discover
end
php_pear 'FPDF' do
channel pearhub_chan.channel_name
action :install
end
when 'debian'
package 'php-fpdf' do
action :install
end
end

View File

@@ -0,0 +1,32 @@
#
# Author:: Joshua Timberman (<joshua@opscode.com>)
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Cookbook Name:: php
# Recipe:: module_gd
#
# Copyright 2009-2011, Opscode, Inc.
#
# 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.
#
pkg = value_for_platform(
%w(centos redhat scientific fedora amazon oracle) => {
el5_range => 'php53-gd',
'default' => 'php-gd'
},
'default' => 'php5-gd'
)
package pkg do
action :install
end

View File

@@ -0,0 +1,32 @@
#
# Author:: Joshua Timberman (<joshua@opscode.com>)
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Cookbook Name:: php
# Recipe:: module_ldap
#
# Copyright 2009-2011, Opscode, Inc.
#
# 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.
#
pkg = value_for_platform(
%w(centos redhat scientific fedora amazon oracle) => {
el5_range => 'php53-ldap',
'default' => 'php-ldap'
},
'default' => 'php5-ldap'
)
package pkg do
action :install
end

View File

@@ -0,0 +1,37 @@
#
# Author:: Joshua Timberman (<joshua@opscode.com>)
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Cookbook Name:: php
# Recipe:: module_memcache
#
# Copyright 2009-2011, Opscode, Inc.
#
# 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.
#
case node['platform_family']
when 'rhel', 'fedora'
%w{ zlib-devel }.each do |pkg|
package pkg do
action :install
end
end
php_pear 'memcache' do
action :install
# directives(:shm_size => "128M", :enable_cli => 0)
end
when 'debian'
package 'php5-memcache' do
action :install
end
end

View File

@@ -0,0 +1,32 @@
#
# Author:: Joshua Timberman (<joshua@opscode.com>)
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Cookbook Name:: php
# Recipe:: module_mysql
#
# Copyright 2009-2011, Opscode, Inc.
#
# 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.
#
pkg = value_for_platform(
%w(centos redhat scientific fedora amazon oracle) => {
el5_range => 'php53-mysql',
'default' => 'php-mysql'
},
'default' => 'php5-mysql'
)
package pkg do
action :install
end

View File

@@ -0,0 +1,32 @@
#
# Author:: Joshua Timberman (<joshua@opscode.com>)
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Cookbook Name:: php
# Recipe:: module_pgsql
#
# Copyright 2009-2011, Opscode, Inc.
#
# 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.
#
pkg = value_for_platform(
%w(centos redhat scientific fedora amazon oracle) => {
el5_range => 'php53-pgsql',
'default' => 'php-pgsql'
},
'default' => 'php5-pgsql'
)
package pkg do
action :install
end

View File

@@ -0,0 +1,29 @@
#
# Author:: Joshua Timberman (<joshua@opscode.com>)
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Cookbook Name:: php
# Recipe:: module_sqlite3
#
# Copyright 2009-2011, Opscode, Inc.
#
# 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.
#
case node['platform_family']
when 'rhel', 'fedora'
# already there in centos, --with-pdo-sqlite=shared
when 'debian'
package 'php5-sqlite' do
action :install
end
end

View File

@@ -0,0 +1,66 @@
#
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Author:: Lucas Hansen (<lucash@opscode.com>)
# Cookbook Name:: php
# Recipe:: package
#
# Copyright 2013, Opscode, Inc.
#
# 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.
#
if platform?('windows')
include_recipe 'iis::mod_cgi'
install_dir = File.expand_path(node['php']['conf_dir']).gsub('/', '\\')
windows_package node['php']['windows']['msi_name'] do
source node['php']['windows']['msi_source']
installer_type :msi
options %W[
/quiet
INSTALLDIR="#{install_dir}"
ADDLOCAL=#{node['php']['packages'].join(',')}
].join(' ')
end
# WARNING: This is not the out-of-the-box go-pear.phar. It's been modified to patch this bug:
# http://pear.php.net/bugs/bug.php?id=16644
cookbook_file "#{node['php']['conf_dir']}/PEAR/go-pear.phar" do
source 'go-pear.phar'
end
template "#{node['php']['conf_dir']}/pear-options" do
source 'pear-options.erb'
end
execute 'install-pear' do
cwd node['php']['conf_dir']
command 'go-pear.bat < pear-options'
creates "#{node['php']['conf_dir']}/pear.bat"
end
ENV['PATH'] += ";#{install_dir}"
windows_path install_dir
else
node['php']['packages'].each do |pkg|
package pkg do
action :install
options node['php']['package_options']
end
end
end
include_recipe "php::ini"

View File

@@ -0,0 +1,85 @@
#
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Cookbook Name:: php
# Recipe:: package
#
# Copyright 2011, Opscode, Inc.
#
# 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.
#
configure_options = node['php']['configure_options'].join(' ')
include_recipe 'build-essential'
include_recipe 'xml'
include_recipe 'mysql::client' if configure_options =~ /mysql/
include_recipe 'yum-epel' if node['platform_family'] == 'rhel'
pkgs = value_for_platform_family(
%w{ rhel fedora } => %w{ bzip2-devel libc-client-devel curl-devel freetype-devel gmp-devel libjpeg-devel krb5-devel libmcrypt-devel libpng-devel openssl-devel t1lib-devel mhash-devel },
%w{ debian ubuntu } => %w{ libbz2-dev libc-client2007e-dev libcurl4-gnutls-dev libfreetype6-dev libgmp3-dev libjpeg62-dev libkrb5-dev libmcrypt-dev libpng12-dev libssl-dev libt1-dev },
'default' => %w{ libbz2-dev libc-client2007e-dev libcurl4-gnutls-dev libfreetype6-dev libgmp3-dev libjpeg62-dev libkrb5-dev libmcrypt-dev libpng12-dev libssl-dev libt1-dev }
)
pkgs.each do |pkg|
package pkg do
action :install
end
end
version = node['php']['version']
remote_file "#{Chef::Config[:file_cache_path]}/php-#{version}.tar.gz" do
source "#{node['php']['url']}/php-#{version}.tar.gz/from/this/mirror"
checksum node['php']['checksum']
mode '0644'
not_if "which #{node['php']['bin']}"
end
if node['php']['ext_dir']
directory node['php']['ext_dir'] do
owner 'root'
group 'root'
mode '0755'
recursive true
end
ext_dir_prefix = "EXTENSION_DIR=#{node['php']['ext_dir']}"
else
ext_dir_prefix = ''
end
bash 'build php' do
cwd Chef::Config[:file_cache_path]
code <<-EOF
tar -zxf php-#{version}.tar.gz
(cd php-#{version} && #{ext_dir_prefix} ./configure #{configure_options})
(cd php-#{version} && make && make install)
EOF
not_if "which #{node['php']['bin']}"
end
directory node['php']['conf_dir'] do
owner 'root'
group 'root'
mode '0755'
recursive true
end
directory node['php']['ext_conf_dir'] do
owner 'root'
group 'root'
mode '0755'
recursive true
end
include_recipe "php::ini"

View File

@@ -0,0 +1,30 @@
#
# Author:: Seth Chisamore <schisamo@opscode.com>
# Cookbook Name:: php
# Resource:: pear_package
#
# Copyright:: 2011, Opscode, Inc <legal@opscode.com>
#
# 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_action :install
actions :install, :upgrade, :remove, :purge
attribute :package_name, :kind_of => String, :name_attribute => true
attribute :version, :default => nil
attribute :channel, :kind_of => String
attribute :options, :kind_of => String
attribute :directives, :kind_of => Hash, :default => {}
attribute :zend_extensions, :kind_of => Array, :default => []
attribute :preferred_state, :default => 'stable'

View File

@@ -0,0 +1,29 @@
#
# Author:: Seth Chisamore <schisamo@opscode.com>
# Cookbook Name:: php
# Resource:: pear_channel
#
# Copyright:: 2011, Opscode, Inc <legal@opscode.com>
#
# 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_action :discover
actions :discover, :add, :update, :remove
attribute :channel_name, :kind_of => String, :name_attribute => true
attribute :channel_xml, :kind_of => String
# TODO: add authenticated channel support!
# attribute :username, :kind_of => String
# attribute :password, :kind_of => String

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -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 -%>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,18 @@
all
<%= node['php']['conf_dir'].gsub("/", "\\") %>
n

File diff suppressed because it is too large Load Diff