Skip to content

Commit

Permalink
- Emerge Cookbook, making unmasking packages easier.
Browse files Browse the repository at this point in the history
    - See README for specifics.

Signed-off-by: Scott M. Likens <slikens@engineyard.com>
  • Loading branch information
Scott M. Likens committed Jul 1, 2010
1 parent 070f6cc commit 31871fc
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cookbooks/emerge/README.rdoc
@@ -0,0 +1,22 @@
= DESCRIPTION:

Emerge Cookbook.

This cookbook holds 2 definitions, one called enable_package and one called update_file. Between these two definitions it enables you to 'unmask' a package in Chef and then install an 'masked' version of said package.

= USAGE:

For example if you want to install Libxml 2.7.6 on the AppCloud you would use the following as a recipe.

enable_package "dev-libs/libxml2" do
version "2.7.6"
end

package "dev-libs/libxml2" do
version "2.7.6"
action :install
end

= LEGEND:

Gentoo uses the names 'mask' and 'unmask' terminology between stable and unstable. Typically this is done in /etc/make.conf with ACCEPT_KEYWORDS declaration for '~amd64 and ~x86". However it can also be added to /etc/portage/package.keywords/local to 'unmask' packages individually.
11 changes: 11 additions & 0 deletions cookbooks/emerge/definitions/enable_package.rb
@@ -0,0 +1,11 @@
define :enable_package, :version => nil do
name = params[:name]
version = params[:version]
full_name = name << ("-#{version}" if version)

update_file "local portage package.keywords" do
path "/etc/portage/package.keywords/local"
body "=#{full_name}"
not_if "grep '=#{full_name}' /etc/portage/package.keywords/local"
end
end
34 changes: 34 additions & 0 deletions cookbooks/emerge/definitions/update_file.rb
@@ -0,0 +1,34 @@
define :update_file, :action => :append do
require 'tempfile'

filepath = params[:path] || params[:name]

file params[:name] do
backup params[:backup] if params[:backup]
group params[:group] if params[:group]
mode params[:mode] if params[:mode]
owner params[:owner] if params[:owner]
path filepath
end

case params[:action].to_sym
when :append, :rewrite

mode = params[:action].to_sym == :append ? 'a' : 'w'

ruby_block "#{params[:action]}-to-#{filepath}" do
block do
File.open(filepath, mode) do |f|
f.puts params[:body]
end
end
end

when :truncate

execute "truncate-#{filepath}" do
command "> #{filepath}"
end

end
end

0 comments on commit 31871fc

Please sign in to comment.