Permalink
Browse files

Make client packages an attribute.

  • Loading branch information...
1 parent 479f533 commit 14bd579e8ba95f46f39a2379be8a5ef61bf61c6d jhowarth committed with jtimberman Aug 15, 2012
Showing with 22 additions and 20 deletions.
  1. +1 −0 .gitignore
  2. +18 −3 attributes/client.rb
  3. +3 −17 recipes/client.rb
View
@@ -2,3 +2,4 @@
.cache
.kitchen
bin
+*.sw[op]
View
@@ -1,6 +1,6 @@
#
# Cookbook Name:: mysql
-# Attributes:: server
+# Attributes:: client
#
# Copyright 2008-2009, Opscode, Inc.
#
@@ -17,16 +17,31 @@
# limitations under the License.
#
-case node["platform"]
+case node['platform']
+when "centos", "redhat", "suse", "fedora", "scientific", "amazon"
+ default['mysql']['client']['packages'] = %w{mysql mysql-devel}
+when "ubuntu","debian"
+ if debian_before_squeeze? || ubuntu_before_lucid?
+ default['mysql']['client']['packages'] = %w{mysql-client libmysqlclient15-dev}
+ else
+ default['mysql']['client']['packages'] = %w{mysql-client libmysqlclient-dev}
+ end
+when "freebsd"
+ default['mysql']['client']['packages'] = %w{mysql55-client}
when "windows"
default['mysql']['client']['version'] = "6.0.2"
default['mysql']['client']['arch'] = "win32" # force 32 bit to work with mysql gem
default['mysql']['client']['package_file'] = "mysql-connector-c-#{mysql['client']['version']}-#{mysql['client']['arch']}.msi"
default['mysql']['client']['url'] = "http://www.mysql.com/get/Downloads/Connector-C/#{mysql['client']['package_file']}/from/http://mysql.mirrors.pair.com/"
- default['mysql']['client']['package_name'] = "MySQL Connector C #{mysql['client']['version']}"
+ default['mysql']['client']['packages'] = ["MySQL Connector C #{mysql['client']['version']}"]
default['mysql']['client']['basedir'] = "#{ENV['SYSTEMDRIVE']}\\Program Files (x86)\\MySQL\\#{mysql['client']['package_name']}"
default['mysql']['client']['lib_dir'] = "#{mysql['client']['basedir']}\\lib/opt"
default['mysql']['client']['bin_dir'] = "#{mysql['client']['basedir']}\\bin"
default['mysql']['client']['ruby_dir'] = RbConfig::CONFIG['bindir']
+when "mac_os_x"
+ default['mysql']['client']['packages'] = %w{mysql-connector-c}
+else
+ default['mysql']['client']['packages'] = %w{mysql-client libmysqlclient-dev}
end
+
View
@@ -21,25 +21,15 @@
# to debian_before_squeeze? and ubuntu_before_lucid?
::Chef::Recipe.send(:include, Opscode::Mysql::Helpers)
-mysql_packages = case node['platform']
-when "centos", "redhat", "suse", "fedora", "scientific", "amazon"
- %w{mysql mysql-devel}
-when "ubuntu","debian"
- if debian_before_squeeze? || ubuntu_before_lucid?
- %w{mysql-client libmysqlclient15-dev}
- else
- %w{mysql-client libmysqlclient-dev}
- end
-when "freebsd"
- %w{mysql55-client}
+case node['platform']
when "windows"
package_file = node['mysql']['client']['package_file']
remote_file "#{Chef::Config[:file_cache_path]}/#{package_file}" do
source node['mysql']['client']['url']
not_if { File.exists? "#{Chef::Config[:file_cache_path]}/#{package_file}" }
end
- windows_package node['mysql']['client']['package_name'] do
+ windows_package node['mysql']['client']['package_names'].first do
source "#{Chef::Config[:file_cache_path]}/#{package_file}"
end
windows_path node['mysql']['client']['bin_dir'] do
@@ -48,15 +38,11 @@
def package(*args, &blk)
windows_package(*args, &blk)
end
- [node['mysql']['client']['package_name']]
when "mac_os_x"
include_recipe 'homebrew'
- %w{mysql-connector-c}
-else
- %w{mysql-client libmysqlclient-dev}
end
-mysql_packages.each do |mysql_pack|
+node['mysql']['client']['packages'].each do |mysql_pack|
package mysql_pack do
action :install
end

0 comments on commit 14bd579

Please sign in to comment.