Module: Bits::InstallerMixin

Defined in:
lib/bits/installer_mixin.rb

Instance Method Summary collapse

Instance Method Details

#install_package(package, force = false) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/bits/installer_mixin.rb', line 14

def install_package package, force=false
  atom = package.atom

  if package.installed? and not force
    log.info "Already installed '#{atom}'"
    return
  end

  matching = package.matching_ppps

  raise "No matching PPP could be found" if matching.empty?

  ppp = pick_one atom, matching

  install_ppp atom, ppp
end

#resolve_dependencies(manifest, criteria) ⇒ Object

Resolve a hash of dependencies with a criteria to packages. Returns [<packages>, error]



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/bits/installer_mixin.rb', line 33

def resolve_dependencies(manifest, criteria)
  repository = ns[:repository]

  raise "No repository in namespace" if repository.nil?

  packages = Array.new
  missing = Array.new

  manifest.depends.each do |dep|
    crit = Hash.new

    crit.update criteria
    crit.update dep.parameters

    begin
      packages << repository.find_package(dep.atom, crit)
    rescue Bits::MissingBit
      missing << dep
    end
  end

  unless missing.empty?
    raise Bits::MissingDependencies.new missing
  end

  packages
end

#setup_installer_opts(opts) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/bits/installer_mixin.rb', line 4

def setup_installer_opts opts
  opts.on('--[no-]compiled', "Insist on installing an already compiled variant or not") do |v|
    ns[:compiled] = v
  end

  opts.on('--force', "Insist on installing even if packages already installed") do |v|
    ns[:force] = v
  end
end