natives 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +15 -0
  2. data/.document +5 -0
  3. data/.rspec +1 -0
  4. data/Gemfile +17 -0
  5. data/Gemfile.lock +137 -0
  6. data/LICENSE.txt +20 -0
  7. data/README.rdoc +19 -0
  8. data/Rakefile +42 -0
  9. data/VERSION +1 -0
  10. data/bin/natives +7 -0
  11. data/chef-solo/.gitignore +17 -0
  12. data/chef-solo/.kitchen.yml +27 -0
  13. data/chef-solo/Berksfile +4 -0
  14. data/chef-solo/config.rb +17 -0
  15. data/chef-solo/vendored-cookbooks/apt/CHANGELOG.md +144 -0
  16. data/chef-solo/vendored-cookbooks/apt/README.md +247 -0
  17. data/chef-solo/vendored-cookbooks/apt/attributes/default.rb +27 -0
  18. data/chef-solo/vendored-cookbooks/apt/files/default/apt-proxy-v2.conf +50 -0
  19. data/chef-solo/vendored-cookbooks/apt/libraries/helpers.rb +47 -0
  20. data/chef-solo/vendored-cookbooks/apt/libraries/network.rb +33 -0
  21. data/chef-solo/vendored-cookbooks/apt/metadata.json +54 -0
  22. data/chef-solo/vendored-cookbooks/apt/metadata.rb +34 -0
  23. data/chef-solo/vendored-cookbooks/apt/providers/preference.rb +61 -0
  24. data/chef-solo/vendored-cookbooks/apt/providers/repository.rb +141 -0
  25. data/chef-solo/vendored-cookbooks/apt/recipes/cacher-client.rb +81 -0
  26. data/chef-solo/vendored-cookbooks/apt/recipes/cacher-ng.rb +43 -0
  27. data/chef-solo/vendored-cookbooks/apt/recipes/default.rb +83 -0
  28. data/chef-solo/vendored-cookbooks/apt/resources/preference.rb +30 -0
  29. data/chef-solo/vendored-cookbooks/apt/resources/repository.rb +41 -0
  30. data/chef-solo/vendored-cookbooks/apt/templates/debian-6.0/acng.conf.erb +173 -0
  31. data/chef-solo/vendored-cookbooks/apt/templates/default/01proxy.erb +5 -0
  32. data/chef-solo/vendored-cookbooks/apt/templates/default/acng.conf.erb +275 -0
  33. data/chef-solo/vendored-cookbooks/apt/templates/ubuntu-10.04/acng.conf.erb +269 -0
  34. data/chef-solo/vendored-cookbooks/homebrew/CHANGELOG.md +36 -0
  35. data/chef-solo/vendored-cookbooks/homebrew/README.md +110 -0
  36. data/chef-solo/vendored-cookbooks/homebrew/attributes/default.rb +22 -0
  37. data/chef-solo/vendored-cookbooks/homebrew/libraries/homebrew_mixin.rb +53 -0
  38. data/chef-solo/vendored-cookbooks/homebrew/libraries/homebrew_package.rb +104 -0
  39. data/chef-solo/vendored-cookbooks/homebrew/metadata.json +32 -0
  40. data/chef-solo/vendored-cookbooks/homebrew/metadata.rb +10 -0
  41. data/chef-solo/vendored-cookbooks/homebrew/providers/tap.rb +48 -0
  42. data/chef-solo/vendored-cookbooks/homebrew/recipes/default.rb +46 -0
  43. data/chef-solo/vendored-cookbooks/homebrew/resources/tap.rb +35 -0
  44. data/lib/natives/app.rb +53 -0
  45. data/lib/natives/cli.rb +11 -0
  46. data/lib/natives.rb +0 -0
  47. data/natives.gemspec +113 -0
  48. data/spec/natives/app_spec.rb +68 -0
  49. data/spec/spec_helper.rb +12 -0
  50. metadata +224 -0
