Permalink
Browse files

The pecl resource now supports manually building an extension.

Fixes an incompatibility with libmemcached installed by the memcached
cookbook, see travis-ci/travis-ci#971.
  • Loading branch information...
1 parent 843d754 commit ef25348a2c87eb0c106db80ff5e0985928092fc6 @loicfrering loicfrering committed Mar 9, 2013
@@ -11,12 +11,19 @@
'memcached' => {
'versions' => default[:php][:multi][:versions].reject { |version| version.start_with?("5.5") },
'before_packages' => %w(libevent-dev libcloog-ppl0),
- 'before_script' => <<-EOF
+ 'before_script' => <<-EOF,
wget https://launchpad.net/libmemcached/1.0/1.0.16/+download/libmemcached-1.0.16.tar.gz
tar xzf libmemcached-1.0.16.tar.gz
cd libmemcached-1.0.16
./configure && make && make install
EOF
+ 'script' => <<-EOF
+ pecl download memcached
+ tar zxvf memcached*.tgz && cd memcached*
+ make clean
+ phpize
+ ./configure --with-libmemcached-dir=/usr/local && make && make install
+ EOF
},
'mongo' => {
'versions' => default[:php][:multi][:versions].reject { |version| version.start_with?("5.5") }
@@ -23,35 +23,49 @@
end
versions.each do |php_version|
- bash "install PECL extension #{extension} for PHP #{php_version}" do
- user new_resource.owner
- group new_resource.group
- environment Hash["HOME" => node.travis_build_environment.home]
- code <<-EOF
- source /etc/profile.d/phpenv.sh
- phpenv global #{php_version}
+ if new_resource.script && !new_resource.script.empty?
+ bash "manually install PECL extension #{extension} for PHP #{php_version}" do
+ user new_resource.owner
+ group new_resource.group
+ cwd "/tmp"
+ environment Hash["HOME" => node.travis_build_environment.home]
+ code <<-EOF
+ source /etc/profile.d/phpenv.sh
+ phpenv global #{php_version}
+ #{new_resource.script}
+ EOF
+ end
+ else
+ bash "install PECL extension #{extension} for PHP #{php_version}" do
+ user new_resource.owner
+ group new_resource.group
+ environment Hash["HOME" => node.travis_build_environment.home]
+ code <<-EOF
+ source /etc/profile.d/phpenv.sh
+ phpenv global #{php_version}
- if [ ! -z "#{new_resource.channel}" ]; then
- pear channel-discover #{new_resource.channel}
- fi
+ if [ ! -z "#{new_resource.channel}" ]; then
+ pear channel-discover #{new_resource.channel}
+ fi
- pecl info #{extension}
- return=$?
- if [ $return = 0 ]; then
- echo "Extension #{extension} was already installed for PHP #{php_version}."
- elif [ $return = 1 ]; then
- result=$(pecl install #{extension} | tail -1)
- if [[ "$result" =~ ^ERROR: ]]; then
- echo "There was an error installing extension #{extension} for PHP #{php_version}:"
- echo "$result"
+ pecl info #{extension}
+ return=$?
+ if [ $return = 0 ] || [ -f "$(pecl config-get ext_dir)/#{extension}.so" ]; then
+ echo "Extension #{extension} was already installed for PHP #{php_version}."
+ elif [ $return = 1 ]; then
+ result=$(pecl install #{extension} | tail -1)
+ if [[ "$result" =~ ^ERROR: ]]; then
+ echo "There was an error installing extension #{extension} for PHP #{php_version}:"
+ echo "$result"
+ exit 1
+ fi
+ echo "Extension #{extension} successfully installed for PHP #{php_version}."
+ else
+ echo "There was an error installing extension #{extension} for PHP #{php_version}."
exit 1
fi
- echo "Extension #{extension} successfully installed for PHP #{php_version}."
- else
- echo "There was an error installing extension #{extension} for PHP #{php_version}."
- exit 1
- fi
- EOF
+ EOF
+ end
end
end
end
@@ -8,6 +8,7 @@
before_recipes options['before_recipes']
before_packages options['before_packages']
before_script options['before_script']
+ script options['script']
owner node.travis_build_environment.user
group node.travis_build_environment.group
@@ -6,5 +6,6 @@
attribute :before_recipes, :kind_of => Array, :default => []
attribute :before_packages, :kind_of => Array, :default => []
attribute :before_script, :kind_of => String
+attribute :script, :kind_of => String
attribute :owner, :regex => Chef::Config[:user_valid_regex]
attribute :group, :regex => Chef::Config[:group_valid_regex]

0 comments on commit ef25348

Please sign in to comment.