Class: Autoproj::OSRepositoryInstaller

Inherits:
Object
  • Object
show all
Defined in:
lib/autoproj/os_repository_installer.rb

Constant Summary collapse

OS_REPOSITORY_MANAGERS =
{
    "debian" => RepositoryManagers::APT
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ws) ⇒ OSRepositoryInstaller

Returns a new instance of OSRepositoryInstaller.



17
18
19
20
21
22
23
# File 'lib/autoproj/os_repository_installer.rb', line 17

def initialize(ws)
    @ws = ws
    @repository_managers = {}
    OS_REPOSITORY_MANAGERS.each do |name, klass|
        @repository_managers[name] = klass.new(ws)
    end
end

Instance Attribute Details

#repository_managersObject (readonly)

Returns the set of repository managers



11
12
13
# File 'lib/autoproj/os_repository_installer.rb', line 11

def repository_managers
  @repository_managers
end

#wsObject (readonly)

The workspace object



8
9
10
# File 'lib/autoproj/os_repository_installer.rb', line 8

def ws
  @ws
end

Instance Method Details

#each_manager(&block) ⇒ Object



41
42
43
# File 'lib/autoproj/os_repository_installer.rb', line 41

def each_manager(&block)
    repository_managers.each_value(&block)
end

#install_os_repositoriesObject



45
46
47
48
49
50
51
# File 'lib/autoproj/os_repository_installer.rb', line 45

def install_os_repositories
    return if os_repository_resolver.resolved_entries.empty?

    deps = os_repository_manager.os_dependencies
    ws.install_os_packages(deps, all: nil) unless deps.empty?
    os_repository_manager.install(os_repository_resolver.resolved_entries)
end

#os_repository_managerObject

Returns the repository manager object for the current OS



30
31
32
33
34
35
36
37
38
39
# File 'lib/autoproj/os_repository_installer.rb', line 30

def os_repository_manager
    return @os_repository_manager if @os_repository_manager

    os_names, = os_repository_resolver.operating_system
    os_name = os_names.find { |name| OS_REPOSITORY_MANAGERS[name] }

    @os_repository_manager =
        repository_managers[os_name] ||
        RepositoryManagers::UnknownOSManager.new(ws)
end

#os_repository_resolverObject



25
26
27
# File 'lib/autoproj/os_repository_installer.rb', line 25

def os_repository_resolver
    ws.os_repository_resolver
end