@@ -0,0 +1,110 @@
1
+ Homebrew Cookbook
2
+ =================
3
+ This cookbook installs [Homebrew](http://mxcl.github.com/homebrew/) and replaces MacPorts as the *default package provider* for the package resource on OS X systems.
4
+
5
+ This cookbook is now maintained by Opscode. The original author, maintainer and copyright holder is Graeme Mathieson. The cookbook remains licensed under the Apache License version 2.
6
+
7
+ [Original blog post by Graeme](http://woss.name/2011/01/23/converging-your-home-directory-with-chef/)
8
+
9
+
10
+ Requirements
11
+ ------------
12
+ ### Prerequisites
13
+
14
+ In order for this recipe to work, your userid must own `/usr/local`. This is outside the scope of the cookbook because it's anticipated that you'll run the cookbook as your own user, not root and you'd have to be root to take ownership of the directory. Easiest way to get started:
15
+
16
+ ```bash
17
+ sudo chown -R `whoami`:staff /usr/local
18
+ ```
19
+
20
+ Bear in mind that this will take ownership of the entire folder and its contents, so if you've already got stuff in there (eg MySQL owned by a `mysql` user) you'll need to be a touch more careful. This is a recommendation from Homebrew.
21
+
22
+ ### Platform
23
+
24
+ - Mac OS X (10.6+)
25
+
26
+ The only platform supported by Homebrew itself at the time of this writing is Mac OS X. It should work fine on Server edition as well, and on platforms that Homebrew supports in the future.
27
+
28
+
29
+ Attributes
30
+ ----------
31
+ - `node['homebrew']['owner']` - The user that will own the Homebrew installation and packages. Setting this will override the default behavior which is to use the non-privileged user that has invoked the Chef run (or the `SUDO_USER` if invoked with sudo). The default is `nil`.
32
+
33
+
34
+ Resources and Providers
35
+ -----------------------
36
+ ### package / homebrew\_package
37
+
38
+ This cookbook provides a package provider called `homebrew_package` which will install/remove packages using Homebrew. This becomes the default provider for `package` if your platform is Mac OS X.
39
+
40
+ As this extends the built-in package resource/provider in Chef, it has all the resource attributes and actions available to the package resource. However, a couple notes:
41
+
42
+ - Homebrew itself doesn't have a notion of "upgrade" per se. The "upgrade" action will simply perform an install, and if the Homebrew Formula for the package is newer, it will upgrade.
43
+ - Likewise, Homebrew doesn't have a purge, but the "purge" action will act like "remove".
44
+
45
+ #### Examples
46
+
47
+ ```ruby
48
+ package 'mysql' do
49
+ action :install
50
+ end
51
+
52
+ homebrew_package 'mysql'
53
+
54
+ package 'mysql' do
55
+ provider Chef::Provider::Package::Homebrew
56
+ end
57
+ ```
58
+
59
+ ### homebrew\_tap
60
+
61
+ LWRP for `brew tap`, a Homebrew command used to add additional formula repositories. From the `brew` man page:
62
+
63
+ ```text
64
+ tap [tap]
65
+ Tap a new formula repository from GitHub, or list existing taps.
66
+
67
+ tap is of the form user/repo, e.g. brew tap homebrew/dupes.
68
+ ```
69
+
70
+ Default action is `:tap` which enables the repository. Use `:untap` to disable a tapped repository.
71
+
72
+ #### Examples
73
+
74
+ ```ruby
75
+ homebrew_tap 'homebrew/dupes'
76
+
77
+ homebrew_tap 'homebrew/dupes' do
78
+ action :untap
79
+ end
80
+ ```
81
+
82
+
83
+ Usage
84
+ -----
85
+ We strongly recommend that you put "recipe[homebrew]" in your node's run list, to ensure that it is available on the system and that Homebrew itself gets installed. Putting an explicit dependency in the metadata will cause the cookbook to be downloaded and the library loaded, thus resulting in changing the package provider on Mac OS X, so if you have systems you want to use the default (Mac Ports), they would be changed to Homebrew.
86
+
87
+ The default itself ensures that Homebrew is installed and up to date.
88
+
89
+
90
+ License and Authors
91
+ -------------------
92
+ - Author:: Graeme Mathieson (<mathie@woss.name>)
93
+ - Author:: Joshua Timberman (<joshua@opscode.com>)
94
+
95
+ ```text
96
+ Copyright:: 2011, Graeme Mathieson
97
+ Copyright:: 2012, Opscode, Inc <legal@opscode.com>
98
+
99
+ Licensed under the Apache License, Version 2.0 (the "License"); you may
100
+ not use this file except in compliance with the License. You may obtain
101
+ a copy of the License at
102
+
103
+ http://www.apache.org/licenses/LICENSE-2.0
104
+
105
+ Unless required by applicable law or agreed to in writing, software
106
+ distributed under the License is distributed on an "AS IS" BASIS,
107
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
108
+ See the License for the specific language governing permissions and
109
+ limitations under the License.
110
+ ```
@@ -0,0 +1,22 @@
1
+ #
2
+ # Author:: Joshua Timberman (<jtimberman@opscode.com>)
3
+ # Author:: Graeme Mathieson (<mathie@woss.name>)
4
+ # Cookbook Name:: homebrew
5
+ # Attributes:: default
6
+ #
7
+ # Copyright 2011-2013, Opscode, Inc.
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ #
21
+
22
+ default['homebrew']['owner'] = nil
@@ -0,0 +1,53 @@
1
+ #
2
+ # Author:: Joshua Timberman (<jtimberman@opscode.com>)
3
+ # Author:: Graeme Mathieson (<mathie@woss.name>)
4
+ # Cookbook Name:: homebrew
5
+ # Libraries:: homebrew_mixin
6
+ #
7
+ # Copyright 2011-2013, Opscode, Inc.
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ #
21
+
22
+ module Homebrew
23
+ module Mixin
24
+
25
+ def homebrew_owner
26
+ @homebrew_owner ||= calculate_owner
27
+ end
28
+
29
+ private
30
+
31
+ def calculate_owner
32
+ owner = homebrew_owner_attr || sudo_user || current_user
33
+ if owner == "root"
34
+ raise Chef::Exceptions::User,
35
+ "Homebrew owner is 'root' which is not supported. " +
36
+ "To set an explicit owner, please set node['homebrew']['owner']."
37
+ end
38
+ owner
39
+ end
40
+
41
+ def homebrew_owner_attr
42
+ node['homebrew']['owner']
43
+ end
44
+
45
+ def sudo_user
46
+ ENV['SUDO_USER']
47
+ end
48
+
49
+ def current_user
50
+ ENV['USER']
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,104 @@
1
+ #
2
+ # Author:: Joshua Timberman (<jtimberman@opscode.com>)
3
+ # Author:: Graeme Mathieson (<mathie@woss.name>)
4
+ # Cookbook Name:: homebrew
5
+ # Libraries:: homebrew_package
6
+ #
7
+ # Copyright 2011-2013, Opscode, Inc.
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ #
21
+
22
+ require 'chef/provider/package'
23
+ require 'chef/resource/package'
24
+ require 'chef/platform'
25
+ require 'chef/mixin/shell_out'
26
+
27
+ class Chef
28
+ class Provider
29
+ class Package
30
+ class Homebrew < Package
31
+
32
+ include Chef::Mixin::ShellOut
33
+ include ::Homebrew::Mixin
34
+
35
+ def load_current_resource
36
+ @current_resource = Chef::Resource::Package.new(@new_resource.name)
37
+ @current_resource.package_name(@new_resource.package_name)
38
+ @current_resource.version(current_installed_version)
39
+
40
+ @current_resource
41
+ end
42
+
43
+ def install_package(name, version)
44
+ brew('install', @new_resource.options, name)
45
+ end
46
+
47
+ def upgrade_package(name, version)
48
+ brew('upgrade', name)
49
+ end
50
+
51
+ def remove_package(name, version)
52
+ brew('uninstall', @new_resource.options, name)
53
+ end
54
+
55
+ # Homebrew doesn't really have a notion of purging, so just remove.
56
+ def purge_package(name, version)
57
+ @new_resource.options = ((@new_resource.options || "") << " --force").strip
58
+ remove_package(name, version)
59
+ end
60
+
61
+ protected
62
+ def brew(*args)
63
+ get_response_from_command("brew #{args.join(' ')}")
64
+ end
65
+
66
+ def current_installed_version
67
+ pkg = get_version_from_formula
68
+ versions = pkg.to_hash['installed'].map {|v| v['version']}
69
+ versions.join(" ") unless versions.empty?
70
+ end
71
+
72
+ def candidate_version
73
+ pkg = get_version_from_formula
74
+ pkg.stable.version.to_s || pkg.version.to_s
75
+ end
76
+
77
+ def get_version_from_command(command)
78
+ version = get_response_from_command(command).chomp
79
+ version.empty? ? nil : version
80
+ end
81
+
82
+ def get_version_from_formula
83
+ brew_cmd = shell_out!("brew --prefix", :user => homebrew_owner)
84
+ libpath = ::File.join(brew_cmd.stdout.chomp, "Library", "Homebrew")
85
+ $:.unshift(libpath)
86
+
87
+ require 'global'
88
+ require 'cmd/info'
89
+
90
+ Formula.factory new_resource.package_name
91
+ end
92
+
93
+ def get_response_from_command(command)
94
+ Chef::Log.debug "Executing '#{command}' as #{homebrew_owner}"
95
+ output = shell_out!(command, :user => homebrew_owner)
96
+ output.stdout
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
102
+
103
+ Chef::Platform.set :platform => :mac_os_x_server, :resource => :package, :provider => Chef::Provider::Package::Homebrew
104
+ Chef::Platform.set :platform => :mac_os_x, :resource => :package, :provider => Chef::Provider::Package::Homebrew
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "homebrew",
3
+ "version": "1.5.0",
4
+ "description": "Install Homebrew and use it as your package provider in Mac OS X",
5
+ "long_description": "Homebrew Cookbook\n=================\nThis cookbook installs [Homebrew](http://mxcl.github.com/homebrew/) and replaces MacPorts as the *default package provider* for the package resource on OS X systems.\n\nThis cookbook is now maintained by Opscode. The original author, maintainer and copyright holder is Graeme Mathieson. The cookbook remains licensed under the Apache License version 2.\n\n[Original blog post by Graeme](http://woss.name/2011/01/23/converging-your-home-directory-with-chef/)\n\n\nRequirements\n------------\n### Prerequisites\n\nIn order for this recipe to work, your userid must own `/usr/local`. This is outside the scope of the cookbook because it's anticipated that you'll run the cookbook as your own user, not root and you'd have to be root to take ownership of the directory. Easiest way to get started:\n\n```bash\nsudo chown -R `whoami`:staff /usr/local\n```\n\nBear in mind that this will take ownership of the entire folder and its contents, so if you've already got stuff in there (eg MySQL owned by a `mysql` user) you'll need to be a touch more careful. This is a recommendation from Homebrew.\n\n### Platform\n\n- Mac OS X (10.6+)\n\nThe only platform supported by Homebrew itself at the time of this writing is Mac OS X. It should work fine on Server edition as well, and on platforms that Homebrew supports in the future.\n\n\nAttributes\n----------\n- `node['homebrew']['owner']` - The user that will own the Homebrew installation and packages. Setting this will override the default behavior which is to use the non-privileged user that has invoked the Chef run (or the `SUDO_USER` if invoked with sudo). The default is `nil`.\n\n\nResources and Providers\n-----------------------\n### package / homebrew\\_package\n\nThis cookbook provides a package provider called `homebrew_package` which will install/remove packages using Homebrew. This becomes the default provider for `package` if your platform is Mac OS X.\n\nAs this extends the built-in package resource/provider in Chef, it has all the resource attributes and actions available to the package resource. However, a couple notes:\n\n- Homebrew itself doesn't have a notion of \"upgrade\" per se. The \"upgrade\" action will simply perform an install, and if the Homebrew Formula for the package is newer, it will upgrade.\n- Likewise, Homebrew doesn't have a purge, but the \"purge\" action will act like \"remove\".\n\n#### Examples\n\n```ruby\npackage 'mysql' do\n action :install\nend\n\nhomebrew_package 'mysql'\n\npackage 'mysql' do\n provider Chef::Provider::Package::Homebrew\nend\n```\n\n### homebrew\\_tap\n\nLWRP for `brew tap`, a Homebrew command used to add additional formula repositories. From the `brew` man page:\n\n```text\ntap [tap]\n Tap a new formula repository from GitHub, or list existing taps.\n\n tap is of the form user/repo, e.g. brew tap homebrew/dupes.\n```\n\nDefault action is `:tap` which enables the repository. Use `:untap` to disable a tapped repository.\n\n#### Examples\n\n```ruby\nhomebrew_tap 'homebrew/dupes'\n\nhomebrew_tap 'homebrew/dupes' do\n action :untap\nend\n```\n\n\nUsage\n-----\nWe strongly recommend that you put \"recipe[homebrew]\" in your node's run list, to ensure that it is available on the system and that Homebrew itself gets installed. Putting an explicit dependency in the metadata will cause the cookbook to be downloaded and the library loaded, thus resulting in changing the package provider on Mac OS X, so if you have systems you want to use the default (Mac Ports), they would be changed to Homebrew.\n\nThe default itself ensures that Homebrew is installed and up to date.\n\n\nLicense and Authors\n-------------------\n- Author:: Graeme Mathieson (<mathie@woss.name>)\n- Author:: Joshua Timberman (<joshua@opscode.com>)\n\n```text\nCopyright:: 2011, Graeme Mathieson\nCopyright:: 2012, Opscode, Inc <legal@opscode.com>\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may\nnot use this file except in compliance with the License. You may obtain\na copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n",
6
+ "maintainer": "Opscode, Inc.",
7
+ "maintainer_email": "cookbooks@opscode.com",
8
+ "license": "Apache 2.0",
9
+ "platforms": {
10
+ "mac_os_x": ">= 0.0.0",
11
+ "mac_os_x_server": ">= 0.0.0"
12
+ },
13
+ "dependencies": {
14
+ },
15
+ "recommendations": {
16
+ },
17
+ "suggestions": {
18
+ },
19
+ "conflicting": {
20
+ },
21
+ "providing": {
22
+ },
23
+ "replacing": {
24
+ },
25
+ "attributes": {
26
+ },
27
+ "groupings": {
28
+ },
29
+ "recipes": {
30
+ "homebrew": "Install Homebrew"
31
+ }
32
+ }
@@ -0,0 +1,10 @@
1
+ name "homebrew"
2
+ maintainer "Opscode, Inc."
3
+ maintainer_email "cookbooks@opscode.com"
4
+ license "Apache 2.0"
5
+ description "Install Homebrew and use it as your package provider in Mac OS X"
6
+ long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7
+ version "1.5.0"
8
+ recipe "homebrew", "Install Homebrew"
9
+ supports "mac_os_x"
10
+ supports "mac_os_x_server"
@@ -0,0 +1,48 @@
1
+ #
2
+ # Author:: Joshua Timberman (<jtimberman@opscode.com>)
3
+ # Author:: Graeme Mathieson (<mathie@woss.name>)
4
+ # Cookbook Name:: homebrew
5
+ # Providers:: tap
6
+ #
7
+ # Copyright 2011-2013, Opscode, Inc.
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ #
21
+
22
+ def load_current_resource
23
+ @tap = Chef::Resource::HomebrewTap.new(new_resource.name)
24
+ tap_dir = @tap.name.gsub('/', '-')
25
+
26
+ Chef::Log.debug("Checking whether we've already tapped #{new_resource.name}")
27
+ if ::File.directory?("/usr/local/Library/Taps/#{tap_dir}")
28
+ @tap.tapped true
29
+ else
30
+ @tap.tapped false
31
+ end
32
+ end
33
+
34
+ action :tap do
35
+ unless @tap.tapped
36
+ execute "tapping #{new_resource.name}" do
37
+ command "/usr/local/bin/brew tap #{new_resource.name}"
38
+ end
39
+ end
40
+ end
41
+
42
+ action :untap do
43
+ if @tap.tapped
44
+ execute "untapping #{new_resource.name}" do
45
+ command "/usr/local/bin/brew untap #{new_resource.name}"
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,46 @@
1
+ #
2
+ # Author:: Joshua Timberman (<jtimberman@opscode.com>)
3
+ # Author:: Graeme Mathieson (<mathie@woss.name>)
4
+ # Cookbook Name:: homebrew
5
+ # Recipes:: default
6
+ #
7
+ # Copyright 2011-2013, Opscode, Inc.
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ #
21
+
22
+ self.extend(Homebrew::Mixin)
23
+
24
+ homebrew_go = "#{Chef::Config[:file_cache_path]}/homebrew_go"
25
+ owner = homebrew_owner
26
+
27
+ Chef::Log.debug("Homebrew owner is '#{homebrew_owner}'")
28
+
29
+ remote_file homebrew_go do
30
+ source "https://raw.github.com/mxcl/homebrew/go"
31
+ mode 00755
32
+ end
33
+
34
+ execute homebrew_go do
35
+ user owner
36
+ not_if { ::File.exist? '/usr/local/bin/brew' }
37
+ end
38
+
39
+ package 'git' do
40
+ not_if "which git"
41
+ end
42
+
43
+ execute "update homebrew from github" do
44
+ user owner
45
+ command "/usr/local/bin/brew update || true"
46
+ end
@@ -0,0 +1,35 @@
1
+ #
2
+ # Author:: Joshua Timberman (<jtimberman@opscode.com>)
3
+ # Author:: Graeme Mathieson (<mathie@woss.name>)
4
+ # Cookbook Name:: homebrew
5
+ # Resources:: tap
6
+ #
7
+ # Copyright 2011-2013, Opscode, Inc.
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ #
21
+
22
+ actions :tap, :untap
23
+ attribute :name,
24
+ :name_attribute => true,
25
+ :kind_of => String,
26
+ :regex => /\w+(?:\/\w+)+/
27
+
28
+ attribute :tapped,
29
+ :kind_of => [TrueClass, FalseClass]
30
+
31
+ ### hax for default action
32
+ def initialize( *args )
33
+ super
34
+ @action = :tap
35
+ end
@@ -0,0 +1,53 @@
1
+ require 'tempfile'
2
+ require 'json'
3
+ require 'chef/application/solo'
4
+
5
+ module Natives
6
+ class App
7
+ def install(packages)
8
+ create_tmp_attrs_file(Array(packages)) do |attrs_file|
9
+ run_chef_solo(attrs_file)
10
+ end
11
+ end
12
+
13
+ def run_chef_solo(json_attrs_file)
14
+ ARGV.clear
15
+ [
16
+ '-c', File.join(gem_base_path, 'chef-solo', 'config.rb'),
17
+ '-o', 'natives',
18
+ '-j', json_attrs_file.to_path
19
+ ].each do |token|
20
+ ARGV << token
21
+ end
22
+ Chef::Application::Solo.new.run
23
+ end
24
+
25
+ def create_tmp_attrs_file(packages, &block)
26
+ file = Tempfile.new('natives.temp_attrs_file')
27
+ file.write(json_attrs(packages))
28
+ file.flush
29
+ file.rewind
30
+ begin
31
+ block.call(file)
32
+ ensure
33
+ file.close!
34
+ end
35
+ end
36
+
37
+ protected
38
+
39
+ def gem_base_path
40
+ File.absolute_path(File.join(File.dirname(__FILE__), '..', '..'))
41
+ end
42
+
43
+ def json_attrs(packages)
44
+ {
45
+ "natives" => {
46
+ "install_list" => {
47
+ "rubygems" => packages
48
+ }
49
+ }
50
+ }.to_json
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,11 @@
1
+ require 'thor'
2
+ require 'natives/app'
3
+
4
+ module Natives
5
+ class Cli < Thor
6
+ desc 'install PACKAGE1 PACKAGE2 ..', 'install a list of ruby packages'
7
+ def install(*packages)
8
+ Natives::App.new.install(packages)
9
+ end
10
+ end
11
+ end
data/lib/natives.rb ADDED
File without changes
data/natives.gemspec ADDED
@@ -0,0 +1,113 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: natives 0.1.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "natives"
9
+ s.version = "0.1.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.authors = ["Huiming Teo"]
13
+ s.date = "2013-11-02"
14
+ s.description = "Automate libraries installation required by rubygems' native extension."
15
+ s.email = "teohuiming@gmail.com"
16
+ s.executables = ["natives"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".rspec",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "LICENSE.txt",
27
+ "README.rdoc",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "bin/natives",
31
+ "chef-solo/.gitignore",
32
+ "chef-solo/.kitchen.yml",
33
+ "chef-solo/Berksfile",
34
+ "chef-solo/config.rb",
35
+ "chef-solo/vendored-cookbooks/apt/CHANGELOG.md",
36
+ "chef-solo/vendored-cookbooks/apt/README.md",
37
+ "chef-solo/vendored-cookbooks/apt/attributes/default.rb",
38
+ "chef-solo/vendored-cookbooks/apt/files/default/apt-proxy-v2.conf",
39
+ "chef-solo/vendored-cookbooks/apt/libraries/helpers.rb",
40
+ "chef-solo/vendored-cookbooks/apt/libraries/network.rb",
41
+ "chef-solo/vendored-cookbooks/apt/metadata.json",
42
+ "chef-solo/vendored-cookbooks/apt/metadata.rb",
43
+ "chef-solo/vendored-cookbooks/apt/providers/preference.rb",
44
+ "chef-solo/vendored-cookbooks/apt/providers/repository.rb",
45
+ "chef-solo/vendored-cookbooks/apt/recipes/cacher-client.rb",
46
+ "chef-solo/vendored-cookbooks/apt/recipes/cacher-ng.rb",
47
+ "chef-solo/vendored-cookbooks/apt/recipes/default.rb",
48
+ "chef-solo/vendored-cookbooks/apt/resources/preference.rb",
49
+ "chef-solo/vendored-cookbooks/apt/resources/repository.rb",
50
+ "chef-solo/vendored-cookbooks/apt/templates/debian-6.0/acng.conf.erb",
51
+ "chef-solo/vendored-cookbooks/apt/templates/default/01proxy.erb",
52
+ "chef-solo/vendored-cookbooks/apt/templates/default/acng.conf.erb",
53
+ "chef-solo/vendored-cookbooks/apt/templates/ubuntu-10.04/acng.conf.erb",
54
+ "chef-solo/vendored-cookbooks/homebrew/CHANGELOG.md",
55
+ "chef-solo/vendored-cookbooks/homebrew/README.md",
56
+ "chef-solo/vendored-cookbooks/homebrew/attributes/default.rb",
57
+ "chef-solo/vendored-cookbooks/homebrew/libraries/homebrew_mixin.rb",
58
+ "chef-solo/vendored-cookbooks/homebrew/libraries/homebrew_package.rb",
59
+ "chef-solo/vendored-cookbooks/homebrew/metadata.json",
60
+ "chef-solo/vendored-cookbooks/homebrew/metadata.rb",
61
+ "chef-solo/vendored-cookbooks/homebrew/providers/tap.rb",
62
+ "chef-solo/vendored-cookbooks/homebrew/recipes/default.rb",
63
+ "chef-solo/vendored-cookbooks/homebrew/resources/tap.rb",
64
+ "lib/natives.rb",
65
+ "lib/natives/app.rb",
66
+ "lib/natives/cli.rb",
67
+ "natives.gemspec",
68
+ "spec/natives/app_spec.rb",
69
+ "spec/spec_helper.rb"
70
+ ]
71
+ s.homepage = "http://github.com/teohm/natives"
72
+ s.licenses = ["MIT"]
73
+ s.require_paths = ["lib"]
74
+ s.rubygems_version = "2.1.10"
75
+ s.summary = "Install libraries required by rubygems' native extension."
76
+
77
+ if s.respond_to? :specification_version then
78
+ s.specification_version = 4
79
+
80
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
81
+ s.add_runtime_dependency(%q<chef>, [">= 11.6.2"])
82
+ s.add_runtime_dependency(%q<natives-catalog>, [">= 0.3"])
83
+ s.add_runtime_dependency(%q<thor>, [">= 0"])
84
+ s.add_development_dependency(%q<rspec>, [">= 0"])
85
+ s.add_development_dependency(%q<yard>, [">= 0"])
86
+ s.add_development_dependency(%q<rdoc>, [">= 0"])
87
+ s.add_development_dependency(%q<bundler>, [">= 0"])
88
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
89
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
90
+ else
91
+ s.add_dependency(%q<chef>, [">= 11.6.2"])
92
+ s.add_dependency(%q<natives-catalog>, [">= 0.3"])
93
+ s.add_dependency(%q<thor>, [">= 0"])
94
+ s.add_dependency(%q<rspec>, [">= 0"])
95
+ s.add_dependency(%q<yard>, [">= 0"])
96
+ s.add_dependency(%q<rdoc>, [">= 0"])
97
+ s.add_dependency(%q<bundler>, [">= 0"])
98
+ s.add_dependency(%q<jeweler>, [">= 0"])
99
+ s.add_dependency(%q<simplecov>, [">= 0"])
100
+ end
101
+ else
102
+ s.add_dependency(%q<chef>, [">= 11.6.2"])
103
+ s.add_dependency(%q<natives-catalog>, [">= 0.3"])
104
+ s.add_dependency(%q<thor>, [">= 0"])
105
+ s.add_dependency(%q<rspec>, [">= 0"])
106
+ s.add_dependency(%q<yard>, [">= 0"])
107
+ s.add_dependency(%q<rdoc>, [">= 0"])
108
+ s.add_dependency(%q<bundler>, [">= 0"])
109
+ s.add_dependency(%q<jeweler>, [">= 0"])
110
+ s.add_dependency(%q<simplecov>, [">= 0"])
111
+ end
112
+ end
113
+