Module: Emerge

Defined in:
lib/vmbuilder_plugins/emerge.rb

Overview

Purpose

emerge is a Capistrano plugin module providing a set of methods that invoke the portage package manage (as used in Gentoo)

Installs within Capistrano as the plugin emerge.

Usage

require 'marshall/plugins/emerge'

Prefix all calls to the library with emerge.

Constant Summary collapse

EMERGE =

Default emerge command - reduce interactivity to the minimum

"emerge -q"

Instance Method Summary collapse

Instance Method Details

#clean(options = {}) ⇒ Object

Run clean old/unused packages



37
38
39
40
41
42
# File 'lib/vmbuilder_plugins/emerge.rb', line 37

def clean(options={})
  cmd = <<-CMD
    sh -c "#{EMERGE} -clean"
  CMD
  sudo(cmd, options)
end

#install(packages, options = {}) ⇒ Object

Emerge a new package or packages



29
30
31
32
33
34
# File 'lib/vmbuilder_plugins/emerge.rb', line 29

def install(packages, options={})
  cmd = <<-CMD
  sh -c "#{EMERGE} #{packages.join(" ")}"
  CMD
  sudo(cmd, options)
end

#rc_update(packages, setting) ⇒ Object

Boot script manipulation command



69
70
71
72
73
# File 'lib/vmbuilder_plugins/emerge.rb', line 69

def rc_update(packages, setting)
  packages.each do |service|
    sudo "rc_update add #{service} #{setting}"
  end
end

#update(options = {}) ⇒ Object

Update all installed packages



61
62
63
64
65
66
# File 'lib/vmbuilder_plugins/emerge.rb', line 61

def update(options={})
  cmd = <<-CMD
    sh -c "#{EMERGE} --update --deep --newuse world"
  CMD
  sudo(cmd, options)
end

#update_system(options = {}) ⇒ Object

Update portage



53
54
55
56
57
58
# File 'lib/vmbuilder_plugins/emerge.rb', line 53

def update_system(options={})
  cmd = <<-CMD
    sh -c "#{EMERGE} portage"
  CMD
  sudo(cmd, options)
end

#upgrade(options = {}) ⇒ Object

Upgrade installed package list



45
46
47
48
49
50
# File 'lib/vmbuilder_plugins/emerge.rb', line 45

def upgrade(options={})
  cmd = <<-CMD
    sh -c "#{EMERGE} --sync"
  CMD
  sudo(cmd, options)
end