Class: DanarchyDeploy::System::Gentoo

Inherits:
Object
  • Object
show all
Defined in:
lib/danarchy_deploy/system/gentoo.rb

Class Method Summary collapse

Class Method Details

.new(deployment, options) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/danarchy_deploy/system/gentoo.rb', line 5

def self.new(deployment, options)
  puts "\n" + self.name
  puts 'Gentoo detected! Using emerge.'

  set_hostname(deployment[:hostname]) if !options[:pretend]
  installer  = 'emerge --usepkg --buildpkg --quiet --noreplace '
  # This needs cpuid2cpuflags to build make.conf; don't --pretend here.
  system("qlist -I cpuid2cpuflags &>/dev/null || #{installer} cpuid2cpuflags &>/dev/null")
  installer += '--pretend ' if options[:pretend]

  updater  = 'emerge --usepkg --buildpkg --update --deep --newuse --quiet --with-bdeps=y @world'
  updater += ' --pretend' if options[:pretend]

  cleaner  = 'emerge --depclean --quiet '
  cleaner += '--pretend ' if options[:pretend]

  if emerge_sync_in_progress
    puts "\n >  Waiting for emerge sync to complete."
    emerge_sync_wait
  end

  if deployment[:portage]
    if deployment[:portage][:templates]
      puts "\nChecking Portage configs."
      DanarchyDeploy::Templater.new(deployment[:portage][:templates], options)
    end

    emerge_sync(deployment[:portage][:sync], options)
  end

  [installer, updater, cleaner]
end