Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Make client packages an attribute.

  • Loading branch information...
commit 14bd579e8ba95f46f39a2379be8a5ef61bf61c6d 1 parent 479f533
Jesse Howarth authored August 15, 2012 jtimberman committed August 15, 2012
1  .gitignore
@@ -2,3 +2,4 @@
2 2
 .cache
3 3
 .kitchen
4 4
 bin
  5
+*.sw[op]
21  attributes/client.rb
... ...
@@ -1,6 +1,6 @@
1 1
 #
2 2
 # Cookbook Name:: mysql
3  
-# Attributes:: server
  3
+# Attributes:: client
4 4
 #
5 5
 # Copyright 2008-2009, Opscode, Inc.
6 6
 #
@@ -17,16 +17,31 @@
17 17
 # limitations under the License.
18 18
 #
19 19
 
20  
-case node["platform"]
  20
+case node['platform']
  21
+when "centos", "redhat", "suse", "fedora", "scientific", "amazon"
  22
+  default['mysql']['client']['packages'] = %w{mysql mysql-devel}
  23
+when "ubuntu","debian"
  24
+  if debian_before_squeeze? || ubuntu_before_lucid?
  25
+    default['mysql']['client']['packages'] = %w{mysql-client libmysqlclient15-dev}
  26
+  else
  27
+    default['mysql']['client']['packages'] = %w{mysql-client libmysqlclient-dev}
  28
+  end
  29
+when "freebsd"
  30
+  default['mysql']['client']['packages'] = %w{mysql55-client}
21 31
 when "windows"
22 32
   default['mysql']['client']['version']      = "6.0.2"
23 33
   default['mysql']['client']['arch']         = "win32" # force 32 bit to work with mysql gem
24 34
   default['mysql']['client']['package_file'] = "mysql-connector-c-#{mysql['client']['version']}-#{mysql['client']['arch']}.msi"
25 35
   default['mysql']['client']['url']          = "http://www.mysql.com/get/Downloads/Connector-C/#{mysql['client']['package_file']}/from/http://mysql.mirrors.pair.com/"
26  
-  default['mysql']['client']['package_name'] = "MySQL Connector C #{mysql['client']['version']}"
  36
+  default['mysql']['client']['packages']     = ["MySQL Connector C #{mysql['client']['version']}"]
27 37
 
28 38
   default['mysql']['client']['basedir']      = "#{ENV['SYSTEMDRIVE']}\\Program Files (x86)\\MySQL\\#{mysql['client']['package_name']}"
29 39
   default['mysql']['client']['lib_dir']      = "#{mysql['client']['basedir']}\\lib/opt"
30 40
   default['mysql']['client']['bin_dir']      = "#{mysql['client']['basedir']}\\bin"
31 41
   default['mysql']['client']['ruby_dir']     = RbConfig::CONFIG['bindir']
  42
+when "mac_os_x"
  43
+  default['mysql']['client']['packages'] = %w{mysql-connector-c}
  44
+else
  45
+  default['mysql']['client']['packages'] = %w{mysql-client libmysqlclient-dev}
32 46
 end
  47
+
20  recipes/client.rb
@@ -21,17 +21,7 @@
21 21
 # to debian_before_squeeze? and ubuntu_before_lucid?
22 22
 ::Chef::Recipe.send(:include, Opscode::Mysql::Helpers)
23 23
 
24  
-mysql_packages = case node['platform']
25  
-when "centos", "redhat", "suse", "fedora", "scientific", "amazon"
26  
-  %w{mysql mysql-devel}
27  
-when "ubuntu","debian"
28  
-  if debian_before_squeeze? || ubuntu_before_lucid?
29  
-    %w{mysql-client libmysqlclient15-dev}
30  
-  else
31  
-    %w{mysql-client libmysqlclient-dev}
32  
-  end
33  
-when "freebsd"
34  
-  %w{mysql55-client}
  24
+case node['platform']
35 25
 when "windows"
36 26
   package_file = node['mysql']['client']['package_file']
37 27
   remote_file "#{Chef::Config[:file_cache_path]}/#{package_file}" do
@@ -39,7 +29,7 @@
39 29
     not_if { File.exists? "#{Chef::Config[:file_cache_path]}/#{package_file}" }
40 30
   end
41 31
 
42  
-  windows_package node['mysql']['client']['package_name'] do
  32
+  windows_package node['mysql']['client']['package_names'].first do
43 33
     source "#{Chef::Config[:file_cache_path]}/#{package_file}"
44 34
   end
45 35
   windows_path node['mysql']['client']['bin_dir'] do
@@ -48,15 +38,11 @@
48 38
   def package(*args, &blk)
49 39
     windows_package(*args, &blk)
50 40
   end
51  
-  [node['mysql']['client']['package_name']]
52 41
 when "mac_os_x"
53 42
   include_recipe 'homebrew'
54  
-  %w{mysql-connector-c}
55  
-else
56  
-  %w{mysql-client libmysqlclient-dev}
57 43
 end
58 44
 
59  
-mysql_packages.each do |mysql_pack|
  45
+node['mysql']['client']['packages'].each do |mysql_pack|
60 46
   package mysql_pack do
61 47
     action :install
62 48
   end

0 notes on commit 14bd579

Please sign in to comment.
Something went wrong with that request. Please try again.