Class: Babushka::AptHelper

Inherits:
PkgHelper show all
Defined in:
lib/babushka/pkg_helpers/apt_helper.rb

Class Method Summary collapse

Methods inherited from PkgHelper

all_manager_keys, bin_path, handle_install!, has?, install!, prefix, present?, should_sudo?, update_pkg_lists

Methods included from ShellHelpers

cmd_dir, current_username, log_shell, login_shell, raw_shell, shell, shell!, shell?, shell_cmd, sudo, which

Methods included from LogHelpers

debug, deprecated!, log, log_block, log_error, log_ok, log_stderr, log_warn, removed!

Class Method Details

.manager_depObject


7
# File 'lib/babushka/pkg_helpers/apt_helper.rb', line 7

def manager_dep; 'core:apt' end

.manager_keyObject


6
# File 'lib/babushka/pkg_helpers/apt_helper.rb', line 6

def manager_key; :apt end

.pkg_binaryObject


9
10
11
# File 'lib/babushka/pkg_helpers/apt_helper.rb', line 9

def pkg_binary
  @_cached_pkg_binary ||= which('aptitude') ? 'aptitude' : 'apt-get'
end

.pkg_cmdObject


5
# File 'lib/babushka/pkg_helpers/apt_helper.rb', line 5

def pkg_cmd; "env DEBCONF_TERSE='yes' DEBIAN_PRIORITY='critical' DEBIAN_FRONTEND='noninteractive' #{pkg_binary}" end

.pkg_typeObject


4
# File 'lib/babushka/pkg_helpers/apt_helper.rb', line 4

def pkg_type; :deb end

.source_for_systemObject


22
23
24
25
26
27
28
# File 'lib/babushka/pkg_helpers/apt_helper.rb', line 22

def source_for_system
  {
    :debian => 'http://http.debian.net/debian',
    :ubuntu => 'http://archive.ubuntu.com/ubuntu',
    :raspbian => 'http://archive.raspbian.org/raspbian',
  }[Babushka.host.flavour]
end

.source_matcher_for_systemObject


30
31
32
33
34
35
36
# File 'lib/babushka/pkg_helpers/apt_helper.rb', line 30

def source_matcher_for_system
  {
    :debian => %r{http://(ftp\d?\.(\w\w\.)?debian\.org|(http|cdn)\.debian\.net)/debian/?},
    :ubuntu => %r{http://((\w\w-(.*)-\d\.ec2\.)|(\w\w\.))?archive\.ubuntu\.com/ubuntu/?},
    :raspbian => %r{http://(archive|mirrordirector)\.raspbian\.org/raspbian/?},
  }[Babushka.host.flavour]
end

.update_pkg_lists_if_requiredObject


13
14
15
16
17
18
19
20
# File 'lib/babushka/pkg_helpers/apt_helper.rb', line 13

def update_pkg_lists_if_required
  wait_for_dpkg
  if !File.exists? '/var/lib/apt/lists/lock'
    update_pkg_lists "Looks like apt hasn't been used on this system yet. Updating"
  else
    super
  end
end